Data transmission method, internet of things server and gateway device

By implementing custom topics and scope management, the flexibility issue of IoT server usage is resolved, enabling device access and data flow through user-defined topics, reducing IoT access costs, and improving the convenience of device production and integration.

CN115941742BActive Publication Date: 2025-11-28ALIBABA CLOUD COMPUTING CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211586435.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-09
Publication Date
2025-11-28
Estimated Expiration
2042-12-09

AI Technical Summary

Technical Problem

When dealing with tens of thousands to millions of connected devices, existing IoT server technologies suffer from poor flexibility due to fixed or predefined topics, making it unable to adapt to user-defined topics and affecting the flexibility of device access and data flow.

Method used

By defining custom topics and determining the scope based on device information, message flow is achieved through topic subscription relationships within the scope. This supports the use of user-defined topics and enables device identity pass-through and message isolation.

Benefits of technology

It improves the flexibility of IoT server usage, reduces device access costs, supports reuse without modification in existing scenarios and device migration, and enhances the convenience of integrating device production with IoT server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115941742B_ABST
    Figure CN115941742B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a data transmission method, an Internet of Things server and a gateway device. The method comprises the following steps: receiving uplink data sent by a first device, wherein the uplink data comprises a first Topic and a first message body; determining a scope corresponding to the uplink data according to device information of the first device; determining a subscription object of the first Topic based on a Topic subscription relationship in the scope; and sending the uplink data to the subscription object of the first Topic, so that the use flexibility of the Internet of Things server is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of Internet of Things, and more particularly, to a data transmission method, an Internet of Things server and a gateway device. BACKGROUND

[0002] In an Internet of Things scenario, a device end needs to carry a topic in the sent data when sending uplink data or a user service end sends downlink instructions, and a receiving end needs to subscribe to a related topic. The Internet of Things server will transfer data flow to the corresponding receiving end according to the topic subscription relationship.

[0003] Since the scale of devices accessed by the Internet of Things server is usually in the range of ten thousand to ten million, in order to simplify the data flow transfer and distribution process, the existing Internet of Things server often has a built-in fixed topic or only allows the user to predefine a fixed format topic, which results in poor flexibility of the Internet of Things server. SUMMARY

[0004] The present application provides a data transmission method, an Internet of Things server and a gateway device to improve the flexibility of the Internet of Things server.

[0005] In a first aspect, the present application provides a data transmission method, comprising:

[0006] receiving uplink data sent by a first device, wherein the uplink data comprises a first topic and a first message body;

[0007] determining a scope corresponding to the uplink data according to device information of the first device;

[0008] determining a subscription object of the first topic based on a topic subscription relationship within the scope;

[0009] sending the uplink data to the subscription object of the first topic.

[0010] Optionally, the device information of the first device comprises an identifier of the first device, an identifier of a product to which the first device belongs, and an identifier of a user to which the product belongs; and the scope comprises a device scope, a product scope and a user scope.

[0011] Optionally, before the determining the scope corresponding to the uplink data according to the device information of the first device, the method further comprises:

[0012] determining the identifier of the product to which the first device belongs and the identifier of the user to which the product belongs according to the identifier of the first device and device connection session information of the first device.

[0013] Optionally, the first device is a gateway sub-device; and the receiving the uplink data sent by the first device comprises:

[0014] receiving encapsulated uplink data sent by a gateway device, the encapsulated uplink data being obtained by the gateway device encapsulating uplink data sent by the gateway sub-device, the encapsulated uplink data comprising a gateway Topic, a second message body and an identifier of the gateway device, the second message body comprising the first Topic, the first message body and an identifier of the gateway sub-device;

[0015] unpacking the encapsulated uplink data based on the gateway Topic to obtain the second message body.

[0016] Optionally, the first device is a direct connection device.

[0017] In a second aspect, the present application provides a data transmission method, comprising:

[0018] receiving downlink data sent by a second device, the downlink data comprising a second Topic, a third message body and target device information;

[0019] determining a scope corresponding to the downlink data according to the target device information;

[0020] determining a subscription object of the second Topic based on a Topic subscription relationship within the scope;

[0021] in a case where the subscription object of the second Topic comprises the target device, sending the downlink data to the target device.

[0022] Optionally, the target device information comprises at least one of an identifier of the target device, an identifier of a product to which the target device belongs and an identifier of a user to which the product belongs.

[0023] Optionally, the target device is a gateway sub-device; and the sending the downlink data to the target device comprises:

[0024] encapsulating the downlink data to obtain encapsulated downlink data, the encapsulated downlink data comprising a gateway Topic, a fourth message body and an identifier of a gateway device, the fourth message body comprising the second Topic, the third message body and an identifier of the gateway sub-device;

[0025] sending the encapsulated downlink data to the gateway device, so that the gateway device unpacks the encapsulated downlink data based on the gateway Topic and sends the second Topic and the third message body unpacked to the gateway sub-device.

[0026] Optionally, the target device is a direct connection device.

[0027] In a third aspect, the present application provides a data transmission method, comprising:

[0028] receiving uplink data sent by a gateway sub-device, wherein the uplink data comprises a first Topic and a first message body;

[0029] performing encapsulation on the uplink data to obtain encapsulated uplink data, wherein the encapsulated uplink data comprises a gateway Topic, a second message body and an identifier of the gateway device, and the second message body comprises the first Topic, the first message body and an identifier of the gateway sub-device;

[0030] sending the encapsulated uplink data to an Internet of Things server, so that the Internet of Things server unpacks the encapsulated uplink data based on the gateway Topic to obtain the second message body, determines a scope corresponding to the uplink data according to the identifier of the gateway sub-device, determines a subscription object of the first Topic based on a Topic subscription relationship within the scope, and sends the uplink data to the subscription object of the first Topic.

[0031] In a fourth aspect, the present application provides a data transmission method, comprising:

[0032] receiving encapsulated downlink data sent by an Internet of Things server, wherein the encapsulated downlink data comprises a gateway Topic, a fourth message body and an identifier of a gateway device, the fourth message body comprises a second Topic, a third message body and an identifier of a gateway sub-device, the encapsulated downlink data is obtained by performing encapsulation on downlink data sent by the Internet of Things server, and the downlink data comprises the second Topic, the third message body and gateway sub-device information;

[0033] unpacking the encapsulated downlink data based on the gateway Topic, and sending the second Topic and the third message body obtained by unpacking to the gateway sub-device.

[0034] In a fifth aspect, the present application provides an Internet of Things server, comprising a memory and a processor.

[0035] The memory is configured to store a computer program.

[0036] The processor is configured to execute the computer program stored in the memory, and the computer program, when running, causes the processor to execute the method of the first aspect or the second aspect.

[0037] In a sixth aspect, the present application provides a gateway device, comprising a memory and a processor;

[0038] The memory is configured to store a computer program.

[0039] The processor is configured to execute the computer program stored in the memory, and the computer program, when executed, causes the processor to perform the method of the third aspect or the fourth aspect.

[0040] In a seventh aspect, the present application provides a computer readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the processor performs the method of the first aspect to the fourth aspect.

[0041] The data transmission method, the Internet of Things server and the gateway device provided by the present application allow users to customize any Topic. On the one hand, in the inventory scenario or the device migration and station moving scenario, the original any Topic can be directly reused without the need to modify and adapt to the fixed Topic specification, thereby reducing the Internet of Things access cost. On the other hand, the users can flexibly customize the Topic to identify different application scenarios, and these customized Topics do not need to be created in advance in the Internet of Things server before use, so that the device production process and the Internet of Things server integration process can be completely decoupled, thereby significantly improving the use flexibility and convenience. BRIEF DESCRIPTION OF DRAWINGS

[0042] Figure 1 is a message flow diagram of an Internet of Things server;

[0043] Figure 2 is a diagram of the scope of the Topic subscription relationship provided by the embodiment of the present application;

[0044] Figure 3 is a structural diagram of the Topic subscription relationship provided by the embodiment of the present application;

[0045] Figure 4 is a Topic subscription diagram provided by the embodiment of the present application;

[0046] Figure 5 is a message flow diagram based on the scope provided by the embodiment of the present application;

[0047] Figure 6 is a flow diagram of a data transmission method provided by the embodiment of the present application;

[0048] Figure 7 is a flow diagram of another data transmission method provided by the embodiment of the present application;

[0049] Figure 8is an uplink data flow conversion schematic diagram of a gateway sub-device provided by an embodiment of the present application;

[0050] Figure 9 is a downlink data flow conversion schematic diagram of a gateway sub-device provided by an embodiment of the present application;

[0051] Figure 10 is an uplink and downlink message flow conversion schematic diagram provided by an embodiment of the present application;

[0052] Figure 11 is a schematic block diagram of a data transmission device provided by an embodiment of the present application;

[0053] Figure 12 is a schematic block diagram of another data transmission device provided by an embodiment of the present application;

[0054] Figure 13 is a schematic block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0055] First, the professional terms related to the embodiments of the present application are explained and described.

[0056] 1. Internet of Things server: a platform integrating device management, device access, and uplink and downlink message subscription flow conversion, supporting device access and device data uplink in the south direction, and supporting user server control instruction issuing in the north direction.

[0057] 2. Device access: direct devices (direct) or gateway sub-devices (indirect) are accessed to the Internet of Things server through Message Queuing Telemetry Transport (MQTT), The Constrained Application Protocol (CoAP), industry private protocol, etc., to realize device end data uplink and user server instruction receiving capabilities.

[0058] 3. Message flow conversion: the Internet of Things server distributes device end uplink data or user server downlink instructions to the correct destination through Topic subscription relationship, for example, device end uplink data is converted to user message or storage middleware through the Internet of Things server rule engine.

[0059] Figure 1 is a message flow conversion schematic diagram of an Internet of Things server. As Figure 1As shown, the example direct connection device sends uplink data to the Internet of Things service end, the uplink data containing Topic, the Internet of Things service end based on Topic subscription relationship-2 flows the uplink data to the user message middleware; as shown, the example gateway sub-device sends uplink data to the Internet of Things service end through the gateway device, the uplink data containing Topic, the Internet of Things service end based on Topic subscription relationship-3 flows the uplink data to the user storage middleware; as shown, the example user service end sends downlink instructions to the Internet platform, the downlink instructions containing Topic, the Internet of Things service end based on Topic subscription relationship-1 flows the downlink instructions to the direct connection device. Wherein, the user service end can be cloud, the user service end can acquire uplink data through the user message middleware or the user storage middleware.

[0060] In the Internet of Things scenario, each device often uses different Topic for message reporting to identify the device itself and application scenario related information, etc. In the face of such a large number of Topics, in order to simplify the data flow distribution process, the Internet of Things service end often has built-in fixed Topic or only allows users to predefine fixed format Topic, that is, the Internet of Things service end does not allow users to use any Topic for message flow. This results in poor flexibility of the Internet of Things service end.

[0061] In view of this, the embodiment of the present application provides a data transmission method, which allows users to use any Topic for message flow. The device connection session is used to obtain device information for Topic subscription relationship query and message flow. There is no need to identify device identity through Topic, and the Topic subscription relationship is isolated based on scope. The same arbitrary Topic can be reused between different users and products, improving the flexibility of the Internet of Things service end.

[0062] Figure 2 is a schematic diagram of the scope of the Topic subscription relationship provided by the embodiment of the present application. As Figure 2 shown, the scope of the Topic subscription relationship of the embodiment of the present application can be divided into global scope, user scope, product scope and device scope. Wherein, the global scope is maintained by the Internet of Things service end, and is used for internal system flow of part of built-in Topic in the Internet of Things service end. The user of the Internet of Things service end can have multiple products, and each product can have multiple devices. The user scope, product scope and device scope are used to isolate and manage the Topic subscription relationship from different maintenance.

[0063] Figure 3 is a structural schematic diagram of the Topic subscription relationship provided by the embodiment of the present application. As Figure 3As shown, the subscription relationship includes global scope, user scope, product scope and device scope, and the global scope includes subscription relationship G1-1 and G1-2, the user scope includes user U1 scope and user U2 scope, the user U1 scope includes subscription relationship U1-1 and U1-2, the product scope includes product P1 scope and product P2 scope, the product P1 scope includes subscription relationship P1-1 and P1-2, the device scope includes device D1 scope and device D2 scope, and the device D1 scope includes subscription relationship D1-1 and D1-2. The subscription relationship includes Topic and a subscription object (a subscriber), and it can be seen that the subscription relationship metadata in the embodiment of the present application only includes scope, Topic and a subscription object, and the model has a tree-like structure of subscription relationship retrieval logic, and the scope can quickly circumscribe a smaller retrieval range, has high subscription relationship retrieval efficiency, supports isolation of subscription relationships of different users, products and devices, and the subscription relationship metadata model structure is universal and can be implemented based on common relational data blocks or non-relational databases, has good scalability while ensuring performance, and has guaranteed consistency.

[0064] Figure 4 FIG. 1 is a schematic diagram of Topic subscription provided by an embodiment of the present application. As shown in FIG. 1, the subscription relationship includes global scope, user scope, product scope and device scope, and the global scope includes subscription relationship G1-1 and G1-2, the user scope includes user U1 scope and user U2 scope, the user U1 scope includes subscription relationship U1-1 and U1-2, the product scope includes product P1 scope and product P2 scope, the product P1 scope includes subscription relationship P1-1 and P1-2, the device scope includes device D1 scope and device D2 scope, and the device D1 scope includes subscription relationship D1-1 and D1-2. The subscription relationship includes Topic and a subscription object (a subscriber), and it can be seen that the subscription relationship metadata in the embodiment of the present application only includes scope, Topic and a subscription object, and the model has a tree-like structure of subscription relationship retrieval logic, and the scope can quickly circumscribe a smaller retrieval range, has high subscription relationship retrieval efficiency, supports isolation of subscription relationships of different users, products and devices, and the subscription relationship metadata model structure is universal and can be implemented based on common relational data blocks or non-relational databases, has good scalability while ensuring performance, and has guaranteed consistency. Figure 4

[0065] Figure 5 FIG. 2 is a schematic diagram of message flow based on scope provided by an embodiment of the present application. As shown in FIG. 2, the message flow includes global scope, user scope, product scope and device scope, and the global scope includes subscription relationship G1-1 and G1-2, the user scope includes user U1 scope and user U2 scope, the user U1 scope includes subscription relationship U1-1 and U1-2, the product scope includes product P1 scope and product P2 scope, the product P1 scope includes subscription relationship P1-1 and P1-2, the device scope includes device D1 scope and device D2 scope, and the device D1 scope includes subscription relationship D1-1 and D1-2. The subscription relationship includes Topic and a subscription object (a subscriber), and it can be seen that the subscription relationship metadata in the embodiment of the present application only includes scope, Topic and a subscription object, and the model has a tree-like structure of subscription relationship retrieval logic, and the scope can quickly circumscribe a smaller retrieval range, has high subscription relationship retrieval efficiency, supports isolation of subscription relationships of different users, products and devices, and the subscription relationship metadata model structure is universal and can be implemented based on common relational data blocks or non-relational databases, has good scalability while ensuring performance, and has guaranteed consistency. Figure 5 ​As shown, when the message flows, the subscription relationship is found based on the specified scope for message routing. For example, for the uplink data of the device side, according to the device connection session information, the device information, the product information corresponding to the device and the user information are determined, and then the product scope, the product scope and the user scope are determined, the subscription relationship is found based on the determined product scope, the product scope and the user scope respectively, and the message flow is based on the subscription object in the subscription relationship. For example, for the downlink instruction of the user service side, the device scope is specified through the downlink instruction, and the subscription relationship is found in the device scope for message flow.

[0066] The following will be described in detail Figure 6 The uplink data transmission in the data transmission method provided by the embodiment of the application is introduced.

[0067] Figure 6 is a flow diagram of a data transmission method provided by the embodiment of the application. The execution subject of the method is an Internet of Things service side. As shown in Figure 6 The method comprises the following steps.

[0068] S601, receiving uplink data sent by a first device, wherein the uplink data comprises a first Topic and a first message body.

[0069] The first device can be a direct connection device or a gateway sub-device, and the first Topic can be any Topic customized by a user, and the first message body contains message data to be transmitted.

[0070] Optionally, in the case where the first device is a gateway sub-device, the Internet of Things service side receives the uplink data of the gateway sub-device through the gateway device, comprising: receiving the encapsulated uplink data sent by the gateway device, wherein the encapsulated uplink data is obtained by the gateway device encapsulating the uplink data sent by the gateway sub-device, and the encapsulated uplink data comprises a gateway Topic, a second message body and an identifier of the gateway device, and the second message body comprises the first Topic, the first message body and the identifier of the gateway sub-device; unpacking the encapsulated uplink data based on the gateway Topic to obtain the second message body. Wherein, the gateway Topic can be a fixed Topic, and after receiving the uplink data of the gateway sub-device, the gateway device encapsulates the first Topic, the first message body and the identifier of the gateway sub-device into a new message body, i.e. the second message body, and uses the fixed Topic as the new Topic, and adds the identifier of the gateway device as the new message source, thereby obtaining the encapsulated uplink data.

[0071] S602, determining the scope corresponding to the uplink data according to the device information of the first device.

[0072] Optionally, the device information of the first device comprises an identifier of the first device, an identifier of a product to which the first device belongs, and an identifier of a user to which the product belongs; and the scope corresponding to the uplink data comprises a device scope, a product scope, and a user scope.

[0073] Optionally, the IoT server determines the identifier of the product to which the first device belongs and the identifier of the user to which the product belongs according to the identifier of the first device and the device connection session information of the first device. When the direct connection device sends the uplink data to the IoT server, the IoT server can obtain the identifier of the direct connection device, and the identifier of the network sub-device can be obtained after the IoT server unpacks the encapsulated uplink data. In addition, in the device connection and authentication stage between the first device and the IoT server, the device information of the first device is bound to the device connection session, and the IoT server can cache the device information of the first device, so as to determine the identifier of the product to which the first device belongs and the identifier of the user to which the product belongs based on the identifier of the first device, and then determine the corresponding device scope, product scope, and user scope.

[0074] S603, determining a subscription object of the first Topic based on a Topic subscription relationship in the scope.

[0075] After determining the device scope, the product scope, and the user scope, the IoT server searches for the subscription object of the first Topic in each scope, for example, searches for the subscription object of the first Topic in the user U1 scope, the product P1 scope, and the device D1 scope as shown in FIG. 6. Figure 3

[0076] S604, sending the uplink data to the subscription object of the first Topic.

[0077] The subscription object of the first Topic can be a user message middleware or a user storage middleware. It can be understood that the user server can obtain the uplink data of the first device from the user message middleware or the user storage middleware.

[0078] The following describes the downlink data transmission in the data transmission method provided by the embodiment of the application. Figure 7

[0079] FIG. 7 is a flowchart of another data transmission method provided by the embodiment of the application. The execution subject of the method is an IoT server. As shown in FIG. 7, the method comprises the following steps. Figure 7 Figure 7 S701, receiving downlink data sent by a second device, wherein the downlink data comprises a second Topic, a third message body, and target device information.

[0080] S701, receiving downlink data sent by a second device, wherein the downlink data comprises a second Topic, a third message body, and target device information.

[0081] ​​The second device is a user service end, the user service end can be a cloud end, and the downlink data can be a downlink instruction. The second Topic can be any Topic customized by a user, and the third message body includes message data, such as instruction information, that needs to be transmitted. The target device can be a direct connection device or a gateway sub-device.

[0082] Optionally, the target device information can include at least one of an identifier of the target device, an identifier of a product to which the target device belongs, and an identifier of a user to which the product belongs. It can be understood that, if the target device information is the identifier of the product to which the target device belongs, all devices under the product are the target device; if the target device information is the identifier of the user to which the product belongs, all devices under all products of the user are the target device.

[0083] S702, determining a scope corresponding to the downlink data according to the target device information.

[0084] Optionally, if the target device information is the identifier of the target device, the device scope corresponding to the target device can be directly determined based on the identifier of the target device; if the target device information is the identifier of the product to which the target device belongs, the identifiers of all devices under the product can be determined according to the identifiers of the devices and the identifiers of the products to which the devices belong that are cached by the Internet of Things service end, and the corresponding device scope is further determined; if the target device information is the identifier of the user to which the product belongs, the identifiers of all devices under all products of the user can be determined according to the identifiers of the devices, the identifiers of the products to which the devices belong, and the identifiers of the users to which the products belong that are cached by the Internet of Things service end, and the corresponding device scope is further determined.

[0085] S703, determining a subscription object of the second Topic based on a Topic subscription relationship in the scope.

[0086] After the device scope is determined, the Internet of Things service end searches for the subscription object of the second Topic in the device scope, for example, searches for the subscription object of the second Topic in the device D1 scope as shown in FIG. 6. Figure 3

[0087] S704, in the case where the subscription object of the second Topic includes the target device, sending the downlink data to the target device.

[0088] Optionally, in the case where the target device is a direct connection device, the Internet of Things service end directly sends the downlink data to the target device.

[0089] ​Optionally, in the case that the target device is a gateway sub-device; the Internet of Things device encapsulates the downlink data to obtain encapsulated downlink data, the encapsulated downlink data including a gateway Topic, a fourth message body, and an identifier of the gateway device, the fourth message body including a second Topic, a third message body, and an identifier of the gateway sub-device; and the encapsulated downlink data is sent to the gateway device, so that the gateway device unpacks the encapsulated downlink data based on the gateway Topic, and sends the second Topic and the third message body obtained by unpacking to the gateway sub-device. The gateway Topic can be a fixed Topic.

[0090] After the Internet of Things server receives the downlink data of the target device being a gateway sub-device, the second Topic, the third message body, and the identifier of the gateway sub-device are encapsulated into a new message body, i.e., a fourth message body, a fixed Topic is used as a new Topic, and the identifier of the gateway device is added as a new message source, so that encapsulated downlink data is obtained and sent to the gateway device. The gateway device receives the encapsulated downlink data, identifies the received downlink data for the gateway sub-device based on the fixed Topic, unpacks the downlink data, and obtains the second Topic and the third message body.

[0091] The data transmission method provided in the embodiments of the present application does not have any limitation on the Topic used by the user, and allows the user to customize any Topic. On the one hand, in the stock scenario or device migration and station moving scenario, there is no need to modify and adapt to the fixed Topic specification, and the original any Topic can be directly reused, thereby reducing the Internet of Things access cost. On the other hand, the user can flexibly customize the Topic to identify different application scenarios, and these customized Topics do not need to be created in advance in the Internet of Things server before use. In combination with the MQTT standard authentication, the device production process and the Internet of Things server integration process can be completely decoupled, thereby significantly improving the use flexibility and convenience.

[0092] In addition, in the embodiments of the present application, direct connection devices and gateway sub-devices (single connection multiple devices) are simultaneously supported to use any Topic. For the gateway sub-device scenario, by encapsulating and converting any Topic message, the real device identity and any original Topic can be directly transmitted to the user server, and the user does not need to identify the real device identity by disassembling the Topic in the message body, so that the gateway sub-device supports any Topic message uplink and downlink, and the processing complexity of the gateway sub-device message by the user is reduced.

[0093] The data transmission method provided in the embodiments of the present application is applied to a gateway device, and includes:

[0094] receive uplink data sent by the gateway sub-device, the uplink data including a first Topic and a first message body; encapsulate the uplink data to obtain encapsulated uplink data, the encapsulated uplink data including a gateway Topic, a second message body and an identifier of the gateway device, the second message body including the first Topic, the first message body and an identifier of the gateway sub-device;

[0095] send the encapsulated uplink data to the Internet of Things server, so that the Internet of Things server unpacks the encapsulated uplink data to obtain the second message body, determines a scope corresponding to the uplink data according to the identifier of the gateway sub-device, determines a subscription object of the first Topic based on a Topic subscription relationship within the scope, and sends the uplink data to the subscription object of the first Topic.

[0096] In the implementation of the present application, the gateway device needs to re-encapsulate the uplink data of the gateway sub-device, and add device information. Correspondingly, the Internet of Things server unpacks the encapsulated data to obtain the original Topic and message body, and converts them into the original device identity after receiving the encapsulated data.

[0097] As shown in the examples in Figure 8 Fig. 1 shows a flow conversion diagram of uplink data of a gateway sub-device, as shown in Figure 8 The uplink data sent by the gateway sub-device includes a first Topic: / a / b / c and a first message body: xxx. After receiving the uplink data, the gateway encapsulates / a / b / c, xxx and a sub-device (subDevice) into a second message body, uses a fixed Topic: $aiot / ext / gateway / sub / up / publish as a new Topic, adds the gateway as a new device identity, and obtains encapsulated uplink data. The Internet of Things server unpacks the received encapsulated uplink data to obtain the second message body therein, and sends it to a user message or a storage middleware based on the scope and the subscription relationship.

[0098] The present application provides a data transmission method, applied to a gateway device, including:

[0099] receive encapsulated downlink data sent by the Internet of Things server, the encapsulated downlink data including a gateway Topic, a fourth message body and an identifier of the gateway device, the fourth message body including a second Topic, a third message body and an identifier of the gateway sub-device, the encapsulated downlink data being obtained by the Internet of Things server encapsulating downlink data sent by a second device, the downlink data including the second Topic, the third message body and gateway sub-device information;

[0100] The gateway topic is used to unpack the encapsulated downlink data, and the unpacked second topic and third message body are sent to the gateway sub-device.

[0101] In the implementation of this application, when the IoT server processes downlink data from the gateway sub-device, it needs to repackage the data and add device information. Correspondingly, after receiving the packaged data, the gateway device unpacks it to obtain the original Topic and message body, and converts it into the original device identity.

[0102] For example, such as Figure 9 The diagram illustrates the downlink data flow of the gateway sub-device, as shown below. Figure 9 As shown, the downlink data sent by the user server includes a second Topic: / d / e / f, a third message body: yyy, and the target device identity: gateway sub-device. After receiving the downlink data, the IoT server encapsulates it, combining / d / e / f, yyy, and the sub-device into a fourth message body. It then uses a fixed Topic: $aiot / ext / gateway / sub / down / publish as a new Topic, adding the gateway as a new device identity, resulting in the encapsulated downlink data. The gateway device unpacks the received encapsulated downlink data, obtaining the third message body, and sends it to the network sub-device.

[0103] The following combination Figure 10 The message flow process in the implementation of this application is described. For example... Figure 10 As shown, the uplink message flow process includes:

[0104] S1-1: Uplink message from a directly connected device, carrying a Topic and message body.

[0105] S1-2: Gateway sub-device message uplink, specifically including:

[0106] S1-2-1: Gateway sub-device message uplink, the message carries the original Topic and message body.

[0107] S1-2-2: The gateway device re-encapsulates the uplink messages of the gateway sub-devices, encapsulating the original Topic, message body, and sub-device information into a new message body in a fixed format, and adding gateway device information using a new fixed Topic.

[0108] S1-2-3: The IoT server identifies the uplink message as an uplink message from the gateway sub-device through a fixed Topic, unpacks the message body into the original Topic and message body, and changes the message source identity from the gateway device to the gateway sub-device.

[0109] S1-3: In the direct connection device and gateway sub-device connection authentication stage, the device information (device ID, product ID, user ID, etc.) has been bound with the device connection session. In this step, the device information in the device connection session information is converted into the corresponding device scope, product scope and user scope according to the message source identity.

[0110] S1-4: The Internet of Things platform finds the corresponding subscription relationship according to the scope, and routes the message.

[0111] The subscription relationship finding of this step can be accelerated by using multi-level heterogeneous cache.

[0112] S1-5: The device end uplink message is routed to the user storage or message middleware, and the user storage or message middleware only senses the real device identity and the original Topic.

[0113] The downlink message routing process includes:

[0114] S2-1: The user service end calls the Internet of Things service end interface to issue instructions to the target device, which can be specified as a direct connection device or a gateway sub-device.

[0115] S2-2: Determine the device scope according to the target device.

[0116] S2-3: The Internet of Things service end finds the corresponding subscription relationship according to the scope, and routes the message.

[0117] The subscription relationship finding of this step can be accelerated by using multi-level heterogeneous cache.

[0118] S2-4: The Internet of Things service end distributes the downlink message of the user service end to the direct connection device.

[0119] S2-5: The gateway sub-device receives the downlink instructions of the user service end distributed by the Internet of Things service end. Specifically includes:

[0120] S2-5-1: When the target device is a gateway sub-device, the Internet of Things platform re-encapsulates the downlink message, encapsulates the original Topic, message body and gateway sub-device information into a new message body in a fixed format, uses a new fixed Topic, and finds the gateway device corresponding to the gateway sub-device according to the topological relationship, and adds the gateway device information.

[0121] S2-5-2: The Internet of Things service end issues the downlink message of the user service end to the gateway device.

[0122] S2-5-3: After receiving the downlink message, the gateway device identifies the downlink message as a gateway sub-device downlink message through a fixed Topic, unpacks the message body into an original Topic and a message body, and forwards the message body to the corresponding gateway sub-device according to gateway sub-device information.

[0123] Figure 11 is a schematic block diagram of a data transmission apparatus provided by the embodiment of the present application. As shown in the figure, the apparatus 1100 comprises: Figure 11

[0124] a receiving module 1101, configured to receive uplink data sent by a first device, the uplink data comprising a first Topic and a first message body;

[0125] a first determining module 1102, configured to determine a scope corresponding to the uplink data according to device information of the first device;

[0126] a second determining module 1103, configured to determine a subscription object of the first Topic based on a Topic subscription relationship within the scope;

[0127] a sending module 1104, configured to send the uplink data to the subscription object of the first Topic.

[0128] Optionally, the device information of the first device comprises an identifier of the first device, an identifier of a product to which the first device belongs, and an identifier of a user to which the product belongs; and the scope comprises a device scope, a product scope, and a user scope.

[0129] Optionally, the first determining module 1102 is further configured to:

[0130] determine the identifier of the product to which the first device belongs and the identifier of the user to which the product belongs according to the identifier of the first device and device connection session information of the first device.

[0131] Optionally, the first device is a gateway sub-device; and the receiving module 1101 is configured to:

[0132] receive encapsulated uplink data sent by a gateway device, the encapsulated uplink data being obtained by the gateway device encapsulating uplink data sent by the gateway sub-device, the encapsulated uplink data comprising a gateway Topic, a second message body, and an identifier of the gateway device, the second message body comprising the first Topic, the first message body, and an identifier of the gateway sub-device;

[0133] unpack the encapsulated uplink data based on the gateway Topic to obtain the second message body.

[0134] Optionally, the first device is a direct connection device.

[0135] ​The device provided by the embodiments of the present application can be used to implement the data transmission method. For details, refer to the detailed description in the foregoing embodiments, which will not be repeated here.

[0136] Figure 12 is a schematic block diagram of another data transmission device provided by the embodiments of the present application. As shown in the figure, Figure 12 The device 1200 includes:

[0137] The receiving module 1201 is configured to receive downlink data sent by a second device, the downlink data including a second Topic, a third message body and target device information.

[0138] The first determining module 1202 is configured to determine a scope corresponding to the downlink data according to the target device information.

[0139] The second determining module 1203 is configured to determine a subscription object of the second Topic based on a Topic subscription relationship within the scope.

[0140] The sending module 1204 is configured to send the downlink data to the target device in a case where the subscription object of the second Topic includes the target device.

[0141] Optionally, the target device information includes at least one of an identifier of the target device, an identifier of a product to which the target device belongs and an identifier of a user to which the product belongs.

[0142] Optionally, the target device is a gateway sub-device, and the sending module 1204 is configured to:

[0143] encapsulate the downlink data to obtain encapsulated downlink data, the encapsulated downlink data including a gateway Topic, a fourth message body and an identifier of a gateway device, the fourth message body including the second Topic, the third message body and an identifier of the gateway sub-device;

[0144] send the encapsulated downlink data to the gateway device, so that the gateway device unpacks the encapsulated downlink data based on the gateway Topic, and sends the second Topic and the third message body obtained by unpacking to the gateway sub-device.

[0145] Optionally, the target device is a direct connection device.

[0146] The device provided by the embodiments of the present application can be used to implement the data transmission method. For details, refer to the detailed description in the foregoing embodiments, which will not be repeated here.

[0147] Figure 13 is a schematic block diagram of an electronic device provided by the embodiments of the present application. As shown in the figure, Figure 13As shown, the electronic device 1300 can include at least one processor 1310 for implementing the data transmission method provided by the embodiments of the present application. The electronic device 1300 can be an Internet of Things server or a gateway device.

[0148] Optionally, the electronic device 1300 further includes at least one memory 1320 for storing program instructions and / or data. The memory 1320 and the processor 1310 are coupled. The coupling in the embodiments of the present application is indirect coupling or communication connection between devices, units or modules, which can be electrical, mechanical or other forms, for information interaction between devices, units or modules. The processor 1310 can operate in cooperation with the memory 1320. The processor 1310 can execute the program instructions stored in the memory 1320. At least one of the at least one memory can be included in the processor.

[0149] Optionally, the electronic device 1300 further includes a communication interface 1330 for communicating with other devices through a transmission medium, so that the electronic device 1300 can communicate with other devices. The communication interface 1330 can be, for example, a transceiver, an interface, a bus, a circuit or a device capable of realizing the transceiving function. The processor 1310 can utilize the communication interface 1330 to transceive data and / or information, and is used to implement the data transmission method provided by the embodiments of the present application.

[0150] The specific connection medium between the processor 1310, the memory 1320 and the communication interface 1330 is not limited in the embodiments of the present application. In the embodiments of the present application, the processor 1310, the memory 1320 and the communication interface 1330 are connected through a bus 1340. Figure 13 The connection mode between other components is only schematically illustrated, and is not limited. The bus can be divided into an address bus, a data bus, a control bus, etc. For convenience, only one thick line is used to represent the bus in the figure, but it does not mean that there is only one bus or only one type of bus. Figure 13 Figure 13

[0151] ​​It should be understood that the processor in the embodiments of the present application can be an integrated circuit chip with a signal processing capability. In the implementation process, the steps of the method embodiments described above can be completed by an integrated logic circuit or an instruction in the form of software in the processor. The processor described above can be a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general purpose processor can be a microprocessor or the processor can also be any conventional processor or the like. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the storage, and the processor reads the information in the storage, and combines the hardware to complete the steps of the above method.

[0152] It should also be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically EPROM (EEPROM) or a flash memory. The volatile memory can be a random access memory (RAM) used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM) and direct rambus RAM (DR RAM). It should be noted that the memory of the system and method described herein is intended to include, but not limited to, these and any other suitable types of memory.

[0153] The present application also provides a computer readable storage medium, which stores a computer program (also referred to as code or instructions). When the computer program is executed, it makes the computer execute the functions in the foregoing embodiments.

[0154] The terms "unit", "module" and the like used in the specification can be used to represent computer-related entities, hardware, combinations of hardware and software, software, or software in execution.

[0155] Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and steps described in connection with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or combinations of both. The choice of hardware or software, or combinations of both, would be dependent on the specific application and design constraints imposed on the overall system. Skilled artisans can implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application. In several embodiments provided in the present application, it will be apparent that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the division of the units described above is merely illustrative, and for example, the division of the units is merely a logical function division, and actual implementation can have another division, for example, a plurality of units or components can be combined or integrated into another system, or some features can be omitted or not implemented. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.

[0156] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. can be located in one place or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.

[0157] In addition, the functional units in each of the embodiments of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit.

[0158] In the above embodiments, the functions of the various functional units can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, the whole or part of the computer program instructions (program) can be implemented in the form of a computer program product. When the computer program instructions (program) are loaded and executed on a computer, the whole or part of the flow or function according to the embodiments of the present application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL) or wireless (such as infrared, wireless, microwave, etc.)) way. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be magnetic media (for example, floppy disk, hard disk, magnetic tape), optical media (for example, digital video disc (DVD)), or semiconductor media (for example, solid state disk (SSD)) and the like.

[0159] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part of the prior art that contributes to the technical solutions or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk and various media that can store program codes.

[0160] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A data transmission method, characterized in that, include: Receive uplink data sent by a first device, wherein the uplink data includes a first topic and a first message body; The scope corresponding to the uplink data is determined based on the device information of the first device, and the device information of the first device is obtained based on the device connection session information of the first device. The subscription objects of the first Topic are determined based on the Topic subscription relationships within the scope. The uplink data is sent to the subscription object of the first Topic; The device information of the first device includes the identifier of the first device, the identifier of the product to which the first device belongs, and the identifier of the user to which the product belongs; the scope includes the device scope, the product scope, and the user scope.

2. The method according to claim 1, characterized in that, Before determining the scope corresponding to the uplink data based on the device information of the first device, the method further includes: Based on the identifier of the first device and the device connection session information of the first device, the identifier of the product to which the first device belongs and the identifier of the user to which the product belongs are determined.

3. The method according to claim 1 or 2, characterized in that, The first device is a gateway sub-device; receiving uplink data sent by the first device includes: The gateway device receives encapsulated uplink data, which is obtained by the gateway device encapsulating uplink data sent by the gateway sub-device. The encapsulated uplink data includes a gateway Topic, a second message body, and the identifier of the gateway device. The second message body includes a first Topic, the first message body, and the identifier of the gateway sub-device. The encapsulated uplink data is unpacked based on the gateway Topic to obtain the second message body.

4. The method according to claim 1 or 2, characterized in that, The first device is a direct-connect device.

5. A data transmission method, characterized in that, include: Receive downlink data sent by the second device, wherein the downlink data includes a second topic, a third message body, and target device information; The scope corresponding to the downlink data is determined based on the target device information. The target device information includes at least one of the identifier of the target device, the identifier of the product to which the target device belongs, and the identifier of the user to which the product belongs. The scope includes the device scope, the product scope, and the user scope. The subscription objects of the second Topic are determined based on the Topic subscription relationships within the scope. If the target device is included in the subscription of the second Topic, the downlink data is sent to the target device.

6. The method according to claim 5, characterized in that, The target device is a gateway sub-device; sending the downlink data to the target device includes: The downlink data is encapsulated to obtain encapsulated downlink data, which includes a gateway Topic, a fourth message body, and an identifier of the gateway device. The fourth message body includes the second Topic, the third message body, and the identifier of the gateway sub-device. The encapsulated downlink data is sent to the gateway device, so that the gateway device can unpack the encapsulated downlink data based on the gateway topic, and send the unpacked second topic and the third message body to the gateway sub-device.

7. The method according to claim 5, characterized in that, The target device is a direct-connect device.

8. A data transmission method, characterized in that, include: Receive uplink data sent by the gateway sub-device, wherein the uplink data includes a first topic and a first message body; The uplink data is encapsulated to obtain encapsulated uplink data. The encapsulated uplink data includes a gateway Topic, a second message body, and an identifier of the gateway device. The second message body includes a first Topic, the first message body, and device information of the gateway sub-device. The device information of the gateway sub-device is obtained based on the connection session information of the gateway sub-device. The device information of the gateway sub-device includes the identifier of the gateway sub-device, the identifier of the product to which the gateway sub-device belongs, and the identifier of the user to which the product belongs. The encapsulated uplink data is sent to the IoT server, so that the IoT server can unpack the encapsulated uplink data based on the gateway Topic to obtain the second message body, determine the scope corresponding to the uplink data according to the device information of the gateway sub-device, determine the subscription object of the first Topic based on the Topic subscription relationship within the scope, and send the uplink data to the subscription object of the first Topic. The scope includes device scope, product scope and user scope.

9. A data transmission method, characterized in that, include: The system receives encapsulated downlink data sent by an IoT server. The encapsulated downlink data includes a gateway topic, a fourth message body, and an identifier of the gateway device. The fourth message body includes a second topic, a third message body, and an identifier of the gateway sub-device. The encapsulated downlink data is obtained by the IoT server encapsulating downlink data sent by a second device. The downlink data includes the second topic, the third message body, and gateway sub-device information. The gateway sub-device information is obtained based on the gateway sub-device connection session information. The gateway sub-device information includes the identifier of the gateway sub-device, the identifier of the product to which the gateway sub-device belongs, and the identifier of the user to which the product belongs. The gateway sub-device information is used to determine the scope corresponding to the downlink data. The scope includes a device scope, a product scope, and a user scope. The gateway Topic is used to unpack the encapsulated downlink data, and the unpacked second Topic and the third message body are sent to the gateway sub-device.

10. An Internet of Things (IoT) server, characterized in that, include: Memory and processor; The memory is used to store computer programs; The processor is configured to execute a computer program stored in the memory, wherein when the computer program is executed, the processor performs the method described in any one of claims 1-7.

11. A gateway device, characterized in that, include: Memory and processor; The memory is used to store computer programs; The processor is configured to execute a computer program stored in the memory, wherein the computer program, when executed, causes the processor to perform the method of claim 8 or 9.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the method as described in any one of claims 1-9.

13. A computer program product, characterized in that, The computer program product stores a computer program that, when executed by a processor, causes the processor to perform the method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Data processing method and device based on Internet of Things

    CN111970363A