Sensor networking method, apparatus, device, and storage medium
By broadcasting network access invitation data packets in the Bluetooth broadcast channel and switching working states, simplified networking of Bluetooth sensors and convenient terminal network access are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- RADIAWAVE TECH CO LTD
- Filing Date
- 2023-02-23
- Publication Date
- 2026-04-21
AI Technical Summary
The existing Bluetooth sensor networking process is cumbersome and terminal access is difficult.
When the operating state is broadcast, the network access invitation data packet is broadcast to the Bluetooth broadcast channel. The sensor terminal scans and responds with an authentication connection request. The gateway switches to the connected state and sends a network access confirmation command, and the sensor terminal joins the network.
It simplifies the networking process for Bluetooth sensors and solves the problem of difficult terminal network access.
Smart Images

Figure CN116193638B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication networking technology, and in particular to a sensor networking method, apparatus, device, and storage medium. Background Technology
[0002] In practical applications of Bluetooth sensors, Bluetooth terminals typically need to periodically upload sensor data to a gateway. Simultaneously, the gateway can send control commands to the terminal to perform related operations, such as switching on / off actions and parameter settings. To achieve these functions, Bluetooth sensor networking is required to enable communication between the Bluetooth sensors and the Bluetooth terminals.
[0003] Existing solutions can network Bluetooth sensors based on a mesh network structure for flood management, but the networking process in this way is cumbersome and it is difficult for terminals to join the network.
[0004] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this invention is to provide a sensor networking method, apparatus, device, and storage medium, aiming to solve the technical problems of complex networking process and difficulty in terminal network access in the existing Bluetooth sensor networking method.
[0006] To achieve the above objectives, the present invention provides a sensor networking method, which is applied to a gateway, and the method includes the following steps:
[0007] When the working state is broadcast mode, the network access invitation data packet is broadcast to the Bluetooth broadcast channel so that the sensor terminal scans the network access invitation data packet in the Bluetooth broadcast channel and sends back an authentication connection request based on the network access invitation data packet;
[0008] Upon receiving the authentication connection request, the working state is switched to the connected state;
[0009] Upon completion of the switchover, the system receives a network access response command sent by the sensor terminal.
[0010] Upon receiving the network access response instruction, a network access confirmation instruction is sent to the sensor terminal so that the sensor terminal can access the network upon receiving the network access confirmation instruction.
[0011] Optionally, the step of sending a network access confirmation instruction to the sensor terminal upon receiving the network access response instruction, so that the sensor terminal accesses the network upon receiving the network access confirmation instruction, includes:
[0012] Upon receiving the network access response command, the network virtual address corresponding to the sensor terminal is determined;
[0013] A network access confirmation command is generated based on the network virtual address, and the network access confirmation command is sent to the sensor terminal so that the sensor terminal can access the network upon receiving the network access confirmation command.
[0014] Accordingly, after the step of sending a network access confirmation command to the sensor terminal upon receiving the network access response command, so that the sensor terminal accesses the network upon receiving the network access confirmation command, the method further includes:
[0015] When a disconnection from the sensor terminal is detected, the local area network address corresponding to the sensor terminal and the network virtual address are stored in the network address mapping table;
[0016] Upon completion of storage, the operating state is switched to the broadcast state to await the network access of other sensor terminals.
[0017] Optionally, after the step of sending a network access confirmation instruction to the sensor terminal upon receiving the network access response instruction, so that the sensor terminal accesses the network upon receiving the network access confirmation instruction, the method further includes:
[0018] When the working mode is in online mode, the working state is switched to scanning mode;
[0019] Upon completion of the handover, scan the encrypted sensor terminal data packets broadcast by the sensor terminal from the Bluetooth broadcast channel;
[0020] The encrypted sensor terminal data packet is decrypted using the network decryption key to obtain the decrypted sensor data.
[0021] Optionally, after the step of switching the working state to the broadcast state upon completion of storage to wait for other sensor terminals to join the network, the method further includes:
[0022] The local area network address corresponding to the sensor terminal is obtained through the network address mapping table;
[0023] Send a Bluetooth connection request to the local area network address to establish a Bluetooth connection between the target sensor terminal corresponding to the local area network address;
[0024] Upon successful connection, downlink command data is sent to the Bluetooth broadcast channel so that the target sensor terminal can receive the downlink command data from the Bluetooth broadcast channel.
[0025] Furthermore, to achieve the above objectives, the present invention provides a sensor networking method, which is applied to a sensor terminal, and the sensor networking method includes:
[0026] When the network access process is triggered, the Bluetooth broadcast channel is scanned, and when a network access invitation data packet is detected, an authentication connection request is sent to the gateway based on the network access invitation data packet.
[0027] When the gateway accepts the authentication connection request, it switches its working state to the connected state;
[0028] Upon completion of the handover, a network access response command is sent to the gateway, so that the gateway can respond with a network access confirmation command upon receiving the network access response command.
[0029] Upon receiving the network access confirmation instruction, the device connects to the gateway.
[0030] Optionally, the step of sending an authentication connection request to the gateway based on the network access invitation data packet when the network access invitation data packet is scanned includes:
[0031] When a network access invitation data packet is detected, the network access invitation data packet is decrypted using the initial decryption key to obtain the target matching parameters;
[0032] Determine whether to join the network based on the target matching parameters and sensor parameters;
[0033] If so, an authentication connection request is sent to the gateway.
[0034] Optionally, after the step of accessing the gateway upon receiving the network access confirmation instruction, the method further includes:
[0035] When the working mode is on-network mode, the sensor data to be reported is encrypted using the network encryption key to obtain the encrypted sensor data packet.
[0036] The encrypted sensor data packet is broadcast to the Bluetooth broadcast channel, so that the gateway scans the encrypted sensor data packet in the Bluetooth broadcast channel and decrypts the encrypted sensor data packet using the on-network decryption key to obtain the decrypted sensor data.
[0037] Furthermore, to achieve the above objectives, the present invention also proposes a sensor networking device, the device comprising:
[0038] The data packet broadcast module is used to broadcast the network access invitation data packet to the Bluetooth broadcast channel when the working state is broadcast mode, so that the sensor terminal scans the network access invitation data packet in the Bluetooth broadcast channel and sends back an authentication connection request based on the network access invitation data packet;
[0039] A state switching module is used to switch the working state to the connected state when the authentication connection request is received;
[0040] The instruction receiving module is used to receive the network access response instruction sent by the sensor terminal when the handover is completed;
[0041] The instruction sending module is used to send a network access confirmation instruction to the sensor terminal when the network access response instruction is received, so that the sensor terminal can access the network when the network access confirmation instruction is received.
[0042] Furthermore, to achieve the above objectives, the present invention also proposes a sensor networking device, the device comprising: a memory, a processor, and a sensor networking program stored in the memory and executable on the processor, the sensor networking program being configured to implement the steps of the sensor networking method described above.
[0043] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing a sensor networking program, which, when executed by a processor, implements the steps of the sensor networking method described above.
[0044] This invention discloses a method where, in the broadcast state, a network access invitation data packet is broadcast to the Bluetooth broadcast channel, enabling the sensor terminal to scan for the network access invitation data packet in the Bluetooth broadcast channel and respond with an authentication connection request based on the network access invitation data packet. Upon receiving the authentication connection request, the operating state is switched to the connected state. Upon completion of the switch, a network access response command sent by the sensor terminal is received. Upon receiving the network access response command, a network access confirmation command is sent to the sensor terminal, enabling the sensor terminal to join the network upon receiving the network access confirmation command. Compared to the existing technology of networking Bluetooth sensors based on a mesh network structure managed by flooding, which involves a cumbersome networking process, this invention broadcasts the network access invitation data packet to the Bluetooth broadcast channel, enabling the sensor terminal to respond with an authentication connection request based on the network access invitation data packet. Upon receiving the authentication connection request, the operating state is switched to the connected state. While in the connected state and upon receiving the network access response command sent by the sensor terminal, the sensor terminal sends a network access confirmation command to the sensor terminal, enabling the sensor terminal to join the network upon receiving the network access confirmation command. This solves the technical problems of the complex networking process and difficulty in terminal network joining in the existing Bluetooth sensor networking methods. Attached Figure Description
[0045] Figure 1 This is a schematic diagram of the sensor networking equipment in the hardware operating environment involved in the embodiments of the present invention;
[0046] Figure 2This is a flowchart illustrating the first embodiment of the sensor networking method of the present invention;
[0047] Figure 3 This is a flowchart illustrating the second embodiment of the sensor networking method of the present invention;
[0048] Figure 4 This is a flowchart illustrating the third embodiment of the sensor networking method of the present invention;
[0049] Figure 5 This is a flowchart illustrating the fourth embodiment of the sensor networking method of the present invention;
[0050] Figure 6 This is a structural block diagram of the first embodiment of the sensor networking device of the present invention.
[0051] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0052] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0053] Reference Figure 1 , Figure 1 This is a schematic diagram of the sensor networking device structure in the hardware operating environment involved in the embodiments of the present invention.
[0054] like Figure 1 As shown, the sensor networking device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be high-speed random access memory (RAM) or stable non-volatile memory (NVM), such as a disk storage device. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0055] Those skilled in the art will understand that Figure 1The structure shown does not constitute a limitation on sensor networking equipment and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0056] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a sensor networking program.
[0057] exist Figure 1 In the sensor networking device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the sensor networking device of the present invention can be set in the sensor networking device, and the sensor networking device calls the sensor networking program stored in the memory 1005 through the processor 1001 and executes the sensor networking method provided in the embodiment of the present invention.
[0058] This invention provides a sensor networking method, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the sensor networking method of the present invention.
[0059] In this embodiment, the sensor networking method includes the following steps:
[0060] Step S10: When the working state is broadcast mode, broadcast the network access invitation data packet to the Bluetooth broadcast channel so that the sensor terminal scans the network access invitation data packet in the Bluetooth broadcast channel and sends back an authentication connection request based on the network access invitation data packet.
[0061] It should be noted that the execution subject of the method in this embodiment can be the gateway when Bluetooth sensors are networking.
[0062] It should be understood that the above-mentioned working state can be the current operating state of the gateway. The working state of the gateway can include broadcast state, connected state, and scanning state, etc., and this embodiment does not limit it.
[0063] It is understandable that the above broadcast state can be the state when the gateway broadcasts data packets.
[0064] It should be noted that the aforementioned network access invitation data packet can be data information broadcast by the gateway to the sensor terminal during network setup, such as the network encryption key and the types of sensor terminals that can join the network. In practical applications, when the gateway is in broadcast mode, the aforementioned network access invitation data packet can be obtained by encrypting the broadcast data of the network access broadcast packet. The original encryption key is built into the gateway and is used to encrypt subsequent network communication data in the factory-set, non-networked state, such as the SM4 algorithm.
[0065] It should be understood that the aforementioned Bluetooth broadcast channel can be an information channel for transmitting information via broadcast. In practical applications, a gateway can broadcast data packets to the Bluetooth broadcast channel for transmission.
[0066] It is understood that the aforementioned sensor terminal can be a Bluetooth Low Energy (BLE) sensor or other Bluetooth sensor terminal. This embodiment does not limit the specific type of sensor terminal.
[0067] It should be noted that the aforementioned authentication connection request can be a request sent by the sensor terminal to the gateway after confirming that it can join the network. In practical applications, after scanning the network access invitation data packet, the sensor terminal can decrypt the network access invitation data packet using the original decryption key to obtain the network key and matching parameters, in order to determine whether the sensor terminal can join the network. If it can, it can send the aforementioned authentication connection request back to the gateway.
[0068] In the implementation, both the gateway and the sensor terminal have a networking button and a networking LED. The LED flashes in networking mode and turns off in non-network mode. The sensor terminal automatically enters networking mode by default, with the LED flashing. Similarly, the gateway, by default, flashes its LED after pressing the networking button, initiating the networking process. After the networking process is initiated, the gateway can switch to broadcast mode and encrypt the broadcast data of the network access invitation packet using the original encryption key to obtain the network access invitation data packet. It then initiates the BLE broadcast process to broadcast the encrypted network access invitation data packet on the Bluetooth broadcast channel. Sensor terminals that need to join the network can switch to scanning mode after triggering the network access process. They scan the network access invitation data packet on the Bluetooth broadcast channel and decrypt it using the original decryption key to obtain the networking key and matching parameters. The networking key can be used to encrypt and decrypt new communication data generated after networking, and the matching parameters are used to match the sensor terminal's own parameters to determine whether the sensor terminal can join the network. For example, if the matching parameters include a network-accessible sensor terminal type of 0x01, then a sensor terminal with a type parameter of 0x02, upon receiving the data packet, will verify a type mismatch and will not continue the network access process. However, if a sensor terminal with a type parameter of 0x01 receives the data packet and verifies a type match, then that sensor terminal can continue the network access process. After confirming network access capability, the sensor terminal can send an authentication connection request to the gateway.
[0069] Step S20: Upon receiving the authentication connection request, switch the working state to the connected state.
[0070] It should be noted that the above connection state can refer to the state in which the gateway can establish a connection with the sensor terminal.
[0071] In the specific implementation, after the sensor terminal confirms that it can access the network, it can initiate a BLE-authenticated secure connection to the gateway. After the connection request is approved, both the sensor terminal and the gateway switch their working state to connected state. The gateway can control whether to approve the connection request by setting a whitelist or blacklist of MAC addresses of sensor terminals that can access the network, or other settings. If the MAC address of the sensor terminal is in the blacklist, the gateway will not approve the connection request; if the MAC address of the sensor terminal is in the whitelist, the gateway will approve the connection request.
[0072] Step S30: Upon completion of the handover, receive the network access response command sent by the sensor terminal.
[0073] It should be understood that the aforementioned network access response instruction can be a command sent by the gateway to the sensor terminal when in the connected state, indicating that the gateway and sensor terminal need to continue to access the network.
[0074] In a practical implementation, when the sensor terminal is in a connected state, it can send a network access response command to the gateway to indicate that the sensor terminal needs to continue to access the network.
[0075] Step S40: Upon receiving the network access response instruction, send a network access confirmation instruction to the sensor terminal so that the sensor terminal accesses the network upon receiving the network access confirmation instruction.
[0076] It is understandable that the aforementioned network access confirmation command may include parameters such as the network virtual address assigned to the sensor terminal, BLE connection time slice parameters, broadcast data packet encryption key, and BLE connection PIN code. After receiving the network access confirmation command, the sensor terminal can save the parameters carried in the command, complete the entire network access process, and actively disconnect from the gateway after network access. The BLE connection time slice parameter can be a parameter used to control the duration of BLE connection communication; the BLE connection PIN code can be a PIN code used to establish BLE connection pairing authentication.
[0077] It's important to note that in practical applications of Bluetooth sensors, the terminal typically needs to periodically upload sensor data to the gateway (uplink communication), while control commands sent from the gateway to the terminal (downlink communication), such as certain switching actions and parameter settings, are generally triggered only when needed. Uplink communication uses BLE broadcasting, and communication-related aspects include the broadcast data packet encryption key; downlink communication uses BLE connection, and communication-related aspects include the BLE connection PIN code and BLE connection time slice parameters.
[0078] Furthermore, to enable multiple sensor terminals to access the gateway, step S40 includes: upon receiving the network access response instruction, determining the network virtual address corresponding to the sensor terminal; generating a network access confirmation instruction based on the network virtual address, and sending the network access confirmation instruction to the sensor terminal, so that the sensor terminal accesses the network upon receiving the network access confirmation instruction; correspondingly, after step S40, the method further includes: upon detecting a disconnection from the sensor terminal, storing the local area network address corresponding to the sensor terminal and the network virtual address in a network address mapping table; upon completion of storage, switching the working state to the broadcast state to wait for other sensor terminals to access the network.
[0079] It should be understood that the aforementioned network virtual address can be the IP address of the sensor terminal, or other addresses with the same or similar functions as IP addresses, and this embodiment does not impose any restrictions on this. In practical applications, when the gateway receives the network access response command sent by the sensor terminal, it can determine the network virtual address assigned to the sensor terminal, generate a network access confirmation command based on the network virtual address, and then send the network access confirmation command to the sensor terminal.
[0080] It is understandable that the aforementioned network address mapping table can be a mapping table that stores the MAC address and network virtual address assigned by the gateway to the sensor terminal.
[0081] In its implementation, when the gateway receives a network access response command from a sensor terminal, it can reply with a network access confirmation command. This confirmation command includes parameters such as the assigned network virtual address, BLE connection time slice parameters, broadcast data packet encryption key, and BLE connection PIN code. Upon receiving the confirmation command, the sensor terminal saves the parameters, completes the network access process, and actively disconnects from the gateway. Simultaneously, the gateway stores the sensor terminal's corresponding LAN address and the aforementioned network virtual address in its network address mapping table and switches back to broadcast mode to respond to the next sensor terminal's network access request. Furthermore, if networking is not required, the gateway can exit networking mode and return to on-network mode by pressing the networking button again.
[0082] This embodiment discloses a method where, in the broadcast state, a network access invitation data packet is broadcast to the Bluetooth broadcast channel, enabling the sensor terminal to scan for the network access invitation data packet in the Bluetooth broadcast channel and respond with an authentication connection request based on the network access invitation data packet. Upon receiving the authentication connection request, the operating state is switched to the connected state. Upon completion of the switch, a network access response command sent by the sensor terminal is received. Upon receiving the network access response command, a network access confirmation command is sent to the sensor terminal, enabling the sensor terminal to join the network upon receiving the network access confirmation command. Compared to the existing technology of networking Bluetooth sensors based on a mesh network structure managed by flooding, which involves a cumbersome networking process, this embodiment broadcasts the network access invitation data packet to the Bluetooth broadcast channel, enabling the sensor terminal to respond with an authentication connection request based on the network access invitation data packet. Upon receiving the authentication connection request, the operating state is switched to the connected state. While in the connected state and upon receiving the network access response command sent by the sensor terminal, a network access confirmation command is sent to the sensor terminal, enabling the sensor terminal to join the network upon receiving the network access confirmation command. This solves the technical problems of the complex networking process and difficulty in terminal network joining in the existing Bluetooth sensor networking methods.
[0083] refer to Figure 3 , Figure 3This is a flowchart illustrating the second embodiment of the sensor networking method of the present invention.
[0084] Based on the first embodiment described above, in order to upload the sensor data from the sensor terminal to the gateway, in this embodiment, after step S40, the method further includes:
[0085] Step S411: When the working mode is in the network mode, switch the working state to the scanning state.
[0086] It should be noted that the gateway can operate in two modes: on-network mode and network mode. On-network mode allows communication between the gateway and sensor terminals, while network mode allows them to form a network.
[0087] Step S412: When the switching is complete, scan the encrypted sensor terminal data packets broadcast by the sensor terminal from the Bluetooth broadcast channel.
[0088] It should be understood that the aforementioned sensor terminal data packet can be a data packet obtained by encrypting the sensor data that needs to be reported.
[0089] Step S413: Decrypt the encrypted sensor terminal data packet using the network decryption key to obtain the decrypted sensor data.
[0090] It is understandable that the aforementioned online decryption key can be a decryption key generated by the gateway using parameters such as the sensor terminal's UUID (128-bit unique device identifier) and random numbers, based on a software algorithm, during the sensor terminal's network access process. This key is then stored in the device's data storage area.
[0091] It should be understood that the aforementioned sensor data may include sensor type, sensor address, etc., and this embodiment does not impose any restrictions on this.
[0092] In practical implementation, when the sensor is in network mode, its working state is in broadcast mode. At this time, the sensor data to be reported can be encrypted using the network encryption key allocated during network setup to obtain the encrypted sensor terminal data packet. The encrypted sensor terminal data packet is then broadcast in the Bluetooth broadcast channel. When the gateway is in network mode, it can enter scanning mode and scan for the encrypted sensor terminal data packet in the Bluetooth broadcast channel. After scanning the encrypted sensor terminal data packet, it can decrypt the encrypted sensor terminal data packet using the network decryption key to obtain the decrypted sensor data.
[0093] In this embodiment, when the working mode is in the network mode, the working state is switched to the scanning state. When the switch is completed, the encrypted sensor terminal data packets broadcast by the sensor terminal are scanned from the Bluetooth broadcast channel, and the encrypted sensor terminal data packets are decrypted using the network decryption key to obtain the decrypted sensor data. Thus, the sensor terminal can upload sensor data to the gateway, realizing uplink communication between the gateway and the sensor terminal.
[0094] refer to Figure 4 , Figure 4 This is a flowchart illustrating the third embodiment of the sensor networking method of the present invention.
[0095] Based on the above embodiments, in order for the gateway to send control commands to the sensor terminal, in this embodiment, after step S40, the method further includes:
[0096] Step S421: Obtain the local area network address corresponding to the sensor terminal through the network address mapping table.
[0097] It should be noted that since the network address mapping table stores the local area network address and the virtual network address corresponding to the sensor terminal, the local area network address corresponding to the sensor terminal can be obtained from the network address mapping table.
[0098] Step S422: Send a Bluetooth connection request to the local area network address to establish a Bluetooth connection between the target sensor terminal corresponding to the local area network address.
[0099] It should be understood that the aforementioned Bluetooth connection request is the same as the BLE connection (Bluetooth connection) request. In practical applications, after obtaining the local area network address corresponding to the sensor terminal, the gateway can initiate a BLE connection to that address. After the sensor terminal corresponding to that address is authenticated via PIN code, the gateway and the sensor terminal can establish a BLE connection. The PIN code authentication can be a standard BLE connection pairing authentication.
[0100] It is understandable that the aforementioned target sensor terminal can be a terminal that the gateway needs to send control commands to.
[0101] Step S423: Upon successful connection, send downlink command data to the Bluetooth broadcast channel so that the target sensor terminal receives the downlink command data from the Bluetooth broadcast channel.
[0102] It is understandable that the aforementioned downlink command data can be control command data sent by the gateway to the sensor terminal. The downlink command data has different command definitions depending on the type of sensor, including: control commands: such as on / off commands (e.g., for smoke alarm sensors, used to turn on and off); setting commands: such as parameter setting commands (e.g., for temperature and humidity sensors, setting the data acquisition time interval).
[0103] In its implementation, when the gateway is in network-enabled mode, it operates in a scanning state. When it needs to send downlink command data to a sensor terminal, it obtains the corresponding LAN address of the sensor terminal through a network address mapping table and initiates a BLE connection to that LAN address. After the sensor terminal authenticates via PIN code, the gateway and the sensor terminal can establish a BLE connection. In BLE connection mode, the gateway sends downlink command data in the Bluetooth broadcast channel, and the sensor terminal receives downlink command data in the Bluetooth broadcast channel and sends a reply. After the agreed communication time slice with the gateway is completed, the gateway disconnects the BLE connection, and the sensor terminal returns to the broadcast state. If the gateway needs to send downlink command data to multiple sensor terminals simultaneously, it can maintain BLE connection communication between multiple sensor terminals according to the set maximum concurrent connection number, and disconnect the BLE connection to release communication resources.
[0104] In this embodiment, the local area network address corresponding to the sensor terminal is obtained through a network address mapping table, and a Bluetooth connection request is sent to the local area network address to establish a Bluetooth connection with the target sensor terminal. When the connection is successful, downlink command data is sent to the Bluetooth broadcast channel so that the target sensor terminal can receive downlink command data from the Bluetooth broadcast channel. Thus, the gateway can send control commands to the sensor terminal, realizing downlink communication between the gateway and the sensor terminal.
[0105] refer to Figure 5 , Figure 5 This is a flowchart illustrating the fourth embodiment of the sensor networking method of the present invention.
[0106] Based on the above embodiments, a fourth embodiment of the sensor networking method of the present invention is proposed.
[0107] In this embodiment, the sensor networking method includes the following steps:
[0108] Step S100: When the network access process is triggered, the Bluetooth broadcast channel is scanned, and when a network access invitation data packet is detected, an authentication connection request is sent to the gateway based on the network access invitation data packet.
[0109] It should be noted that the subject executing the method in this embodiment can be a sensor terminal that needs to be networked.
[0110] It should be understood that the step of sending an authentication connection request to the gateway based on the network access invitation data packet when the network access invitation data packet is scanned includes: decrypting the network access invitation data packet using an initial decryption key to obtain target matching parameters when the network access invitation data packet is scanned; determining whether to access the network based on the target matching parameters and sensor parameters; and if so, sending an authentication connection request to the gateway.
[0111] It is understood that the aforementioned initial decryption key can be the key that comes with the sensor terminal and is used to decrypt subsequent network communication data when the device is not networked at the factory. For example, it can be decrypted using the SM4 algorithm. This embodiment does not limit this.
[0112] It should be noted that the target matching parameters mentioned above can be used to verify whether a sensor terminal can access the gateway. In practical applications, if the target matching parameters include a network-accessible sensor type of 0x01, then a sensor with a type parameter of 0x02 will receive this data packet, verify a type mismatch, and the sensor terminal will not continue the network access process.
[0113] In the specific implementation, if the sensor terminal needs to join the network, after triggering the network joining process, its working state can be switched to scanning state, and it can scan in the Bluetooth broadcast channel. After scanning the network joining invitation data packet, it can decrypt the network joining invitation data packet with the initial decryption key to obtain the corresponding matching parameters and sensor parameters, and determine whether it can join the network. If it can, it sends an authentication connection request to the gateway.
[0114] Step S200: When the gateway accepts the authentication connection request, the working state is switched to the connected state.
[0115] It should be understood that the gateway can determine whether to approve the connection request from the sensor terminal based on a pre-defined whitelist or blacklist of the sensor terminal's MAC address. When the gateway approves the sensor's connection request, it can switch its working state to connected state.
[0116] Step S300: When the handover is complete, send a network access response command to the gateway so that the gateway can send back a network access confirmation command upon receiving the network access response command.
[0117] Step S400: Upon receiving the network access confirmation instruction, access the gateway.
[0118] In the specific implementation, after the sensor terminal switches to connected mode, it can send a network access response command to the gateway. Upon receiving the network access response command, the gateway can reply with a network access confirmation command. This confirmation command includes parameters such as the assigned network virtual address, BLE connection time slice parameters, broadcast data packet encryption key, and BLE connection PIN code. After receiving the confirmation command, the sensor terminal saves the parameters contained in the command and completes the normal network access process, i.e., connects to the gateway.
[0119] Furthermore, in order to upload sensor data from the sensor terminal to the gateway, after step S400, the method further includes: when the working mode is in the online mode, encrypting the sensor data to be reported using the online encryption key to obtain an encrypted sensor data packet; broadcasting the encrypted sensor data packet to the Bluetooth broadcast channel, so that the gateway scans the encrypted sensor data packet in the Bluetooth broadcast channel and decrypts the encrypted sensor data packet using the online decryption key to obtain the decrypted sensor data.
[0120] It is understandable that the aforementioned network encryption key can be an encryption key generated by the gateway using parameters such as the device's UUID (128-bit unique device identifier) and random numbers, based on a software algorithm, during the sensor terminal's network access process. This key is then stored in the device's data storage area.
[0121] This embodiment discloses a method for scanning the Bluetooth broadcast channel when triggering the network access process, and sending an authentication connection request to the gateway based on the network access invitation data packet when the network access invitation data packet is detected. When the gateway accepts the authentication connection request, the working state is switched to the connected state. When the switch is complete, a network access response command is sent to the gateway so that the gateway can respond with a network access confirmation command when it receives the network access response command. When the network access confirmation command is received, the device accesses the gateway. Because this embodiment sends the authentication connection request to the gateway based on the network access invitation data packet scanned in the Bluetooth broadcast channel, switches to the connected state when the gateway accepts the authentication connection request, and sends a network access response command to the gateway in the connected state, so that the device accesses the gateway when it receives the network access confirmation command from the gateway, this solves the technical problem that the networking process of Bluetooth sensors in the prior art is relatively complex and the terminal network access is difficult.
[0122] Furthermore, this embodiment of the invention also proposes a storage medium storing a sensor networking program, which, when executed by a processor, implements the steps of the sensor networking method described above.
[0123] Reference Figure 6 , Figure 6 This is a structural block diagram of the first embodiment of the sensor networking device of the present invention.
[0124] like Figure 6 As shown, the sensor networking device proposed in this embodiment of the invention includes:
[0125] The data packet broadcasting module 601 is used to broadcast the network access invitation data packet to the Bluetooth broadcast channel when the working state is broadcast mode, so that the sensor terminal scans the network access invitation data packet in the Bluetooth broadcast channel and feeds back the authentication connection request based on the network access invitation data packet;
[0126] The state switching module 602 is used to switch the working state to the connected state when the authentication connection request is received;
[0127] The instruction receiving module 603 is used to receive the network access response instruction sent by the sensor terminal when the handover is completed;
[0128] The instruction sending module 604 is used to send a network access confirmation instruction to the sensor terminal when the network access response instruction is received, so that the sensor terminal can access the network when the network access confirmation instruction is received.
[0129] This embodiment of the sensor networking device discloses that, when the working state is broadcast mode, it broadcasts a network access invitation data packet to the Bluetooth broadcast channel, so that the sensor terminal scans for the network access invitation data packet in the Bluetooth broadcast channel and sends back an authentication connection request based on the network access invitation data packet; when the authentication connection request is received, the working state is switched to connected mode; when the switch is completed, the device receives a network access response command sent by the sensor terminal; when the network access response command is received, the device sends a network access confirmation command to the sensor terminal, so that the sensor terminal joins the network when it receives the network access confirmation command. Compared with the prior art of networking Bluetooth sensors based on a mesh network structure of flood management, which is cumbersome, this embodiment broadcasts the network access invitation data packet to the Bluetooth broadcast channel, so that the sensor terminal sends back an authentication connection request based on the network access invitation data packet, switches the working state to connected mode when it receives the authentication connection request, and sends a network access confirmation command to the sensor terminal when it is in connected mode and receives a network access response command sent by the sensor terminal, so that the sensor terminal joins the network when it receives the network access confirmation command. This solves the technical problems of the complex networking process and difficulty in terminal network joining in the prior art of Bluetooth sensor networking.
[0130] Other embodiments or specific implementations of the sensor networking device of the present invention can be referred to the above-described method embodiments, and will not be repeated here.
[0131] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0132] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0133] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0134] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A sensor networking method, characterized in that, The sensor networking method is applied to a gateway, and the sensor networking method includes: When the working state is broadcast mode, the broadcast data of the network access broadcast packet is encrypted with the original encryption key corresponding to the SM4 algorithm to obtain the network access invitation data packet. The network access invitation data packet is broadcast to the Bluetooth broadcast channel so that the sensor terminal scans the network access invitation data packet in the Bluetooth broadcast channel and decrypts the network access invitation data packet with the initial decryption key to obtain the target matching parameters. After comparing it with its own sensor parameters, it sends back an authentication connection request. Upon receiving the authentication connection request, the system determines whether to approve the authentication connection request based on a preset whitelist or blacklist of network-accessible sensor terminal MAC addresses; if approved, the system switches the working state to the connected state. Upon completion of the switchover, the system receives a network access response command sent by the sensor terminal. Upon receiving the network access response command, the network virtual address corresponding to the sensor terminal is determined; A network access confirmation command is generated based on the network virtual address, and the network access confirmation command is sent to the sensor terminal so that the sensor terminal can access the network upon receiving the network access confirmation command. When a disconnection from the sensor terminal is detected, the local area network address corresponding to the sensor terminal and the network virtual address are stored in the network address mapping table; Upon completion of storage, the operating state is switched to the broadcast state to await the network access of other sensor terminals; When the working mode is in online mode, the working state is switched to scanning mode; Upon completion of the handover, scan the encrypted sensor terminal data packets broadcast by the sensor terminal from the Bluetooth broadcast channel; The encrypted sensor terminal data packet is decrypted using the network decryption key to obtain the decrypted sensor data.
2. The sensor networking method as described in claim 1, characterized in that, After the step of switching the working state to the broadcast state upon completion of storage to wait for other sensor terminals to join the network, the method further includes: The local area network address corresponding to the sensor terminal is obtained through the network address mapping table; Send a Bluetooth connection request to the local area network address to establish a Bluetooth connection between the target sensor terminal corresponding to the local area network address; Upon successful connection, downlink command data is sent to the Bluetooth broadcast channel so that the target sensor terminal can receive the downlink command data from the Bluetooth broadcast channel.
3. A sensor networking device, characterized in that, The device includes: The data packet broadcasting module is used to obtain a network access invitation data packet by encrypting the broadcast data of the network access broadcast packet with the original encryption key corresponding to the SM4 algorithm when the working state is broadcast. The network access invitation data packet is broadcast to the Bluetooth broadcast channel so that the sensor terminal scans the network access invitation data packet in the Bluetooth broadcast channel and decrypts the network access invitation data packet with the initial decryption key to obtain the target matching parameters. After comparing the parameters with its own sensor parameters, it sends back an authentication connection request. The state switching module is used to determine whether to accept the authentication connection request based on a preset whitelist or blacklist of MAC addresses of network-accessible sensor terminals when the authentication connection request is received; if accepted, the working state is switched to the connected state. The instruction receiving module is used to receive the network access response instruction sent by the sensor terminal when the handover is completed; The instruction sending module is used to determine the network virtual address corresponding to the sensor terminal when receiving the network access response instruction; generate a network access confirmation instruction based on the network virtual address, and send the network access confirmation instruction to the sensor terminal, so that the sensor terminal accesses the network when it receives the network access confirmation instruction; When the device detects a disconnection from the sensor terminal, it stores the local area network address and the network virtual address corresponding to the sensor terminal in the network address mapping table; upon completion of storage, it switches the working state to the broadcast state to wait for other sensor terminals to join the network. When the working mode is in online mode, the working state is switched to scanning mode; Upon completion of the handover, scan the encrypted sensor terminal data packets broadcast by the sensor terminal from the Bluetooth broadcast channel; The encrypted sensor terminal data packet is decrypted using the network decryption key to obtain the decrypted sensor data.
4. A sensor networking device, characterized in that, The device includes: a memory, a processor, and a sensor networking program stored in the memory and executable on the processor, the sensor networking being configured to implement the steps of the sensor networking method as described in claim 1 or 2.
5. A storage medium, characterized in that, The storage medium stores a sensor networking program, which, when executed by a processor, implements the steps of the sensor networking method as described in claim 1 or 2.
Citation Information
Patent Citations
Smart home equipment authentication method, device, equipment, system and storage medium
CN114301628A