技术领域Technical Field
本申请涉及通讯技术,应用于物联网(internet of things,IoT)领域,尤其涉及一种用于物联网的信息处理方法及相关装置。The present application relates to communication technology, which is applied to the field of Internet of Things (IoT), and in particular to an information processing method and related devices for IoT.
背景技术Background Art
随着IoT应用技术的普及,智能设备已经走进千家万户。消息队列遥感传输(message queuing telemetry transport,MQTT)协议系统可以帮助用户根据自己的需求控制智能家设备,这为用户的工作与生活带来便利。MQTT协议是一种基于传输控制(transmission control protocol,TCP)/网际互连(internet protocol,IP)协议上传输的轻量级通讯协议,采用发布和订阅机制。其中,订阅者通过MQTT服务器只接收自己订阅的主题数据,非订阅的则不接受,发布者只需向MQTT服务器中针对约定的主题发布消息即可,这样既交换了必要的数据,又避免了存储和处理无效的数据。所以,MQTT协议在IoT领域得到广泛应用。With the popularization of IoT application technology, smart devices have entered thousands of households. The message queuing telemetry transport (MQTT) protocol system can help users control smart home devices according to their needs, which brings convenience to users' work and life. The MQTT protocol is a lightweight communication protocol based on the transmission control protocol (TCP)/Internet protocol (IP) protocol, which adopts a publish and subscribe mechanism. Among them, subscribers only receive the topic data they subscribe to through the MQTT server, and non-subscribers do not receive it. The publisher only needs to publish messages to the agreed topic in the MQTT server, which not only exchanges necessary data, but also avoids storing and processing invalid data. Therefore, the MQTT protocol is widely used in the field of IoT.
在通常情况下,MQTT服务器会同时管理成千上万的设备连接,当所有的连接都同时负载在一个MQTT服务器之上,暴增的连接数会导致服务器过载,消息处理也不能实时投递。Normally, an MQTT server will manage tens of thousands of device connections at the same time. When all connections are loaded on one MQTT server at the same time, the surge in the number of connections will cause the server to be overloaded and message processing will not be delivered in real time.
发明内容Summary of the invention
本申请实施例公开了一种用于物联网的信息处理方法及相关装置,建立异构MQTT集群,用于缓解MQTT服务器的负载压力,提高消息处理效率。The embodiments of the present application disclose an information processing method and related devices for the Internet of Things, which establish a heterogeneous MQTT cluster to alleviate the load pressure of the MQTT server and improve the message processing efficiency.
第一方面,本申请实施例提供了一种用于物联网的信息处理方法,该方法包括:In a first aspect, an embodiment of the present application provides an information processing method for the Internet of Things, the method comprising:
桥接服务器接收业务端发送的控制指令,其中,所述控制指令用于请求执行第一功能;The bridge server receives a control instruction sent by the service end, wherein the control instruction is used to request execution of a first function;
所述桥接服务器对所述控制指令进行转换,得到基于消息队列遥感传输MQTT的第一控制消息;The bridge server converts the control instruction to obtain a first control message based on message queue remote sensing transmission MQTT;
所述桥接服务器向MQTT集群中的第一MQTT服务器发送所述第一控制消息,其中,所述MQTT集群包括至少两个不同厂商的MQTT服务器,所述第一控制消息用于指示对所述第一MQTT服务器维护的第一设备执行所述第一功能。The bridge server sends the first control message to a first MQTT server in an MQTT cluster, wherein the MQTT cluster includes at least two MQTT servers from different manufacturers, and the first control message is used to instruct to execute the first function on a first device maintained by the first MQTT server.
上述方法中,业务端(如智能锁、智能灯、智能温度计等智能设备的业务系统)可基于相关协议,如超文本传输协议(hyper text transfer protocol,HTTP)、远程过程调用(remote procedure call,RPC)协议、双向实时通讯(WebSocket)协议等信息传输协议,与桥接服务器进行信息交互。因此,该桥接服务器可适配不同的业务端,接收来自业务端的控制指令。In the above method, the business end (such as the business system of smart devices such as smart locks, smart lights, and smart thermometers) can interact with the bridge server based on relevant protocols, such as hypertext transfer protocol (HTTP), remote procedure call (RPC), two-way real-time communication (WebSocket) and other information transmission protocols. Therefore, the bridge server can adapt to different business ends and receive control instructions from the business ends.
桥接服务器可基于相关协议,如HTTP协议、RPC协议、MQTT协议等信息传输协议,与不同厂商的MQTT服务器进行信息交互。因此,该桥接服务器可适配不同厂商的MQTT服务器,向MQTT服务器发送控制消息,建立异构MQTT集群。The bridge server can exchange information with MQTT servers of different manufacturers based on relevant protocols, such as HTTP protocol, RPC protocol, MQTT protocol and other information transmission protocols. Therefore, the bridge server can adapt to MQTT servers of different manufacturers, send control messages to MQTT servers, and establish heterogeneous MQTT clusters.
响应于业务端发送的控制指令,桥接服务器对该控制指令进行转换,得到基于MQTT的第一控制消息,并将该第一控制消息发送至MQTT集群中的第一MQTT服务器。具体的,该控制指令的格式取决于该桥接服务器与该业务端连接所基于的信息传输协议,第一控制消息的格式取决于该桥接服务器与第一MQTT服务器连接所基于的信息传输协议。因此,该桥接服务器作为该业务端和第一MQTT服务器进行信息交互的枢纽,业务端可通过桥接服务器指示第一设备执行第一功能。In response to the control instruction sent by the service end, the bridge server converts the control instruction to obtain a first control message based on MQTT, and sends the first control message to the first MQTT server in the MQTT cluster. Specifically, the format of the control instruction depends on the information transmission protocol based on which the bridge server is connected to the service end, and the format of the first control message depends on the information transmission protocol based on which the bridge server is connected to the first MQTT server. Therefore, the bridge server serves as a hub for information interaction between the service end and the first MQTT server, and the service end can instruct the first device to execute the first function through the bridge server.
进一步的,当多个业务端需和同一个MQTT服务器进行信息交互时,MQTT服务器可通过一个桥接服务器与多个业务端进行交互,而不是直接与多个业务端建立连接,这大大缓解了MQTT服务器的负载压力,提高了消息处理效率。Furthermore, when multiple business terminals need to exchange information with the same MQTT server, the MQTT server can interact with multiple business terminals through a bridge server instead of directly establishing connections with multiple business terminals. This greatly alleviates the load pressure of the MQTT server and improves message processing efficiency.
进一步的,当同一个业务端和多个MQTT服务器进行信息交互时,基于桥接服务器和不同MQTT服务器连接所基于的信息传输协议,由于桥接服务器可以将接收到的控制指令转换为适应不同MQTT服务器的控制消息,从而可以实现对不同MQTT服务器各自维护的设备的联动控制,即实现对不同厂商设备的联动控制。Furthermore, when the same business end interacts with multiple MQTT servers, based on the information transmission protocol on which the bridge server and different MQTT servers are connected, the bridge server can convert the received control instructions into control messages that are suitable for different MQTT servers. This can achieve linkage control of devices maintained by different MQTT servers, that is, linkage control of devices from different manufacturers.
结合第一方面,在一种可能的实现方式中,所述控制指令还用于请求执行第二功能,所述方法还包括:In combination with the first aspect, in a possible implementation manner, the control instruction is further used to request execution of a second function, and the method further includes:
所述桥接服务器对所述控制指令进行转换,得到基于MQTT的第二控制消息;The bridge server converts the control instruction to obtain a second control message based on MQTT;
所述桥接服务器向MQTT集群中的第二MQTT服务器发送所述第二控制消息,其中,所述第二控制消息用于指示对所述第二MQTT服务器维护的第二设备执行所述第二功能,所述第一MQTT服务器和所述第二MQTT服务器为两个不同厂商的MQTT服务器。The bridging server sends the second control message to the second MQTT server in the MQTT cluster, wherein the second control message is used to instruct execution of the second function on a second device maintained by the second MQTT server, and the first MQTT server and the second MQTT server are MQTT servers from two different manufacturers.
桥接服务器将该控制指令分别转换为多个基于MQTT的多个控制消息,多个控制消息可以分别用于控制不同的功能,因此采用本申请实施例能够通过一个控制指令实现对多种不同功能的联动控制。另外,由于第一MQTT服务器和第二MQTT服务器为两个不同厂商的MQTT服务器,因此采用本申请实施例能够通过该控制指令指示不同厂商的设备分别执行不同的功能,实现不同厂商设备的联动控制。The bridge server converts the control instruction into multiple control messages based on MQTT, and the multiple control messages can be used to control different functions. Therefore, the embodiment of the present application can realize the linkage control of multiple different functions through one control instruction. In addition, since the first MQTT server and the second MQTT server are MQTT servers of two different manufacturers, the embodiment of the present application can instruct devices of different manufacturers to perform different functions respectively through the control instruction, thereby realizing the linkage control of devices of different manufacturers.
结合第一方面,在另一种可能的实现方式中,若所述控制指令请求控制的设备所属的MQTT服务器为非自研MQTT服务器,则所述桥接服务器与所述第一MQTT服务器基于MQTT协议建立连接,所述第一控制消息属于主题发布消息;其中,所述非自研MQTT服务器包括开源MQTT服务器或云MQTT服务器。In combination with the first aspect, in another possible implementation method, if the MQTT server to which the device controlled by the control instruction request belongs is a non-self-developed MQTT server, the bridge server establishes a connection with the first MQTT server based on the MQTT protocol, and the first control message belongs to a topic publishing message; wherein the non-self-developed MQTT server includes an open source MQTT server or a cloud MQTT server.
若所述控制指令请求控制的设备所属的MQTT服务器为自研MQTT服务器,则所述桥接服务器与所述第一MQTT服务器基于远程过程调用RPC协议建立连接,所述第一控制消息属于RPC消息。If the MQTT server to which the device controlled by the control instruction request belongs is a self-developed MQTT server, the bridge server establishes a connection with the first MQTT server based on the remote procedure call RPC protocol, and the first control message is an RPC message.
具体的,RPC协议中接受者可以直接通过MQTT服务器接收发布者发送的RPC消息,保证RPC消息实时传递,但是对于非自研MQTT服务器的场景,该非自研MQTT服务器无法基于RPC协议与其他设备进行通信,因此本申请实施例同时引入了RPC协议和MQTT协议,既能够兼顾消息传输效率也可以适应更多的应用场景。结合第一方面,在又一种可能的实现方式中,所述桥接服务器包括桥接Bridge模块;所述桥接服务器对所述控制指令进行转换,包括:Specifically, in the RPC protocol, the recipient can directly receive the RPC message sent by the publisher through the MQTT server to ensure the real-time delivery of the RPC message. However, for the scenario of non-self-developed MQTT server, the non-self-developed MQTT server cannot communicate with other devices based on the RPC protocol. Therefore, the embodiment of the present application introduces both the RPC protocol and the MQTT protocol, which can take into account both the message transmission efficiency and adapt to more application scenarios. In combination with the first aspect, in another possible implementation method, the bridge server includes a bridge module; the bridge server converts the control instruction, including:
所述桥接服务器通过所述桥接Bridge模块对所述控制指令进行转换。The bridge server converts the control instruction through the bridge module.
上述方法中,Bridge模块可存储多个信息传输协议格式之间的对应关系,作为业务端和第一MQTT服务器交互的中介,对来自该业务端的控制指令进行转换。In the above method, the Bridge module can store the correspondence between multiple information transmission protocol formats, serve as an intermediary for the interaction between the business end and the first MQTT server, and convert the control instructions from the business end.
结合第一方面,在又一种可能的实现方式中,所述MQTT集群中的各个MQTT服务器通过所述桥接服务器提供的桥接Bridge模块建立所述MQTT集群。In combination with the first aspect, in yet another possible implementation, each MQTT server in the MQTT cluster establishes the MQTT cluster through a bridge module provided by the bridge server.
可选的,该MQTT集群中的MQTT服务器可为单机MQTT服务器。通常情况下,单机MQTT服务器仅支持连接一个设备和一个业务端,且不支持与其他MQTT服务器直接建立连接构建集群,所以一个业务端难以控制多个单机MQTT服务器所维护的多个设备。Optionally, the MQTT server in the MQTT cluster can be a stand-alone MQTT server. Generally, a stand-alone MQTT server only supports connecting one device and one service end, and does not support directly establishing a connection with other MQTT servers to build a cluster, so it is difficult for one service end to control multiple devices maintained by multiple stand-alone MQTT servers.
在上述方法中,该桥接服务器提供的桥接Bridge模块可连接多个单机MQTT服务器,将单机MQTT服务器集群在一起,所以业务端可以通过该桥接服务器控制多个单机MQTT服务器所维护的多个设备。且在这种集群模式下,单机MQTT服务器仅连接一个桥接服务器和一个设备,多个单机MQTT服务器的消息数据能够在一定程度上实现隔离、互不影响,也就是说,该集群模式不影响单机MQTT服务器的运行模式。In the above method, the bridge module provided by the bridge server can connect multiple stand-alone MQTT servers and cluster the stand-alone MQTT servers together, so the service end can control multiple devices maintained by multiple stand-alone MQTT servers through the bridge server. In this cluster mode, the stand-alone MQTT server is only connected to one bridge server and one device, and the message data of multiple stand-alone MQTT servers can be isolated to a certain extent and do not affect each other. In other words, the cluster mode does not affect the operation mode of the stand-alone MQTT server.
可选的,根据用户或应用场景的需求,通过编写特定程序,MQTT集群中的单机MQTT服务器可通过该桥接服务器提供的Bridge模块进行信息交互。上述方法中,多个单机MQTT服务器的消息数据能够在一定程度上实现信息交互,不再是隔离状态,这拓展了单机MQTT服务器的运行模式。Optionally, according to the needs of users or application scenarios, by writing specific programs, the stand-alone MQTT servers in the MQTT cluster can exchange information through the Bridge module provided by the bridge server. In the above method, the message data of multiple stand-alone MQTT servers can achieve information exchange to a certain extent and are no longer isolated, which expands the operation mode of the stand-alone MQTT server.
结合第一方面,在又一种可能的实现方式中,所述桥接服务器接收业务端发送的控制指令之前,还包括:In combination with the first aspect, in another possible implementation manner, before the bridge server receives the control instruction sent by the service end, the method further includes:
所述桥接服务器接收所述第一MQTT服务器发送的认证请求,其中,所述认证请求用于请求认证所述第一MQTT服务器维护的第一设备的身份和/或业务权限;The bridge server receives an authentication request sent by the first MQTT server, wherein the authentication request is used to request authentication of an identity and/or service authority of a first device maintained by the first MQTT server;
所述桥接服务器将所述认证请求分配至所述业务端,以供所述业务端认证所述第一MQTT服务器维护的第一设备。The bridge server distributes the authentication request to the service end so that the service end authenticates the first device maintained by the first MQTT server.
在上述方法中,第一设备需向第一MQTT服务器发送认证请求,便于业务端对其进行身份和/或业务权限认证,否则该设备不能向第一MQTT服务器订阅主题消息,进而收不到该MQTT服务器发送的第一控制消息。具体的,该主题对应控制指令请求执行的第一功能。In the above method, the first device needs to send an authentication request to the first MQTT server to facilitate the business end to authenticate its identity and/or business authority, otherwise the device cannot subscribe to the topic message from the first MQTT server, and thus cannot receive the first control message sent by the MQTT server. Specifically, the topic corresponds to the first function executed by the control instruction request.
通常情况下,第一MQTT服务器接收第一设备的认证请求后,识别该认证请求并分配至业务端,而在上述方法中,第一MQTT服务器不再承担识别并分配该认证请求至业务端的任务,只需将该认证请求发送至桥接服务器,该桥接服务器进一步识别和分配认证请求至业务端。也即是说,该桥接服务器针对不同MQTT服务器提供统一的认证接入口,向不同业务端提供它们各自所需的响应入口,从而缓解了第一MQTT服务器的负载压力。Normally, after receiving the authentication request from the first device, the first MQTT server identifies the authentication request and distributes it to the service end. In the above method, the first MQTT server no longer bears the task of identifying and distributing the authentication request to the service end, but only needs to send the authentication request to the bridge server, which further identifies and distributes the authentication request to the service end. In other words, the bridge server provides a unified authentication access point for different MQTT servers, and provides different service ends with their respective required response access points, thereby alleviating the load pressure of the first MQTT server.
可选的,所述桥接服务器包括钩子Hook模块,所述桥接服务器接收所述第一MQTT服务器发送的认证请求,包括:Optionally, the bridge server includes a hook module, and the bridge server receives the authentication request sent by the first MQTT server, including:
所述桥接服务器通过所述钩子Hook模块接收所述第一MQTT服务器发送的认证请求。The bridge server receives the authentication request sent by the first MQTT server through the hook module.
上述方法中,Hook模块可以是将MQTT集群中的MQTT服务器的认证模块独立出来,编写成钩子的形式,类似一个认证模块的集线器。In the above method, the Hook module can be to separate the authentication module of the MQTT server in the MQTT cluster and write it in the form of a hook, which is similar to a hub of an authentication module.
可选的,所述认证请求包括目标业务标识,所述桥接服务器将所述认证请求分配至所述业务端,包括:Optionally, the authentication request includes a target service identifier, and the bridge server distributes the authentication request to the service end, including:
所述桥接服务器将所述认证请求分配至所述目标业务标识对应的所述业务端,其中,所述桥接服务器存储了多个业务标识与多个业务端之间的对应关系。The bridge server distributes the authentication request to the service end corresponding to the target service identifier, wherein the bridge server stores a correspondence between a plurality of service identifiers and a plurality of service ends.
具体的,目标业务标识包括MQTT用户Client身份证明ID前缀标识或用户名前缀标识。Specifically, the target business identifier includes the MQTT user Client identity ID prefix identifier or the user name prefix identifier.
通常情况下,不同的设备类型往往意味着不同的业务逻辑,甚至数据来源于不同数据库,登录认证的方式也不尽相同,所以,设备认证请求消息处理的效率较低。上述方法中,桥接服务器将来自多个设备的认证请求集中在一起,并再根据认证请求中的目标业务标识(如MQTT用户Client身份证明ID前缀标识、用户名前缀标识等标识)将不同的认证请求分配至对应业务端。采用目标业务标识对认证请求进行识别和分配的方法适用范围广,桥接服务器只需储存多个业务标识与多个业务端之间的对应关系,就能根据目标业务表示精准地将认证请求分配到对应的业务端,提高了不同设备认证请求消息的处理的效率。Normally, different device types often mean different business logics, and even the data comes from different databases, and the login authentication methods are also different. Therefore, the efficiency of device authentication request message processing is low. In the above method, the bridge server brings together the authentication requests from multiple devices, and then assigns different authentication requests to the corresponding business end according to the target business identifier in the authentication request (such as the MQTT user Client identity ID prefix identifier, the user name prefix identifier, etc.). The method of identifying and assigning authentication requests using the target business identifier has a wide range of applications. The bridge server only needs to store the correspondence between multiple business identifiers and multiple business ends, and can accurately assign authentication requests to the corresponding business end according to the target business representation, thereby improving the efficiency of processing authentication request messages from different devices.
结合第一方面,在又一种可能的实现方式中,所述桥接服务器向MQTT集群中的第一MQTT服务器发送所述第一控制消息之后,还包括:In combination with the first aspect, in another possible implementation manner, after the bridge server sends the first control message to the first MQTT server in the MQTT cluster, the method further includes:
所述桥接服务器接收所述第一MQTT服务器发送的第一消息;The bridge server receives a first message sent by the first MQTT server;
所述桥接服务器向所述业务端发送第一消息,其中,所述第一消息包括所述第一MQTT服务器维护的第一设备执行所述第一功能的结果。The bridge server sends a first message to the service end, wherein the first message includes a result of a first device maintained by the first MQTT server executing the first function.
可选的,所述第一MQTT服务器维护的第一设备执行所述第一功能的结果为经加密处理的消息,所述桥接服务器用于对所述经加密处理的结果进行解密,所述桥接服务器向所述业务端发送的结果为经解密处理的消息。Optionally, the result of the first device maintained by the first MQTT server executing the first function is an encrypted message, the bridge server is used to decrypt the encrypted result, and the result sent by the bridge server to the service end is a decrypted message.
通常情况下,设备和MQTT服务器运行在广域网中,业务端和MQTT服务器运行在局域网中,设备发送至MQTT服务器的加密结果只能由业务端进行解密。上述方法中,桥接服务器可将第一设备发送至第一MQTT服务器的经加密处理的结果解密为业务端所能处理的消息,解密结果消息不需要业务端实现,因此提高了业务端对结果消息的处理效率。Normally, the device and the MQTT server run in a wide area network, the service end and the MQTT server run in a local area network, and the encrypted result sent by the device to the MQTT server can only be decrypted by the service end. In the above method, the bridge server can decrypt the encrypted result sent by the first device to the first MQTT server into a message that can be processed by the service end, and the decrypted result message does not need to be implemented by the service end, thereby improving the efficiency of the service end in processing the result message.
结合第一方面,在又一种可能的实现方式中,所述桥接服务器与数据库基于相关的信息传输协议(比如HTTP协议、RPC协议)建立连接,其中,所述数据库用于对所述桥接服务器接收或发送的消息进行持久化存储。In combination with the first aspect, in another possible implementation, the bridge server establishes a connection with a database based on a relevant information transmission protocol (such as HTTP protocol, RPC protocol), wherein the database is used to persistently store messages received or sent by the bridge server.
结合第一方面,在又一种可能的实现方式中,所述桥接服务器与数据流处理平台基于相关的信息传输协议(比如HTTP协议、RPC协议)建立连接,所述数据流处理平台用于对所述桥接服务器接收或发送的消息进行流式处理和大数据分析。具体的,所述大数据分析用于统计所述第一MQTT服务器维护的设备的使用状态、所述业务端的使用习惯、所述桥接服务器接收或发送的消息属性及吞吐量中的任意一项或多项。In combination with the first aspect, in another possible implementation, the bridge server establishes a connection with the data stream processing platform based on a relevant information transmission protocol (such as HTTP protocol, RPC protocol), and the data stream processing platform is used to perform streaming processing and big data analysis on the messages received or sent by the bridge server. Specifically, the big data analysis is used to count any one or more of the usage status of the device maintained by the first MQTT server, the usage habits of the business end, the message attributes received or sent by the bridge server, and the throughput.
上述方法中,通过数据流处理平台,桥接服务器缓解了MQTT集群的吞吐压力,并使运营系统对消息数据进行二次清晰。In the above method, through the data stream processing platform, the bridge server alleviates the throughput pressure of the MQTT cluster and enables the operation system to perform secondary clarification of the message data.
第二方面,本申请实施例提供了一种用于物联网的信息处理装置,该装置包括接收单元、转换单元和发送单元,用于实现第一方面或第一方面任一种可能的实施方式所描述的方法。In a second aspect, an embodiment of the present application provides an information processing device for the Internet of Things, the device comprising a receiving unit, a conversion unit and a sending unit, for implementing the method described in the first aspect or any possible implementation manner of the first aspect.
结合第二方面,在一种可能的实现方式中,所述装置用于:In conjunction with the second aspect, in a possible implementation manner, the device is used to:
接收单元,用于接收业务端发送的控制指令,其中,所述控制指令用于请求执行第一功能;A receiving unit, configured to receive a control instruction sent by a service end, wherein the control instruction is used to request execution of a first function;
转换单元,用于对所述控制指令进行转换,得到基于消息队列遥感传输MQTT的第一控制消息;A conversion unit, used for converting the control instruction to obtain a first control message based on message queue remote sensing transmission MQTT;
发送单元,用于向MQTT集群中的第一MQTT服务器发送所述第一控制消息,其中,所述MQTT集群包括至少两个不同厂商的MQTT服务器,所述第一控制消息用于指示对所述第一MQTT服务器维护的第一设备执行所述第一功能。A sending unit is used to send the first control message to a first MQTT server in an MQTT cluster, wherein the MQTT cluster includes at least two MQTT servers from different manufacturers, and the first control message is used to instruct a first device maintained by the first MQTT server to execute the first function.
结合第二方面,在另一种可能的实现方式中,所述控制指令还用于请求执行第二功能:In conjunction with the second aspect, in another possible implementation manner, the control instruction is further used to request execution of a second function:
所述转换单元还用于对所述控制指令进行转换,得到基于MQTT的第二控制消息;The conversion unit is further used to convert the control instruction to obtain a second control message based on MQTT;
所述发送单元还用于向MQTT集群中的第二MQTT服务器发送所述第二控制消息,其中,所述第二控制消息用于指示对所述第二MQTT服务器维护的第二设备执行所述第二功能,所述第一MQTT服务器和所述第二MQTT服务器为两个不同厂商的MQTT服务器。The sending unit is also used to send the second control message to a second MQTT server in the MQTT cluster, wherein the second control message is used to instruct execution of the second function on a second device maintained by the second MQTT server, and the first MQTT server and the second MQTT server are MQTT servers from two different manufacturers.
结合第二方面,在又一种可能的实现方式中,若所述控制指令请求控制的设备所属的MQTT服务器为非自研MQTT服务器,则所述装置与所述第一MQTT服务器基于MQTT协议建立连接,所述第一控制消息属于主题发布消息;In combination with the second aspect, in another possible implementation manner, if the MQTT server to which the device controlled by the control instruction request belongs is a non-self-developed MQTT server, the device establishes a connection with the first MQTT server based on the MQTT protocol, and the first control message belongs to a topic publishing message;
若所述控制指令请求控制的设备所属的MQTT服务器为自研MQTT服务器,则所述装置与所述第一MQTT服务器基于远程过程调用RPC协议建立连接,所述第一控制消息属于RPC消息。If the MQTT server to which the device controlled by the control instruction request belongs is a self-developed MQTT server, the device establishes a connection with the first MQTT server based on the remote procedure call RPC protocol, and the first control message is an RPC message.
结合第二方面,在又一种可能的实现方式中,所述转换单元包括桥接Bridge模块;在对所述控制指令进行转换方面,所述转化单元具体用于:In conjunction with the second aspect, in another possible implementation manner, the conversion unit includes a bridge module; in terms of converting the control instruction, the conversion unit is specifically used to:
通过所述桥接Bridge模块对所述控制指令进行转换。The control instruction is converted by the bridge module.
结合第二方面,在又一种可能的实现方式中,所述MQTT集群中的各个MQTT服务器通过所述转换单元提供的桥接Bridge模块建立所述MQTT集群。In combination with the second aspect, in yet another possible implementation, each MQTT server in the MQTT cluster establishes the MQTT cluster through a bridge module provided by the conversion unit.
结合第二方面,在又一种可能的实现方式中,在所述接收单元接收业务端发送的控制指令之前:In conjunction with the second aspect, in yet another possible implementation, before the receiving unit receives the control instruction sent by the service end:
所述接收单元还用于接收所述第一MQTT服务器发送的认证请求,其中,所述认证请求用于请求认证所述第一MQTT服务器维护的第一设备的身份和/或业务权限;The receiving unit is further used to receive an authentication request sent by the first MQTT server, wherein the authentication request is used to request authentication of the identity and/or service authority of the first device maintained by the first MQTT server;
所述发送单元还用于将所述认证请求分配至所述业务端,以供所述业务端认证所述第一MQTT服务器维护的第一设备。The sending unit is further used to distribute the authentication request to the service end so that the service end can authenticate the first device maintained by the first MQTT server.
可选的,所述接收单元包括钩子Hook模块,在接收所述第一MQTT服务器发送的认证请求方面,所述接收单元具体用于:Optionally, the receiving unit includes a hook module, and in receiving the authentication request sent by the first MQTT server, the receiving unit is specifically used to:
通过所述钩子Hook模块接收所述第一MQTT服务器发送的认证请求。The authentication request sent by the first MQTT server is received through the hook module.
可选的,所述认证请求包括目标业务标识,在将所述认证请求分配至所述业务端方面,所述发送单元具体用于:Optionally, the authentication request includes a target service identifier, and in terms of allocating the authentication request to the service end, the sending unit is specifically configured to:
将所述认证请求分配至所述目标业务标识对应的所述业务端;所述转换单元存储了多个业务标识与多个业务端之间的对应关系。The authentication request is distributed to the service end corresponding to the target service identifier; the conversion unit stores the correspondence between multiple service identifiers and multiple service ends.
其中,所述目标业务标识包括MQTT用户Client身份证明ID前缀标识或用户名前缀标识。The target service identifier includes an MQTT user Client identity ID prefix identifier or a user name prefix identifier.
结合第二方面,在又一种可能的实现方式中,在所述发送单元向MQTT集群中的第一MQTT服务器发送所述第一控制消息之后:In combination with the second aspect, in yet another possible implementation manner, after the sending unit sends the first control message to the first MQTT server in the MQTT cluster:
所述接受单元还用于接收所述第一MQTT服务器发送的第一消息;The receiving unit is also used to receive a first message sent by the first MQTT server;
所述发送单元还用于向所述业务端发送第一消息,其中,所述第一消息包括所述第一MQTT服务器维护的第一设备执行所述第一功能的结果。The sending unit is further used to send a first message to the service end, wherein the first message includes a result of the first device maintained by the first MQTT server executing the first function.
可选的,所述第一MQTT服务器维护的第一设备执行所述第一功能的结果为经加密处理的消息,所述转换单元用于对所述经加密处理的结果进行解密,所述发送单元向所述业务端发送的结果为经解密处理的消息。Optionally, the result of the first device maintained by the first MQTT server executing the first function is an encrypted message, the conversion unit is used to decrypt the encrypted result, and the result sent by the sending unit to the business end is a decrypted message.
结合第二方面,在又一种可能的实现方式中,所述发送单元与数据库基于相关的信息传输协议(比如HTTP协议、RPC协议)建立连接,其中,所述数据库用于对所述装置接收或发送的消息进行持久化存储。In combination with the second aspect, in another possible implementation, the sending unit establishes a connection with a database based on a relevant information transmission protocol (such as HTTP protocol, RPC protocol), wherein the database is used to persistently store messages received or sent by the device.
结合第二方面,在又一种可能的实现方式中,所述发送单元与数据流处理平台基于相关的信息传输协议(比如HTTP协议、RPC协议)建立连接,所述数据流处理平台用于对所述装置接收或发送的消息进行流式处理和大数据分析。In combination with the second aspect, in another possible implementation method, the sending unit establishes a connection with the data stream processing platform based on relevant information transmission protocols (such as HTTP protocol, RPC protocol), and the data stream processing platform is used to perform streaming processing and big data analysis on messages received or sent by the device.
第三方面,本申请实施例提供了一种桥接服务器,该桥接服务器包括处理器、存储器和通信接口,其中,所述通信接口用于在所述处理器的控制下执行接收和/或发送操作,所述存储器用于存储计算机程序,所述处理器用于调用所述存储器中的计算机程序,用于实现第一方面或第一方面任一种可能的实施方式所描述的方法。In a third aspect, an embodiment of the present application provides a bridging server, which includes a processor, a memory, and a communication interface, wherein the communication interface is used to perform receiving and/or sending operations under the control of the processor, the memory is used to store a computer program, and the processor is used to call the computer program in the memory to implement the method described in the first aspect or any possible implementation method of the first aspect.
第四方面,本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在处理器上运行时,用于实现第一方面或第一方面任一种可能的实施方式所描述的方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, which, when executed on a processor, is used to implement the method described in the first aspect or any possible implementation manner of the first aspect.
本申请第二至第四方面所提供的技术方法,其有益效果可以参考第一方面技术方案的有益效果,此处不再赘述。The beneficial effects of the technical methods provided in the second to fourth aspects of the present application can refer to the beneficial effects of the technical solution in the first aspect, and will not be repeated here.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
下面将对本申请实施例描述中所需要使用的附图作简单的介绍。The following is a brief introduction to the drawings required for describing the embodiments of the present application.
图1是本申请实施例提供的一种用于物联网的信息处理系统的架构示意图;FIG1 is a schematic diagram of the architecture of an information processing system for the Internet of Things provided by an embodiment of the present application;
图2是本申请实施例提供的一种用于物联网的信息处理方法的流程示意图;FIG2 is a flow chart of an information processing method for the Internet of Things provided in an embodiment of the present application;
图3是本申请实施例提供的又一种用于物联网的信息处理方法的流程示意图;FIG3 is a flow chart of another information processing method for the Internet of Things provided in an embodiment of the present application;
图4是本申请实施例提供的一种用于物联网的信息处理装置40的结构示意图;FIG4 is a schematic diagram of the structure of an information processing device 40 for the Internet of Things provided by an embodiment of the present application;
图5是本申请实施例提供的一种桥接服务器50的结构示意图。FIG. 5 is a schematic diagram of the structure of a bridge server 50 provided in an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
下面结合附图对本申请实施例进行详细介绍。The embodiments of the present application are described in detail below with reference to the accompanying drawings.
请参见图1,图1是本申请实施例提供的一种用于物联网的信息处理系统的架构示意图,该系统包括终端101、业务端103、桥接服务器104、消息队列遥感传输(messagequeuing telemetry transport,MQTT)集群107(包含MQTT服务器108-110)及设备111-116。其中,本申请对终端101、业务端103、MQTT服务器及设备等的数量不做严格限定,图1所示的数量仅为示例。Please refer to Figure 1, which is a schematic diagram of the architecture of an information processing system for the Internet of Things provided by an embodiment of the present application, the system includes a terminal 101, a service terminal 103, a bridge server 104, a message queuing telemetry transport (MQTT) cluster 107 (including MQTT servers 108-110) and devices 111-116. Among them, the present application does not strictly limit the number of terminals 101, service terminals 103, MQTT servers and devices, and the number shown in Figure 1 is only an example.
终端101可为手机,电脑及智能手表等,其中终端101内置控制软件102。该控制软件102是由程序代码组成的软件模块,比如应用程序(application,APP),通过应用程序编程接口(application programming interface,API)与业务端103进行信息交互。The terminal 101 can be a mobile phone, a computer, a smart watch, etc., wherein the terminal 101 has a built-in control software 102. The control software 102 is a software module composed of program codes, such as an application (APP), which interacts with the service terminal 103 through an application programming interface (API).
业务端103可为设备111-116(如智能锁、智能灯、智能温度计等智能设备)的业务系统,可基于相关协议,如超文本传输协议(hyper text transfer protocol,HTTP)、远程过程调用(remote procedure call,RPC)协议、双向实时通讯(WebSocket)协议等信息传输协议,与桥接服务器104进行信息交互。The business end 103 can be the business system of devices 111-116 (such as smart locks, smart lights, smart thermometers and other smart devices), and can interact with the bridge server 104 based on relevant protocols, such as hypertext transfer protocol (HTTP), remote procedure call (RPC) protocol, two-way real-time communication (WebSocket) protocol and other information transmission protocols.
桥接服务器104至少有两种部署情况:There are at least two deployment scenarios for the bridge server 104:
情况一:桥接服务器104包括钩子(Hook)模块105和桥接(Bridge)模块106,Hook模块和Bridge模块可以是由程序代码组成的软件模块;Case 1: The bridge server 104 includes a hook module 105 and a bridge module 106. The hook module and the bridge module may be software modules composed of program codes.
需要说明的是,Hook模块105是将MQTT集群107中MQTT服务器的认证模块独立出来,编写成钩子的形式,类似一个认证模块的集线器;Bridge模块106是业务端103与MQTT集群107信息交互的中介,是消息输入输出的核心模块。It should be noted that the Hook module 105 is to separate the authentication module of the MQTT server in the MQTT cluster 107 and write it in the form of a hook, which is similar to a hub of an authentication module; the Bridge module 106 is the intermediary for information interaction between the business end 103 and the MQTT cluster 107, and is the core module of message input and output.
在情况一中,桥接服务器104通过Hook模块105接收MQTT服务器(后续以MQTT服务器108为例进行说明)发送的认证请求,再根据认证请求中的目标业务标识将认证请求分配至业务端103,便于设备(后续以设备111为例进行说明)登录业务端103。In situation one, the bridge server 104 receives an authentication request sent by the MQTT server (hereinafter referred to as MQTT server 108 as an example) through the Hook module 105, and then distributes the authentication request to the business end 103 according to the target business identifier in the authentication request, so as to facilitate the device (hereinafter referred to as device 111 as an example) to log in to the business end 103.
桥接服务器104接收业务端103发送的控制指令,通过Bridge模块106对该控制指令进行转换,得到基于MQTT的第一控制消息,将第一控制消息发送到MQTT服务器108。其中,该控制指令用于请求执行第一功能,第一控制消息用于指示对MQTT服务器108维护的设备111执行第一功能。The bridge server 104 receives the control instruction sent by the service end 103, converts the control instruction through the Bridge module 106, obtains a first control message based on MQTT, and sends the first control message to the MQTT server 108. The control instruction is used to request the execution of the first function, and the first control message is used to instruct the device 111 maintained by the MQTT server 108 to execute the first function.
情况二:桥接服务器104包括Bridge模块106,Hook模块105可以配置在独立于桥接服务器104的硬件上,通过配置在该Hook模块105上的通信接口与业务端103及MQTT集群107进行信息交互。Case 2: The bridge server 104 includes a Bridge module 106 , and the Hook module 105 can be configured on hardware independent of the bridge server 104 , and information is exchanged with the service end 103 and the MQTT cluster 107 through a communication interface configured on the Hook module 105 .
在情况二中,桥接服务器104不再承担识别和分配认证请求的功能,主要借助Bridge模块106实现情况一中的其他功能,比如转换控制指令和发送第一控制消息等功能。In the second case, the bridge server 104 no longer assumes the function of identifying and allocating authentication requests, and mainly implements other functions in the first case, such as converting control instructions and sending the first control message, with the help of the Bridge module 106.
MQTT集群107包括至少两个不同厂商的MQTT服务器,可选的,该集群中的MQTT服务器可通过桥接服务器104中的Bridge模块106建立该MQTT集群107。可选的,该集群中的MQTT服务器可以为单机MQTT服务器,即仅支持连接一个设备且不支持与其他MQTT服务器直接建立连接构建集群。The MQTT cluster 107 includes at least two MQTT servers from different manufacturers. Optionally, the MQTT servers in the cluster can establish the MQTT cluster 107 through the Bridge module 106 in the bridge server 104. Optionally, the MQTT server in the cluster can be a stand-alone MQTT server, that is, it only supports connecting one device and does not support directly establishing a connection with other MQTT servers to build a cluster.
若业务端103发送的控制指令请求控制的设备111所属的MQTT服务器108为自研MQTT服务器,如开源MQTT服务器或云MQTT服务器,则桥接服务器104与该非自研MQTT服务器可基于MQTT协议建立连接;若业务端103发送的控制指令请求控制的设备111所属的MQTT服务器108为自研MQTT服务器,则桥接服务器104与自研MQTT服务器可基于RPC协议建立连接。If the MQTT server 108 to which the device 111 controlled by the control instruction sent by the business end 103 belongs is a self-developed MQTT server, such as an open source MQTT server or a cloud MQTT server, the bridge server 104 and the non-self-developed MQTT server can establish a connection based on the MQTT protocol; if the MQTT server 108 to which the device 111 controlled by the control instruction sent by the business end 103 belongs is a self-developed MQTT server, the bridge server 104 and the self-developed MQTT server can establish a connection based on the RPC protocol.
MQTT集群107中的任一MQTT服务器基于MQTT协议以主题订阅/发布的方式,与其所维护的设备进行信息交互。业务端103通过桥接服务器向MQTT服务器108所维护的设备111发送控制消息,设备111执行控制消息所请求执行的功能后,通过维护该设备的MQTT服务器108向业务端103反馈其执行结果。Any MQTT server in the MQTT cluster 107 interacts with the devices it maintains in a topic subscription/publishing manner based on the MQTT protocol. The service end 103 sends a control message to the device 111 maintained by the MQTT server 108 through the bridge server. After the device 111 executes the function requested by the control message, it feeds back the execution result to the service end 103 through the MQTT server 108 that maintains the device.
通过图1所示的系统架构,用户可以通过该系统控制不同厂商的智能设备并获得其执行控制指令的结果。Through the system architecture shown in FIG1 , users can control smart devices of different manufacturers through the system and obtain the results of executing control instructions.
请参见图2,图2是本申请实施例提供的一种用于物联网的信息处理方法的流程示意图,该方法可以基于图1所示的系统的架构来实现,该方法包括但不限于如下步骤:Please refer to FIG. 2 , which is a flow chart of an information processing method for the Internet of Things provided by an embodiment of the present application. The method can be implemented based on the architecture of the system shown in FIG. 1 , and the method includes but is not limited to the following steps:
步骤S201:桥接服务器接收业务端发送的控制指令。Step S201: The bridge server receives a control instruction sent by the service end.
用户通过终端(比如手机)的控制软件APP登录业务端,点击APP界面显示的智能设备(后续以第一设备为例进行说明)的图标,此时业务端收到APP发送的控制命令,该控制命令用于请求执行第一功能。具体的,该控制命令的消息字段包括第一设备的独有电子序列号“esn”和请求执行的功能类型“action”,比如,若请求执行功能“开”,则“action”可具体为“open”。The user logs in to the service end through the control software APP of the terminal (such as a mobile phone), and clicks the icon of the smart device (hereinafter, the first device is used as an example) displayed on the APP interface. At this time, the service end receives the control command sent by the APP, and the control command is used to request the execution of the first function. Specifically, the message field of the control command includes the unique electronic serial number "esn" of the first device and the function type "action" requested to be executed. For example, if the request is to execute the function "open", then "action" can be specifically "open".
业务端接收该控制命令后关联出控制指令,并向桥接服务器发送该控制指令。该控制指令的消息字段除第一设备的电子序列号“esn”和请求执行的功能类型“action”外,还包括控制指令标识“msgId”及响应时间“reqTime”等字段。需要说明的是,该控制指令的格式取决于该业务端与该桥接服务器建立连接所基于的信息传输协议,比如HTTP,RPC,WebSocket等信息传输协议。After receiving the control command, the service end associates the control instruction and sends the control instruction to the bridge server. In addition to the electronic serial number "esn" of the first device and the function type "action" requested to be executed, the message field of the control instruction also includes fields such as the control instruction identifier "msgId" and the response time "reqTime". It should be noted that the format of the control instruction depends on the information transmission protocol based on which the service end establishes a connection with the bridge server, such as HTTP, RPC, WebSocket and other information transmission protocols.
步骤S202:桥接服务器对控制指令进行转换,得到基于MQTT的第一控制消息。Step S202: The bridge server converts the control instruction to obtain a first control message based on MQTT.
桥接服务器可基于相关协议,如HTTP协议、RPC协议、MQTT协议等信息传输协议,与不同厂商的MQTT服务器进行信息交互,从而适配不同厂商的MQTT服务器。当桥接服务器分别与业务端和维护目标设备的MQTT服务器基于不同信息传输协议连接时,业务端发送的控制指令需经过桥接服务器转换成基于MQTT的控制消息后才能被发送至该MQTT服务器。具体的,第一控制消息的格式取决于该桥接服务器与维护第一设备的第一MQTT服务器建立连接所基于的信息传输协议。The bridge server can exchange information with MQTT servers of different manufacturers based on relevant protocols, such as HTTP protocol, RPC protocol, MQTT protocol and other information transmission protocols, so as to adapt to MQTT servers of different manufacturers. When the bridge server is connected to the business end and the MQTT server that maintains the target device based on different information transmission protocols, the control instructions sent by the business end must be converted into MQTT-based control messages by the bridge server before being sent to the MQTT server. Specifically, the format of the first control message depends on the information transmission protocol based on which the bridge server establishes a connection with the first MQTT server that maintains the first device.
需要说明的是,第一控制消息仍然包含控制指令中的消息字段,如第一设备的“esn”、“action”、“msgId”及“reqTime”等。It should be noted that the first control message still includes the message fields in the control instruction, such as "esn", "action", "msgId" and "reqTime" of the first device.
可选的,若该控制指令请求控制的设备所属的MQTT服务器为非自研MQTT服务器,则该桥接服务器与第一MQTT服务器基于MQTT协议建立连接,第一控制消息属于主题发布消息;其中,非自研MQTT服务器包括开源MQTT服务器或云MQTT服务器。Optionally, if the MQTT server to which the device requested to be controlled by the control instruction belongs is a non-self-developed MQTT server, the bridge server establishes a connection with the first MQTT server based on the MQTT protocol, and the first control message belongs to a topic publishing message; wherein, the non-self-developed MQTT server includes an open source MQTT server or a cloud MQTT server.
若所述控制指令请求控制的设备所属的MQTT服务器为自研MQTT服务器,则该桥接服务器与第一MQTT服务器基于RPC协议建立连接,所述第一控制消息属于RPC消息。If the MQTT server to which the device controlled by the control instruction request belongs is a self-developed MQTT server, the bridge server establishes a connection with the first MQTT server based on the RPC protocol, and the first control message is an RPC message.
相较于MQTT协议,RPC协议中接受者不用提前向MQTT服务器订阅相关主题消息,可以直接通过MQTT服务器接收发布者发布的RPC消息,从而保证RPC消息实时传递。Compared with the MQTT protocol, the recipient in the RPC protocol does not need to subscribe to relevant topic messages from the MQTT server in advance. It can directly receive the RPC messages published by the publisher through the MQTT server, thereby ensuring the real-time delivery of RPC messages.
又一可选的,该桥接服务器包括桥接Bridge模块;该桥接服务器对所述控制指令进行转换,包括:Alternatively, the bridge server includes a bridge module; the bridge server converts the control instruction, including:
该桥接服务器通过该桥接Bridge模块对该控制指令进行转换。The bridge server converts the control instruction through the bridge module.
具体的,该Bridge模块可存储多个信息传输协议格式之间的对应关系,作为业务端和第一MQTT服务器交互的中介,对来自该业务端的控制指令进行转换。Specifically, the Bridge module can store the correspondence between multiple information transmission protocol formats, serve as an intermediary for the interaction between the business end and the first MQTT server, and convert the control instructions from the business end.
步骤S203:桥接服务器向MQTT集群中的第一MQTT服务器发送第一控制消息。Step S203: The bridge server sends a first control message to the first MQTT server in the MQTT cluster.
该桥接服务器根据业务端发送的控制指令中第一设备的“esn”消息字段关联到维护第一设备的第一MQTT服务器的地址“destination”消息字段,从而准确地向第一MQTT服务器发送第一控制消息。The bridge server associates the "esn" message field of the first device in the control instruction sent by the service end with the address "destination" message field of the first MQTT server maintaining the first device, thereby accurately sending the first control message to the first MQTT server.
可选的,该MQTT集群中的各个MQTT服务器通过所述桥接服务器提供的桥接Bridge模块建立所述MQTT集群。Optionally, each MQTT server in the MQTT cluster establishes the MQTT cluster through a bridge module provided by the bridge server.
具体的,该Bridge模块可存储MQTT集群中多个MQTT服务器的“destination”和它们所维护的设备“esn”的对应关系。Specifically, the Bridge module can store the correspondence between the "destination" of multiple MQTT servers in the MQTT cluster and the devices "esn" they maintain.
相应的,第一MQTT服务器接收桥接服务器发送的第一控制消息后,根据第一控制消息中第一设备的“esn”准确地向第一设备发送第一控制消息,用于指示对第一设备执行第一功能。Correspondingly, after receiving the first control message sent by the bridge server, the first MQTT server accurately sends the first control message to the first device according to the "esn" of the first device in the first control message, so as to instruct to execute the first function on the first device.
MQTT集群中的任一MQTT服务器基于MQTT协议以主题订阅/发布的方式与其所维护的设备进行信息交互。具体的,MQTT集群中第一MQTT服务器维护的第一设备向MQTT服务器发送主题订阅消息,该主题订阅消息中包含主题“topic”消息字段,该“topic”消息字段对应于业务端发送的控制指令中所包含的第一设备“esn”和请求执行的功能类型“action”消息字段。因此,第一设备能接收到第一MQTT服务器发送的对应于该主题订阅消息的主题发布消息。Any MQTT server in the MQTT cluster interacts with the devices it maintains in a topic subscription/publishing manner based on the MQTT protocol. Specifically, the first device maintained by the first MQTT server in the MQTT cluster sends a topic subscription message to the MQTT server. The topic subscription message contains a topic "topic" message field, and the "topic" message field corresponds to the first device "esn" and the function type "action" message field requested to be executed contained in the control instruction sent by the business end. Therefore, the first device can receive the topic publishing message corresponding to the topic subscription message sent by the first MQTT server.
可选的,若该桥接服务器与第一MQTT服务器连接所基于的信息传输协议为MQTT协议,第一MQTT服务器向第一设备发送第一控制消息,第一控制消息为主题发布消息,用于指示第一设备执行第一功能;若该桥接服务器与第一MQTT服务器连接所基于的信息传输协议是除MQTT协议的其他协议,第一MQTT服务器则将第一控制消息转换为第三控制消息,第一MQTT服务器向第一设备发送第三控制消息,第三控制消息为主题发布消息,用于指示第一设备执行第一功能。Optionally, if the information transmission protocol based on which the bridge server and the first MQTT server are connected is the MQTT protocol, the first MQTT server sends a first control message to the first device, and the first control message is a topic publishing message, used to instruct the first device to perform a first function; if the information transmission protocol based on which the bridge server and the first MQTT server are connected is a protocol other than the MQTT protocol, the first MQTT server converts the first control message into a third control message, and the first MQTT server sends a third control message to the first device, and the third control message is a topic publishing message, used to instruct the first device to perform the first function.
可选的,第一设备需向第一MQTT服务器发送认证请求,便于业务端对其进行身份和/或业务权限认证,否则该设备不能向第一MQTT服务器订阅主题消息,进而收不到该MQTT服务器发送的第一控制消息。因此,该桥接服务器接收业务端发送控制指令之前,还包括:Optionally, the first device needs to send an authentication request to the first MQTT server to facilitate the business end to authenticate its identity and/or business authority, otherwise the device cannot subscribe to the topic message from the first MQTT server, and thus cannot receive the first control message sent by the MQTT server. Therefore, before the bridge server receives the control instruction sent by the business end, it also includes:
该桥接服务器接收该第一MQTT服务器发送的认证请求,其中,所述认证请求用于请求认证第一MQTT服务器维护的第一设备的身份和/或业务权限;The bridge server receives an authentication request sent by the first MQTT server, wherein the authentication request is used to request authentication of an identity and/or service authority of a first device maintained by the first MQTT server;
该桥接服务器将该认证请求分配至业务端,以供该业务端认证第一MQTT服务器维护的第一设备。The bridge server distributes the authentication request to the service end so that the service end authenticates the first device maintained by the first MQTT server.
可选的,该认证请求包括目标业务标识,该桥接服务器将所述认证请求分配至业务端,包括:Optionally, the authentication request includes a target service identifier, and the bridge server distributes the authentication request to the service end, including:
该桥接服务器将该认证请求分配至所述目标业务标识对应的所述业务端,其中,所述桥接服务器存储了多个业务标识与多个业务端之间的对应关系。具体的,所述目标业务标识包括MQTT用户Client身份证明ID前缀标识或用户名前缀标识。The bridge server distributes the authentication request to the service end corresponding to the target service identifier, wherein the bridge server stores the correspondence between multiple service identifiers and multiple service ends. Specifically, the target service identifier includes an MQTT user Client identity ID prefix identifier or a user name prefix identifier.
本申请实施例中,第一设备向第一MQTT服务器发送认证请求,该认证请求包含MQTT用户Client身份证明ID“Client ID”消息字段,其前缀标识为“wf:”,第一MQTT服务器向该桥接服务器转发该认证请求。该桥接服务器根据该前缀标识“wf:”关联到业务端的地址“destination”,并将该认证消息发送至该业务端。In an embodiment of the present application, the first device sends an authentication request to the first MQTT server, the authentication request includes the MQTT user Client identity ID "Client ID" message field, whose prefix identifier is "wf:", and the first MQTT server forwards the authentication request to the bridge server. The bridge server associates the prefix identifier "wf:" with the address "destination" of the service end and sends the authentication message to the service end.
需要说明的是,针对向同一个业务端发送认证请求的多个设备,它们的“ClientID”前缀标识是相同的。针对向不同业务端发送认证请求的多个设备,它们的“Client ID”前缀标识可以包括“wf:”“wh:”“wg:”“wk:”等消息字段。It should be noted that for multiple devices sending authentication requests to the same service end, their "ClientID" prefix identifiers are the same. For multiple devices sending authentication requests to different service ends, their "Client ID" prefix identifiers may include message fields such as "wf:", "wh:", "wg:", "wk:", etc.
进一步的,业务端认证第一设备后,通过桥接服务器向第一设备发送认证结果消息,该认证结果消息包括“ture”或“false”消息字段,分别代表“认证成功”或“认证失败”。第一设备只有接收到包含“true”的认证结果后才能向第一MQTT服务器发送主题订阅消息。Furthermore, after the service end authenticates the first device, it sends an authentication result message to the first device through the bridge server, and the authentication result message includes a "true" or "false" message field, which respectively represents "authentication success" or "authentication failure". The first device can only send a topic subscription message to the first MQTT server after receiving an authentication result containing "true".
可选的,该桥接服务器包括钩子Hook模块,该桥接服务器接收第一MQTT服务器发送的认证请求,包括:Optionally, the bridge server includes a hook module, and the bridge server receives the authentication request sent by the first MQTT server, including:
该桥接服务器通过钩子Hook模块接收第一MQTT服务器发送的认证请求。The bridge server receives the authentication request sent by the first MQTT server through the hook module.
具体的,Hook模块可以是将MQTT集群中的MQTT服务器的认证模块独立出来,编写成钩子的形式,类似一个认证模块的集线器。该Hook模块包括函数程序,作为模板,用于储存多个业务标识与多个业务端之间的对应关系。Specifically, the Hook module can be an independent authentication module of the MQTT server in the MQTT cluster, written in the form of a hook, similar to a hub of an authentication module. The Hook module includes a function program as a template for storing the corresponding relationship between multiple service identifiers and multiple service terminals.
进一步的,该桥接服务器将第一控制消息发送到MQTT集群中的第一MQTT服务器之后(步骤S203),还包括:Further, after the bridge server sends the first control message to the first MQTT server in the MQTT cluster (step S203), it also includes:
该桥接服务器接收第一MQTT服务器发送的第一消息;The bridge server receives a first message sent by a first MQTT server;
该桥接服务器向业务端发送第一消息,其中,第一消息包括第一MQTT服务器维护的第一设备执行所述第一功能的结果。The bridge server sends a first message to the service end, wherein the first message includes a result of a first device maintained by a first MQTT server executing the first function.
可选的,第一设备执行第一功能的结果为经加密处理的消息,所述桥接服务器用于对所述经加密处理的结果进行解密,所述桥接服务器向所述业务端发送的结果为经解密处理的消息。Optionally, the result of the first device executing the first function is an encrypted message, the bridge server is used to decrypt the encrypted result, and the result sent by the bridge server to the service end is the decrypted message.
需要说明的是,与业务端发送的控制指令一样,执行结果需在信息交互过程中被转换以适应不同的信息传输协议,此处不再赘述。It should be noted that, like the control instructions sent by the business end, the execution results need to be converted during the information interaction process to adapt to different information transmission protocols, which will not be repeated here.
本申请实施例中,桥接服务器可与数据库建立连接,该数据库用于对所述桥接服务器接收或发送的消息进行持久化存储。In the embodiment of the present application, the bridge server may establish a connection with a database, and the database is used to persistently store messages received or sent by the bridge server.
本申请实施例中,桥接服务器还可与数据流处理平台建立连接,该数据流处理平台用于对该桥接服务器接收或发送的消息进行流式处理和大数据分析,具体的,大数据分析用于统计第一MQTT服务器维护的设备的使用状态、业务端的使用习惯、桥接服务器接收或发送的消息属性及吞吐量中的任意一项或多项。In an embodiment of the present application, the bridge server can also establish a connection with a data stream processing platform, which is used to perform streaming processing and big data analysis on messages received or sent by the bridge server. Specifically, the big data analysis is used to count any one or more of the usage status of the device maintained by the first MQTT server, the usage habits of the business end, the message attributes and throughput received or sent by the bridge server.
结合本申请实施例,业务端发送的控制指令还可用于请求执行第二功能,本申请实施例还包括:In conjunction with the embodiment of the present application, the control instruction sent by the service end may also be used to request execution of the second function. The embodiment of the present application also includes:
该桥接服务器对该控制指令进行转换,得到基于MQTT的第二控制消息;The bridge server converts the control instruction to obtain a second control message based on MQTT;
该桥接服务器向MQTT集群中的第二MQTT服务器发送第二控制消息,其中,第二控制消息用于指示对第二MQTT服务器维护的第二设备执行第二功能,第一MQTT服务器和第二MQTT服务器为两个不同厂商的MQTT服务器。The bridge server sends a second control message to a second MQTT server in the MQTT cluster, wherein the second control message is used to instruct execution of a second function on a second device maintained by the second MQTT server, and the first MQTT server and the second MQTT server are MQTT servers from two different manufacturers.
具体的,业务端发送的控制指令可用于请求执行多个功能,桥接服务器将该控制指令分别转换为多个基于MQTT的控制消息,并分配至对应的MQTT服务器。Specifically, the control instruction sent by the business end can be used to request the execution of multiple functions. The bridge server converts the control instruction into multiple MQTT-based control messages and distributes them to the corresponding MQTT servers.
举例来说,用户借助智能手表中的控制软件APP登录智能设备业务系统(即业务端),该业务系统已对用户办公室的A厂商的智能锁a(即第一设备)和B厂商的智能温度计b(即第二设备)进行认证,且与桥接服务器基于RPC协议进行信息交互。该桥接服务器与维护智能锁a的第一MQTT服务器桥接服务器基于MQTT协议进行信息交互,与维护智能温度计b的第二MQTT服务器桥接服务器以RPC的方式进行信息交互。For example, a user logs in to the smart device business system (i.e., the business end) with the help of the control software APP in the smart watch. The business system has authenticated the smart lock a (i.e., the first device) of manufacturer A and the smart thermometer b (i.e., the second device) of manufacturer B in the user's office, and exchanges information with the bridge server based on the RPC protocol. The bridge server exchanges information with the first MQTT server bridge server that maintains the smart lock a based on the MQTT protocol, and exchanges information with the second MQTT server bridge server that maintains the smart thermometer b in the form of RPC.
用户利用业务系统的“联动”功能,选择智能锁a和智能温度计b的图标进行绑定,并点击“联动”功能图标,此时该业务系统接收到来自用户端的联动控制命令。业务系统根据该联动控制命令确定出联动控制指令,该联动控制指令包含消息字段:“w1”及“open”关联(linkage)“w2”及“temperature”,为便于区分,“w1”代表智能锁a的“esn”,“w2”代表智能温度计b的“esn”,“open”代表执行“开”功能,“temperature”代表“读取温度”。The user uses the "linkage" function of the business system to select the icons of smart lock a and smart thermometer b for binding, and clicks the "linkage" function icon. At this time, the business system receives the linkage control command from the user. The business system determines the linkage control instruction based on the linkage control command. The linkage control instruction contains the message fields: "w1" and "open" are associated (linkage) with "w2" and "temperature". For easy distinction, "w1" represents the "esn" of smart lock a, "w2" represents the "esn" of smart thermometer b, "open" represents the execution of the "open" function, and "temperature" represents "reading temperature".
该桥接服务器接收基于RPC协议的控制指令并将其转换为基于MQTT协议的第一控制消息和基于RPC协议的第二控制消息。第一控制消息包含消息字段:“w1”及“open”及“01”,第二控制消息包含消息字段:“w2”及“temperature”及“02”,为便于区分,“01”代表第一MQTT服务器的“destination”,“02”代表第二MQTT服务器的“destination”。The bridge server receives the control instruction based on the RPC protocol and converts it into a first control message based on the MQTT protocol and a second control message based on the RPC protocol. The first control message includes the message fields: "w1", "open", and "01", and the second control message includes the message fields: "w2", "temperature", and "02". For easy distinction, "01" represents the "destination" of the first MQTT server, and "02" represents the "destination" of the second MQTT server.
该桥接服务器将第一控制消息发送至第一MQTT服务器,将第二控制消息发送至第二MQTT服务器。第一MQTT服务器将基于MQTT协议的第一控制消息发送至智能锁a;第二MQTT服务器将基于RPC协议的第二控制消息转换为基于MQTT协议的第三控制消息发送至智能温度计b。智能锁a接收第一控制消息后执行“开”功能,并将开启状态传回业务系统;同理,智能温度计d接收第三控制消息后执行“读取温度”功能,并将温度数据传回业务系统。The bridge server sends the first control message to the first MQTT server and the second control message to the second MQTT server. The first MQTT server sends the first control message based on the MQTT protocol to the smart lock a; the second MQTT server converts the second control message based on the RPC protocol into a third control message based on the MQTT protocol and sends it to the smart thermometer b. After receiving the first control message, the smart lock a executes the "open" function and transmits the open state back to the business system; similarly, after receiving the third control message, the smart thermometer d executes the "read temperature" function and transmits the temperature data back to the business system.
通过上述步骤,用户可通过智能手表开启办公室A厂商的智能锁a的同时读取B厂商的智能温度计b的温度数据。Through the above steps, the user can use the smart watch to open the smart lock a of manufacturer A in the office and read the temperature data of the smart thermometer b of manufacturer B at the same time.
结合本申请实施例,桥接服务器还可对该控制指令进行转换,得到基于MQTT的第四控制消息;该桥接服务器向MQTT集群中的第三MQTT服务器发送第四控制消息。其中,第一MQTT服务器和第三MQTT服务器可为两个不同厂商的MQTT服务器,第四控制消息用于指示对第三MQTT服务器维护的第三设备执行所述第一功能。In combination with the embodiment of the present application, the bridge server can also convert the control instruction to obtain a fourth control message based on MQTT; the bridge server sends the fourth control message to the third MQTT server in the MQTT cluster. The first MQTT server and the third MQTT server can be MQTT servers of two different manufacturers, and the fourth control message is used to instruct the third device maintained by the third MQTT server to execute the first function.
具体的,业务端发送的控制指令可用于请求不同设备执行同一功能,该桥接服务器可将业务端发送的控制指令分别转换为对应不同MQTT服务器的控制消息。Specifically, the control instructions sent by the service end can be used to request different devices to execute the same function, and the bridge server can convert the control instructions sent by the service end into control messages corresponding to different MQTT servers.
举例来说,用户借助手机中的控制软件APP登录智能设备业务系统(即业务端),该业务系统已对用户家中A厂商的智能锁a(即第一设备)和D厂商的智能锁d(即第三设备)进行认证,且与桥接服务器基于HTTP协议进行信息交互。该桥接服务器与维护智能锁a的第一MQTT服务器桥接服务器基于MQTT协议进行信息交互,与维护智能锁d的第三MQTT服务器桥接服务器基于RPC协议进行信息交互。For example, a user logs in to the smart device business system (i.e., the business end) with the help of the control software APP in the mobile phone. The business system has authenticated the smart lock a (i.e., the first device) of manufacturer A and the smart lock d (i.e., the third device) of manufacturer D in the user's home, and exchanges information with the bridge server based on the HTTP protocol. The bridge server exchanges information with the first MQTT server bridge server that maintains smart lock a based on the MQTT protocol, and exchanges information with the third MQTT server bridge server that maintains smart lock d based on the RPC protocol.
用户利用业务系统的“联动”功能,选择智能锁a和智能锁d的图标进行绑定,并点击“联动”功能图标,此时该业务系统接收到来自用户APP的联动控制命令,业务系统根据该联动控制命令确定出联动控制指令,该联动控制指令包含消息字段:“w1”关联(linkage)“w3”及“open”,为便于区分,“w1”代表智能锁a的“esn”,“w3”代表智能锁d的“esn”,“open”代表执行“开”功能。桥接服务器接收基于HTTP协议的联动控制指令并将其转换为基于MQTT协议的第一控制消息和基于RPC协议的第四控制消息。第一控制消息包含消息字段:“w1”及“open”及“01”,第四控制消息包含消息字段:“w3”/“open”/“03”,为便于区分,“01”代表第一MQTT服务器的“destination”,“03”代表第三MQTT服务器的“destination”。The user uses the "linkage" function of the business system to select the icons of smart lock a and smart lock d for binding, and clicks the "linkage" function icon. At this time, the business system receives the linkage control command from the user APP. The business system determines the linkage control instruction based on the linkage control command. The linkage control instruction contains the message field: "w1" is associated (linkage) "w3" and "open". For easy distinction, "w1" represents the "esn" of smart lock a, "w3" represents the "esn" of smart lock d, and "open" represents the execution of the "open" function. The bridge server receives the linkage control instruction based on the HTTP protocol and converts it into a first control message based on the MQTT protocol and a fourth control message based on the RPC protocol. The first control message contains the message fields: "w1" and "open" and "01", and the fourth control message contains the message fields: "w3"/"open"/"03". For easy distinction, "01" represents the "destination" of the first MQTT server, and "03" represents the "destination" of the third MQTT server.
该桥接服务器将第一控制消息发送至第一MQTT服务器,将第四控制消息发送至第三MQTT服务器。第一MQTT服务器直接将基于MQTT的第一控制消息发送至智能锁a;第三MQTT服务器将基于RPC协议的第四控制消息转换为基于MQTT协议的第五控制消息发送至智能锁d。智能锁接收第一控制消息后执行“开”功能,并将开启状态传回业务系统;同理,智能锁d接收第五控制消息后执行“开”功能,并将开启状态传回业务系统。The bridge server sends the first control message to the first MQTT server and sends the fourth control message to the third MQTT server. The first MQTT server directly sends the first control message based on MQTT to smart lock a; the third MQTT server converts the fourth control message based on the RPC protocol into a fifth control message based on the MQTT protocol and sends it to smart lock d. After receiving the first control message, the smart lock executes the "open" function and transmits the opening status back to the business system; similarly, after receiving the fifth control message, smart lock d executes the "open" function and transmits the opening status back to the business system.
通过上述步骤,用户可通过手机同时开启家中A厂商的智能锁a和D厂商的智能锁d。Through the above steps, users can use their mobile phones to simultaneously open smart lock a from manufacturer A and smart lock d from manufacturer D in their home.
便于进一步理解图2,请参见图3,图3是本申请实施例提供的又一种用于物联网的信息处理方法的流程示意图。For further understanding of FIG. 2 , please refer to FIG. 3 , which is a flow chart of another information processing method for the Internet of Things provided in an embodiment of the present application.
步骤301:第一设备通过第一MQTT服务器向桥接服务器发送认证请求。Step 301: The first device sends an authentication request to the bridge server through the first MQTT server.
步骤302:桥接服务器分配认证请求至业务端。Step 302: The bridge server distributes the authentication request to the service end.
步骤303:业务端认证设备。Step 303: The business end authenticates the device.
步骤304:业务端发送认证结果至桥接服务器。Step 304: The service end sends the authentication result to the bridge server.
步骤305:桥接服务器分配认证结果至第一MQTT服务器。Step 305: The bridge server distributes the authentication result to the first MQTT server.
步骤306:第一MQTT服务器发送认证结果至第一设备。Step 306: The first MQTT server sends the authentication result to the first device.
步骤307:第一设备接收认证结果。Step 307: The first device receives the authentication result.
步骤308:若认证成功,则第一设备向第一MQTT服务器订阅与业务端对应的主题消息。这种情况下,执行后续步骤S310-S320。Step 308: If the authentication is successful, the first device subscribes to the topic message corresponding to the service end from the first MQTT server. In this case, the subsequent steps S310-S320 are executed.
步骤309:若认证失败,则第一设备不能向第一MQTT服务器订阅与业务端对应的主题消息。这种情况下,不执行后续步骤S310-S320。Step 309: If the authentication fails, the first device cannot subscribe to the topic message corresponding to the service end from the first MQTT server. In this case, the subsequent steps S310-S320 are not executed.
步骤S310:业务端接收终端发送的控制命令。Step S310: The service end receives a control command sent by the terminal.
步骤S311:业务端根据控制命令确定出控制指令。Step S311: The service end determines a control instruction according to the control command.
步骤S312:业务端发送控制指令至桥接服务器。Step S312: The service end sends a control instruction to the bridge server.
步骤S313:桥接服务器接收控制指令。Step S313: The bridge server receives the control instruction.
步骤S314:桥接服务器对控制指令进行转换,得到基于MQTT的第一控制消息。Step S314: the bridge server converts the control instruction to obtain a first control message based on MQTT.
步骤S315:桥接服务器通过第一MQTT服务器向第一设备发送第一控制消息。Step S315: The bridge server sends a first control message to the first device through the first MQTT server.
步骤S316:第一设备接收第一控制消息。Step S316: The first device receives the first control message.
步骤S317:第一设备执行第一功能。Step S317: The first device executes the first function.
步骤S318:第一设备通过第一MQTT服务器向桥接服务器发送执行结果。Step S318: The first device sends the execution result to the bridge server through the first MQTT server.
步骤S319:桥接服务器分配执行结果至业务端。Step S319: The bridge server distributes the execution result to the service end.
步骤S320:业务端将执行结果发送至终端。Step S320: The business end sends the execution result to the terminal.
通过本实施例,用户可通过终端发送控制命令从而控制第一设备执行第一功能,并获得第一设备的执行结果。Through this embodiment, the user can send a control command through the terminal to control the first device to execute the first function and obtain the execution result of the first device.
上述详细阐述了本申请实施例的方法,为了便于更好地实施本申请实施例的上述方案,相应地,下面提供了本申请实施例的装置。The method of the embodiment of the present application is described in detail above. In order to facilitate better implementation of the above scheme of the embodiment of the present application, the device of the embodiment of the present application is provided below accordingly.
可以理解的是,本申请实施例提供的装置,例如一种用于物联网的信息处理装置,为了实现上述方法实施例中的功能,其包含了执行各个功能相应的硬件结构、软件模块、或硬件结构和软件结构的组合等。It can be understood that the device provided in the embodiments of the present application, such as an information processing device for the Internet of Things, includes hardware structures, software modules, or a combination of hardware structures and software structures corresponding to executing each function in order to implement the functions in the above method embodiments.
本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及步骤,本申请实施例能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以在不同的使用场景中,使用不同的装置实现方式来实现前述的方法实施例,对于装置的不同实现方式不应认为超出本申请实施例的范围。Those skilled in the art should easily realize that, in combination with the units and steps of each example described in the embodiments disclosed herein, the embodiments of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different device implementations to implement the aforementioned method embodiments in different usage scenarios, and different implementations of the device should not be considered to exceed the scope of the embodiments of the present application.
本申请实施例可以对装置进行功能模块的划分。例如,可对应各个功能划分各个功能模块,也可将两个或两个以上的功能集成在一个功能模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如,以采用集成的方式划分装置各个功能模块的情况为例,本申请例举几种可能的处理装置。The embodiments of the present application may divide the device into functional modules. For example, each functional module may be divided according to each function, or two or more functions may be integrated into one functional module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiments of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation. For example, taking the case of dividing the functional modules of the device in an integrated manner as an example, the present application cites several possible processing devices.
请参见图4,图4是本申请实施例提供的一种用于物联网的信息处理装置的结构示意图,该信息处理装置40可以为图1所示的桥接服务器,或者该桥接服务器中的器件;该信息处理装置40可以包括接收单元401,转换单元402和发送单元403,其中,各个单元的详细描述如下:Please refer to FIG. 4 , which is a schematic diagram of the structure of an information processing device for the Internet of Things provided by an embodiment of the present application. The information processing device 40 may be the bridge server shown in FIG. 1 , or a device in the bridge server; the information processing device 40 may include a receiving unit 401, a conversion unit 402 and a sending unit 403, wherein each unit is described in detail as follows:
接收单元401用于接收业务端发送的控制指令,其中,所述控制指令用于请求执行第一功能;The receiving unit 401 is used to receive a control instruction sent by the service end, wherein the control instruction is used to request to execute the first function;
转换单元402用于对所述控制指令进行转换,得到基于消息队列遥感传输MQTT的第一控制消息;The conversion unit 402 is used to convert the control instruction to obtain a first control message based on message queue remote sensing transmission MQTT;
发送单元403用于将所述第一控制消息发送到MQTT集群中的第一MQTT服务器,其中,所述MQTT集群包括至少两个不同厂商的MQTT服务器,所述第一控制消息用于指示对所述第一MQTT服务器维护的第一设备执行所述第一功能。The sending unit 403 is used to send the first control message to a first MQTT server in an MQTT cluster, wherein the MQTT cluster includes at least two MQTT servers from different manufacturers, and the first control message is used to instruct a first device maintained by the first MQTT server to execute the first function.
在一种可能的实现方式中,所述控制指令还用于请求执行第二功能:In a possible implementation, the control instruction is further used to request execution of a second function:
所述转换单元402还用于对所述控制指令进行转换,得到基于MQTT的第二控制消息;The conversion unit 402 is further used to convert the control instruction to obtain a second control message based on MQTT;
所述发送单元403还用于向MQTT集群中的第二MQTT服务器发送所述第二控制消息,其中,所述第二控制消息用于指示对所述第二MQTT服务器维护的第二设备执行所述第二功能,所述第一MQTT服务器和所述第二MQTT服务器为两个不同厂商的MQTT服务器。The sending unit 403 is also used to send the second control message to the second MQTT server in the MQTT cluster, wherein the second control message is used to instruct the execution of the second function on the second device maintained by the second MQTT server, and the first MQTT server and the second MQTT server are MQTT servers from two different manufacturers.
在另一种可能的实现方式中,若所述控制指令请求控制的设备所属的MQTT服务器为非自研MQTT服务器,则所述装置40与所述第一MQTT服务器基于MQTT协议建立连接,所述第一控制消息属于主题发布消息;In another possible implementation, if the MQTT server to which the device controlled by the control instruction request belongs is a non-self-developed MQTT server, the device 40 establishes a connection with the first MQTT server based on the MQTT protocol, and the first control message belongs to a topic publishing message;
若所述控制指令请求控制的设备所属的MQTT服务器为自研MQTT服务器,则所述装置40与所述第一MQTT服务器基于远程过程调用RPC协议建立连接,所述第一控制消息属于RPC消息。If the MQTT server to which the device controlled by the control instruction requests belongs is a self-developed MQTT server, the device 40 establishes a connection with the first MQTT server based on the remote procedure call RPC protocol, and the first control message is an RPC message.
在又一种可能的实现方式中,所述转换单元402包括桥接Bridge模块;在对所述控制指令进行转换方面,所述转换单元402具体用于:In another possible implementation, the conversion unit 402 includes a bridge module; in terms of converting the control instruction, the conversion unit 402 is specifically used to:
通过所述桥接Bridge模块对所述控制指令进行转换。The control instruction is converted by the bridge module.
在又一种可能的实现方式中,所述MQTT集群中的各个MQTT服务器通过所述转换单元402提供的桥接Bridge模块建立所述MQTT集群。In yet another possible implementation, each MQTT server in the MQTT cluster establishes the MQTT cluster through a bridge module provided by the conversion unit 402 .
在又一种可能的实现方式中,在所述接收单元401接收业务端发送的控制指令之前,In another possible implementation, before the receiving unit 401 receives the control instruction sent by the service end,
所述接收单元401还用于接收所述第一MQTT服务器发送的认证请求,其中,所述认证请求用于请求认证所述第一MQTT服务器维护的第一设备的身份和/或业务权限;The receiving unit 401 is further configured to receive an authentication request sent by the first MQTT server, wherein the authentication request is used to request authentication of the identity and/or service authority of the first device maintained by the first MQTT server;
所述发送单元403还用于将所述认证请求分配至所述业务端,以供所述业务端认证所述第一MQTT服务器维护的第一设备。The sending unit 403 is further configured to distribute the authentication request to the service end, so that the service end can authenticate the first device maintained by the first MQTT server.
可选的,所述接收单元401包括钩子Hook模块,在接收所述第一MQTT服务器发送的认证请求方面,所述接收单元401具体用于:Optionally, the receiving unit 401 includes a hook module. In terms of receiving the authentication request sent by the first MQTT server, the receiving unit 401 is specifically used to:
通过所述钩子Hook模块接收所述第一MQTT服务器发送的认证请求。The authentication request sent by the first MQTT server is received through the hook module.
可选的,所述认证请求包括目标业务标识,在将所述认证请求分配至所述业务端方面,所述发送单元403具体用于:Optionally, the authentication request includes a target service identifier. In terms of allocating the authentication request to the service end, the sending unit 403 is specifically configured to:
将所述认证请求分配至所述目标业务标识对应的所述业务端;所述转换单元402存储了多个业务标识与多个业务端之间的对应关系。The authentication request is distributed to the service end corresponding to the target service identifier; the conversion unit 402 stores the correspondence between multiple service identifiers and multiple service ends.
其中,所述目标业务标识包括MQTT用户Client身份证明ID前缀标识或用户名前缀标识。The target service identifier includes an MQTT user Client identity ID prefix identifier or a user name prefix identifier.
在又一种可能的实现方式中,在所述发送单元403向MQTT集群中的第一MQTT服务器发送所述第一控制消息之后:In yet another possible implementation, after the sending unit 403 sends the first control message to the first MQTT server in the MQTT cluster:
所述接收单元401还用于接收所述第一MQTT服务器发送的第一消息;The receiving unit 401 is further configured to receive a first message sent by the first MQTT server;
所述发送单元403还用于向所述业务端发送第一消息,其中,所述第一消息包括所述第一MQTT服务器维护的第一设备执行所述第一功能的结果。The sending unit 403 is further configured to send a first message to the service end, wherein the first message includes a result of the first device maintained by the first MQTT server executing the first function.
可选的,所述第一MQTT服务器维护的第一设备执行所述第一功能的结果为经加密处理的消息,所述转换单元402用于对所述经加密处理的结果进行解密,所述发送单元403向所述业务端发送的结果为经解密处理的消息。Optionally, the result of the first device maintained by the first MQTT server executing the first function is an encrypted message, the conversion unit 402 is used to decrypt the encrypted result, and the result sent by the sending unit 403 to the business end is a decrypted message.
在又一种可能的实现方式中,所述发送单元403与数据库基于相关的信息传输协议(比如HTTP协议、RPC协议)建立连接,其中,所述数据库用于对所述装置40接收或发送的消息进行持久化存储。In another possible implementation, the sending unit 403 establishes a connection with a database based on a relevant information transmission protocol (such as HTTP protocol, RPC protocol), wherein the database is used to persistently store messages received or sent by the device 40.
在又一种可能的实现方式中,所述发送单元403与数据流处理平台基于相关的信息传输协议(比如HTTP协议、RPC协议)建立连接,所述数据流处理平台用于对所述装置40接收或发送的消息进行流式处理和大数据分析。In another possible implementation, the sending unit 403 establishes a connection with a data stream processing platform based on relevant information transmission protocols (such as HTTP protocol, RPC protocol), and the data stream processing platform is used to perform streaming processing and big data analysis on messages received or sent by the device 40.
需要说明的是,在本申请实施例中,各个单元的具体实现及技术效果还可以对应参照图2或图3所示的方法实施例的相应描述。It should be noted that, in the embodiments of the present application, the specific implementation and technical effects of each unit may also correspond to the corresponding description of the method embodiment shown in FIG. 2 or FIG. 3 .
请参见图5,图5是本申请实施例提供的一种桥接服务器50,该桥接服务器50包括处理器501、存储器502和通信接口503,所述处理器501、存储器502和通信接口503通过总线相互连接。Please refer to FIG. 5 , which is a bridging server 50 provided in an embodiment of the present application. The bridging server 50 includes a processor 501 , a memory 502 , and a communication interface 503 . The processor 501 , the memory 502 , and the communication interface 503 are interconnected via a bus.
处理器501可以是一个或多个中央处理器(central processing unit,CPU),在处理器501是一个CPU的情况下,该CPU可以是单核CPU,也可以是多核CPU。The processor 501 may be one or more central processing units (CPUs). When the processor 501 is a CPU, the CPU may be a single-core CPU or a multi-core CPU.
存储器502包括但不限于是随机存储记忆体(random access memory,RAM)、只读存储器(read-only memory,ROM)、可擦除可编程只读存储器(erasable programmableread only memory,EPROM)、或便携式只读存储器(compact disc read-only memory,CD-ROM),该存储器502用于相关计算机程序及数据。The memory 502 includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or portable read-only memory (CD-ROM), and the memory 502 is used for related computer programs and data.
通信接口503用于接收和发送数据。The communication interface 503 is used to receive and send data.
处理器501用于读取所述存储器502中存储的计算机程序代码,执行以下操作:The processor 501 is used to read the computer program code stored in the memory 502 and perform the following operations:
通过所述通信接口503接收业务端发送的控制指令,其中,所述控制指令用于请求执行第一功能;Receiving a control instruction sent by a service end through the communication interface 503, wherein the control instruction is used to request execution of a first function;
对所述控制指令进行转换,得到基于消息队列遥感传输MQTT的第一控制消息;Convert the control instruction to obtain a first control message based on message queue remote sensing transmission MQTT;
通过所述通信接口503向MQTT集群中的第一MQTT服务器发送所述第一控制消息,其中,所述MQTT集群包括至少两个不同厂商的MQTT服务器,所述第一控制消息用于指示对所述第一MQTT服务器维护的第一设备执行所述第一功能。The first control message is sent to a first MQTT server in the MQTT cluster through the communication interface 503, wherein the MQTT cluster includes at least two MQTT servers from different manufacturers, and the first control message is used to instruct a first device maintained by the first MQTT server to execute the first function.
在一种可能的实现方式中,所述控制指令还用于请求执行第二功能,所述处理器501还用于:In a possible implementation manner, the control instruction is further used to request execution of a second function, and the processor 501 is further used to:
对所述控制指令进行转换,得到基于MQTT的第二控制消息;Convert the control instruction to obtain a second control message based on MQTT;
通过所述通信接口503向MQTT集群中的第二MQTT服务器发送所述第二控制消息,其中,所述第二控制消息用于指示对所述第二MQTT服务器维护的第二设备执行所述第二功能,所述第一MQTT服务器和所述第二MQTT服务器为两个不同厂商的MQTT服务器。The second control message is sent to the second MQTT server in the MQTT cluster through the communication interface 503, wherein the second control message is used to instruct the execution of the second function on the second device maintained by the second MQTT server, and the first MQTT server and the second MQTT server are MQTT servers from two different manufacturers.
在另一种可能的实现方式中,若所述控制指令请求控制的设备所属的MQTT服务器为非自研MQTT服务器,则所述桥接服务器50与所述第一MQTT服务器基于MQTT协议建立连接,所述第一控制消息属于主题发布消息;In another possible implementation, if the MQTT server to which the device controlled by the control instruction request belongs is a non-self-developed MQTT server, the bridge server 50 establishes a connection with the first MQTT server based on the MQTT protocol, and the first control message belongs to a topic publishing message;
若所述控制指令请求控制的设备所属的MQTT服务器为自研MQTT服务器,则所述桥接服务器50与所述第一MQTT服务器基于远程过程调用RPC协议建立连接,所述第一控制消息属于RPC消息。If the MQTT server to which the device controlled by the control instruction requests belongs is a self-developed MQTT server, the bridge server 50 establishes a connection with the first MQTT server based on the remote procedure call RPC protocol, and the first control message is an RPC message.
在又一种可能的实现方式中,所述处理器501包括桥接Bridge模块;在对所述控制指令进行转换方面,所述处理器501具体用于:In another possible implementation, the processor 501 includes a bridge module; in terms of converting the control instruction, the processor 501 is specifically configured to:
通过所述桥接Bridge模块对所述控制指令进行转换。The control instruction is converted by the bridge module.
在又一种可能的实现方式中,所述MQTT集群中的各个MQTT服务器通过所述处理器501提供的桥接Bridge模块建立所述MQTT集群。In yet another possible implementation, each MQTT server in the MQTT cluster establishes the MQTT cluster through a bridge module provided by the processor 501 .
在又一种可能的实现方式中,在通过所述通信接口503接收业务端发送的控制指令之前,所述处理器501还用于:In yet another possible implementation, before receiving, through the communication interface 503, a control instruction sent by a service end, the processor 501 is further configured to:
通过所述通信接口503接收所述第一MQTT服务器发送的认证请求,其中,所述认证请求用于请求认证所述第一MQTT服务器维护的第一设备的身份和/或业务权限;Receiving, through the communication interface 503, an authentication request sent by the first MQTT server, wherein the authentication request is used to request authentication of the identity and/or service authority of the first device maintained by the first MQTT server;
通过所述通信接口503将所述认证请求分配至所述业务端,以供所述业务端认证所述第一MQTT服务器维护的第一设备。The authentication request is distributed to the service end through the communication interface 503, so that the service end can authenticate the first device maintained by the first MQTT server.
可选的,所述处理器501包括钩子Hook模块,在接收所述第一MQTT服务器发送的认证请求之前,所述处理器501还用于:Optionally, the processor 501 includes a hook module, and before receiving the authentication request sent by the first MQTT server, the processor 501 is further configured to:
通过所述钩子Hook模块接收所述第一MQTT服务器发送的认证请求。The authentication request sent by the first MQTT server is received through the hook module.
可选的,所述认证请求包括目标业务标识,在通过所述通信接口503将所述认证请求分配至所述业务端方面,所述处理器501具体用于:Optionally, the authentication request includes a target service identifier, and in terms of allocating the authentication request to the service end through the communication interface 503, the processor 501 is specifically configured to:
通过所述通信接口503将所述认证请求分配至所述目标业务标识对应的所述业务端;所述处理器501通过所述存储器502存储了多个业务标识与多个业务端之间的对应关系。The authentication request is distributed to the service end corresponding to the target service identifier through the communication interface 503 ; the processor 501 stores the correspondence between multiple service identifiers and multiple service ends through the memory 502 .
其中,所述目标业务标识包括MQTT用户Client身份证明ID前缀标识或用户名前缀标识。The target service identifier includes an MQTT user Client identity ID prefix identifier or a user name prefix identifier.
在又一种可能的实现方式中,在向MQTT集群中的第一MQTT服务器发送所述第一控制消息之后,所述处理器501还用于:In yet another possible implementation, after sending the first control message to the first MQTT server in the MQTT cluster, the processor 501 is further configured to:
通过所述通信接口503接收所述第一MQTT服务器发送的第一消息;Receiving, through the communication interface 503, a first message sent by the first MQTT server;
通过所述通信接口503向所述业务端发送第一消息,其中,所述第一消息包括所述第一MQTT服务器维护的第一设备执行所述第一功能的结果。A first message is sent to the service end through the communication interface 503, wherein the first message includes a result of the first device maintained by the first MQTT server executing the first function.
可选的,所述第一MQTT服务器维护的第一设备执行所述第一功能的结果为经加密处理的消息,所述处理器501用于对所述经加密处理的结果进行解密,所述处理器501通过所述通信接口503向所述业务端发送的结果为经解密处理的消息。Optionally, the result of the first device maintained by the first MQTT server executing the first function is an encrypted message, the processor 501 is used to decrypt the encrypted result, and the result sent by the processor 501 to the business end through the communication interface 503 is a decrypted message.
在又一种可能的实现方式中,所述处理器501与数据库基于相关的信息传输协议(比如HTTP协议、RPC协议)建立连接,其中,所述数据库用于对所述通信接口503接收或发送的消息进行持久化存储。In another possible implementation, the processor 501 establishes a connection with a database based on a relevant information transmission protocol (such as HTTP protocol, RPC protocol), wherein the database is used to persistently store messages received or sent by the communication interface 503.
在又一种可能的实现方式中,所述处理器501与数据流处理平台基于相关的信息传输协议(比如HTTP协议、RPC协议)建立连接,所述数据流处理平台用于对所述通信接口503接收或发送的消息进行流式处理和大数据分析。In another possible implementation, the processor 501 establishes a connection with a data stream processing platform based on relevant information transmission protocols (such as HTTP protocol, RPC protocol), and the data stream processing platform is used to perform streaming processing and big data analysis on messages received or sent by the communication interface 503.
需要说明的是,各个操作的实现还可以对应参照图2或图3所示的方法实施例的相应描述。It should be noted that the implementation of each operation may also correspond to the corresponding description of the method embodiment shown in FIG. 2 or FIG. 3 .
本申请实施例还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,当其在网络设备上运行时,图2或图3所示的方法流程得以实现。An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a network device, the method flow shown in FIG. 2 or FIG. 3 is implemented.
本申请中实施例提到的“至少一个”是指一个或者多个,“多个”是指两个或两个以上,“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A、同时存在A和B、单独存在B这三种情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。In the embodiments of the present application, "at least one" refers to one or more, "more than one" refers to two or more, and "and/or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and/or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character "/" generally indicates that the associated objects before and after are in an "or" relationship.
以及,除非有相反的说明,本申请实施例中提到的第一MQTT服务器、第一控制消息以及第一功能中的“第一”只是用来做名字标识,不用于限定多个对象的顺序、时序、优先级或者重要程度。该规则同样适用于“第二”、“第三”和“第四”等。Furthermore, unless otherwise stated, the "first" in the first MQTT server, the first control message, and the first function mentioned in the embodiments of the present application is only used as a name identifier and is not used to limit the order, timing, priority, or importance of multiple objects. The same rule applies to "second", "third", and "fourth", etc.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211019340.XACN115412329B (en) | 2022-08-24 | 2022-08-24 | Information processing method and related device for Internet of things |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211019340.XACN115412329B (en) | 2022-08-24 | 2022-08-24 | Information processing method and related device for Internet of things |
| Publication Number | Publication Date |
|---|---|
| CN115412329A CN115412329A (en) | 2022-11-29 |
| CN115412329Btrue CN115412329B (en) | 2024-09-17 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202211019340.XAActiveCN115412329B (en) | 2022-08-24 | 2022-08-24 | Information processing method and related device for Internet of things |
| Country | Link |
|---|---|
| CN (1) | CN115412329B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114724557B (en)* | 2022-03-14 | 2024-12-17 | 深圳市凯迪仕智能科技有限公司 | Control method and related device |
| US12217044B2 (en) | 2023-01-30 | 2025-02-04 | Honda Motor Co., Ltd. | System and method for providing enriched connected vehicle mobility communication |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107948193A (en)* | 2017-12-22 | 2018-04-20 | 大陆汽车投资(上海)有限公司 | Suitable for the vehicle shared server means of communication of multiple terminals type access |
| CN112422565A (en)* | 2020-11-18 | 2021-02-26 | 青岛海尔科技有限公司 | Message processing method, device and storage medium and electronic device |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR20200032894A (en)* | 2018-09-19 | 2020-03-27 | 문준태 | IoT Communication Method With Messenger Program |
| CN112565334B (en)* | 2020-11-04 | 2022-10-25 | 深圳市宏电技术股份有限公司 | Access method and device of Internet of things equipment and MQTT gateway |
| CN114690723A (en)* | 2022-03-29 | 2022-07-01 | 阿里巴巴(中国)有限公司 | Device control method, device, server and storage medium for heterogeneous system |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107948193A (en)* | 2017-12-22 | 2018-04-20 | 大陆汽车投资(上海)有限公司 | Suitable for the vehicle shared server means of communication of multiple terminals type access |
| CN112422565A (en)* | 2020-11-18 | 2021-02-26 | 青岛海尔科技有限公司 | Message processing method, device and storage medium and electronic device |
| Publication number | Publication date |
|---|---|
| CN115412329A (en) | 2022-11-29 |
| Publication | Publication Date | Title |
|---|---|---|
| CN115412329B (en) | Information processing method and related device for Internet of things | |
| US20080137830A1 (en) | Dispatching A Message Request To A Service Provider In A Messaging Environment | |
| CN108449418A (en) | A hybrid cloud platform management system and method | |
| CN111901230B (en) | Internet of things gateway and system supporting equipment access verification and equipment access verification method | |
| CN110808948B (en) | Remote procedure call method, device and system | |
| CN113810264B (en) | Information transmission method, device, electronic equipment and storage medium | |
| CN111818158B (en) | Gateway control method, device, electronic device and storage medium | |
| CN113177179B (en) | Data request connection management method, device, equipment and storage medium | |
| CN108881111A (en) | A kind of method and device for realizing multi-tenant system | |
| US12430186B2 (en) | Hardware accelerator service aggregation | |
| CN113986811A (en) | High-performance kernel-mode network data packet acceleration method | |
| CN112181681A (en) | Remote calling method and device, computer equipment and storage medium | |
| CN113965628B (en) | Message scheduling method, server and storage medium | |
| CN114221995A (en) | Service calling method and device and electronic equipment | |
| CN117135156A (en) | Edge cluster nano-management method and system based on publish/subscribe message protocol | |
| CN1939035B (en) | Method and apparatus for communicating data between computer devices | |
| CN118827648A (en) | Automatic docking method, system, device and medium for Internet of Things devices | |
| CN113992641A (en) | Data processing method, device, equipment and storage medium | |
| CN118740899A (en) | Virtual debugging communication method, device, equipment and storage medium | |
| CN118054932A (en) | Method and system for operating object storage service based on proxy server and electronic equipment | |
| CN114844961B (en) | Distributed system protocol intercommunication method, device, equipment and storage medium | |
| CN115086425A (en) | Message transmission method, device, program product, medium and electronic equipment | |
| CN111240867B (en) | Information communication system and method | |
| CN113988797A (en) | Method and device for processing request, storage medium and electronic device | |
| CN114201315A (en) | Cache method and device, electronic device and storage medium for microservice system |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CP03 | Change of name, title or address | Address after:518000 Office Building 02, 11th Floor, Building B2, Xiandong Road, Xiandong Community, Xili Street, Nanshan District, Shenzhen City, Guangdong Province, China Patentee after:Shenzhen Kaidisi Intelligent Technology Co.,Ltd. Country or region after:China Address before:9 / F, block B, Tsinghua information port, No.1, Xindong Road, songpingshan community, Xili street, Nanshan District, Shenzhen City, Guangdong Province Patentee before:SHENZHEN KAADAS INTELLIGENT TECHNOLOGY Co.,Ltd. Country or region before:China | |
| CP03 | Change of name, title or address |