Bluetooth device access method, Bluetooth gateway and system
By receiving preset configuration protocols and monitoring Bluetooth device broadcast packets, the problem that existing Bluetooth gateway devices can only access fixed Bluetooth devices is solved, and flexible and efficient access to Bluetooth devices is achieved, improving access efficiency and reducing costs.
Patent Information
- Application Number
- CN202411949458.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-05-06
AI Technical Summary
Existing Bluetooth gateway devices can only access fixed Bluetooth devices. If you need to access a new Bluetooth device, you need to upgrade the gateway's access function, resulting in low access efficiency and high cost.
By receiving the preset configuration protocol sent by the client, the Bluetooth device is monitored, the device's configuration information is determined, and the preset configuration protocol is matched. If it matches, the Bluetooth device is allowed to access the Bluetooth gateway.
It realizes flexible and efficient access to Bluetooth devices, improves the efficiency of accessing new devices, reduces access costs, and simplifies access methods.
Smart Images

Figure CN119946771A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Bluetooth, and in particular to an access method for Bluetooth equipment, a Bluetooth gateway and a system. Background Art
[0002] A Bluetooth gateway is a product that enables Bluetooth devices to connect to the Internet. The Bluetooth gateway is connected to the Bluetooth device via Bluetooth, and the Bluetooth gateway is connected to the Internet via wired or wireless connection. Therefore, the Bluetooth device accesses the Internet through the Bluetooth gateway.
[0003] Generally, after leaving the factory, Bluetooth gateway devices can only connect to fixed Bluetooth devices. If other new Bluetooth devices need to be connected to the Bluetooth gateway, it is necessary to develop the Bluetooth gateway again and upgrade the access function of the Bluetooth gateway. In addition, each Bluetooth gateway leaving the factory needs to be upgraded, resulting in low access efficiency and high access cost. Summary of the invention
[0004] An object of the embodiments of the present invention is to provide a method for accessing a Bluetooth device, a Bluetooth gateway, and a system, which can access a new Bluetooth device more flexibly and efficiently.
[0005] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0006] In a first aspect, an embodiment of the present invention provides a method for accessing a Bluetooth device, which is applied to a Bluetooth gateway. The method includes:
[0007] Receiving a preset configuration protocol sent by a client;
[0008] Monitor the broadcast packets of Bluetooth devices;
[0009] Determine the configuration information of the Bluetooth device according to the broadcast packet;
[0010] Determining whether the configuration information matches the preset configuration protocol;
[0011] If they match, the Bluetooth device is connected to the Bluetooth gateway.
[0012] Optionally, determining the configuration information of the Bluetooth device according to the broadcast packet includes:
[0013] Determine the type of the Bluetooth device according to the broadcast packet;
[0014] Determining whether the type of the Bluetooth device matches the preset type in the preset configuration protocol;
[0015] If yes, and the type of the Bluetooth device is a connection type, obtaining the name of the Bluetooth device in the broadcast packet, determining whether the name of the Bluetooth device is consistent with the preset name in the preset configuration protocol, and if they are consistent, establishing a connection with the Bluetooth device and reading the first configuration information of the Bluetooth device;
[0016] If yes, and the type of the Bluetooth device is a broadcast type, the second configuration information of the Bluetooth device is obtained from the broadcast packet.
[0017] Optionally, the reading the first configuration information of the Bluetooth device includes:
[0018] Sending a query instruction to the Bluetooth device;
[0019] The first configuration information returned by the Bluetooth device according to the query instruction is received, wherein the first configuration information includes a first service identifier supported by the Bluetooth device, a data sending attribute of the Bluetooth device, and a data reading attribute of the Bluetooth device.
[0020] Optionally, the determining whether the configuration information matches the preset configuration protocol includes:
[0021] Obtaining a preset service identifier in the preset configuration protocol;
[0022] Determining whether the first service identifier is consistent with the preset service identifier;
[0023] If they are consistent, it is determined whether the first configuration information matches the preset configuration protocol according to the data sending attribute and the data reading attribute.
[0024] Optionally, determining whether the first configuration information matches the preset configuration protocol according to the data sending attribute and the data reading attribute includes:
[0025] Determine whether there is a read data configuration requirement in the preset configuration protocol;
[0026] If so, determining whether the Bluetooth device supports data being read according to the data being read attribute of the Bluetooth device, and if so, determining that the first configuration information matches the preset configuration protocol; or,
[0027] Determine whether there is a configuration requirement for receiving data in the preset configuration protocol;
[0028] If so, determining whether the Bluetooth device supports data transmission according to the data transmission attribute of the Bluetooth device, and if so, determining that the first configuration information matches the preset configuration protocol; or,
[0029] Determine whether there is a configuration requirement for reading data and receiving data in the preset configuration protocol;
[0030] If both exist, determine whether the Bluetooth device supports reading data based on the data reading attribute of the Bluetooth device, and determine whether the Bluetooth device supports sending data based on the data sending attribute of the Bluetooth device. If both are supported, determine that the first configuration information matches the preset configuration protocol.
[0031] Optionally, the method further comprises:
[0032] If not matched, the connection with the Bluetooth device is disconnected.
[0033] Optionally, the second configuration information includes a second service identifier supported by the Bluetooth device, and the determining whether the configuration information matches the preset configuration protocol further includes:
[0034] Obtaining a preset service identifier in the preset configuration protocol;
[0035] Determining whether the second service identifier matches the preset service identifier;
[0036] If they match, it is determined that the second configuration information matches the preset configuration protocol.
[0037] Optionally, the method further comprises:
[0038] Receiving a configuration instruction sent by the client;
[0039] According to the configuration instruction, its own communication mode is configured to be a monitoring broadcast mode.
[0040] In a second aspect, an embodiment of the present invention provides a Bluetooth gateway, comprising at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the access method of the Bluetooth device as described above.
[0041] In a third aspect, an embodiment of the present invention provides an access system for a Bluetooth device, comprising: a Bluetooth device, a client, and the Bluetooth gateway as described above, wherein the Bluetooth gateway is communicatively connected with the client.
[0042] Based on the above technical solution, an embodiment of the present invention provides a method for accessing a Bluetooth device, which is applied to a Bluetooth gateway. The method includes first receiving a preset configuration protocol sent by a client, then monitoring a broadcast packet of a Bluetooth device, and determining the configuration information of the Bluetooth device according to the broadcast packet, and determining whether the configuration information matches the preset configuration protocol. If it matches, the Bluetooth device accesses the Bluetooth gateway. The method modifies the configuration of the Bluetooth gateway through a preset configuration protocol, so that Bluetooth devices that comply with the preset configuration protocol can be quickly accessed, thereby improving the efficiency of accessing new Bluetooth devices. Moreover, the method realizes the function of accessing different Bluetooth devices by configuring different preset configuration protocols, without the need to redevelop a Bluetooth gateway, thus saving the cost of Bluetooth device access, and making the access method simpler and more flexible. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0044] Figure 1 is a schematic diagram of an access system for a Bluetooth device provided by an embodiment of the present invention;
[0045] Figure 2 It is a schematic diagram of the hardware structure of a Bluetooth gateway provided by an embodiment of the present invention;
[0046] Figure 3 It is a flowchart of a method for accessing a Bluetooth device provided by an embodiment of the present invention;
[0047] Figure 4 yes Figure 3 Schematic diagram of the process of step S13;
[0048] Figure 5 yes Figure 4 Schematic diagram of the process of step S133;
[0049] Figure 6 yes Figure 3 Schematic diagram of the process of step S14;
[0050] Figure 7 yes Figure 3 Another schematic diagram of the process of step S14;
[0051] Figure 8 It is a structural schematic diagram of an access device for a Bluetooth device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0053] It should be noted that, if there is no conflict, the various features in the embodiments of the present application can be combined with each other, all within the scope of protection of the present application. In addition, although the functional module division is performed in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a sequence different from the module division in the device or the flow chart. Furthermore, the words "first", "second", "third", etc. used in this application do not limit the data and execution order, but only distinguish the same items or similar items with basically the same functions and effects.
[0054] See also Figure 1 , Figure 1 It is a structural diagram of an access system for a Bluetooth device provided in an embodiment of the present application. The access system 100 includes a Bluetooth device 10, a client 20 and a Bluetooth gateway 30, wherein the Bluetooth gateway 30 is in communication connection with the client 20.
[0055] The Bluetooth gateway 30 is a device that is usually connected to the Internet via wired (Ethernet) or wireless (Wi-Fi, cellular network, etc.) means, and the Bluetooth gateway 30 is connected to the Bluetooth device 10 via Bluetooth technology. The Bluetooth gateway 30 can scan and connect to nearby Bluetooth devices 10 (such as sensors, health monitoring devices, smart phones, tablets, headphones, etc.).
[0056] The Bluetooth gateway 30 is connected to the Bluetooth device 10 via Bluetooth technology. The Bluetooth gateway 30 uploads the data collected from the Bluetooth device 10 to the cloud, such as a server or cloud platform on the Internet, via a wired or wireless connection. At the same time, the Bluetooth gateway 30 can also receive data from the Internet and forward it to the Bluetooth device 10 to achieve two-way data exchange. Therefore, the main function of the Bluetooth gateway 30 is to bridge the Bluetooth device 10 with a wider network to achieve data transmission and communication.
[0057] The Bluetooth gateway 30 and the client 20 are connected to each other by wired or wireless communication. The client 20 sends a configuration command to the Bluetooth gateway 30 to configure the Bluetooth gateway 30 and set the working mode of the Bluetooth gateway 30 or the access mode between the Bluetooth gateway 30 and the Bluetooth device 10.
[0058] The client 20 provided in the embodiment of the present invention may be any suitable type of electronic device with computing capabilities, such as a server, a desktop computer, a smart phone, a tablet computer, and other electronic products.
[0059] Generally, after leaving the factory, Bluetooth gateway devices can only connect to fixed Bluetooth devices. For example, if a Bluetooth gateway cooperates with a supplier to provide three fixed Bluetooth devices, the Bluetooth gateway can only connect these three devices to the terminal's APP or cloud platform. After the Bluetooth gateway leaves the factory, if a new Bluetooth device needs to be connected to the Bluetooth gateway, it is necessary to develop the Bluetooth gateway again, upgrade the access function of the Bluetooth gateway, and upgrade each Bluetooth gateway. The access efficiency is low and the access cost is also high.
[0060] Based on the above reasons, an embodiment of the present application provides a method for accessing a Bluetooth device, which is applied to a Bluetooth gateway. The method includes first receiving a preset configuration protocol sent by a client, then monitoring a broadcast packet of the Bluetooth device, and determining configuration information of the Bluetooth device based on the broadcast packet, and determining whether the configuration information matches the preset configuration protocol. If so, the Bluetooth device accesses the Bluetooth gateway, and data interaction is performed between the Bluetooth gateway and the Bluetooth device.
[0061] The method modifies the configuration of the Bluetooth gateway through a preset configuration protocol, so that Bluetooth devices that comply with the preset configuration protocol can be quickly accessed, thereby improving the efficiency of accessing new Bluetooth devices. In addition, the method realizes the function of accessing different Bluetooth devices by configuring different preset configuration protocols, without the need to redevelop the Bluetooth gateway, saving the cost of Bluetooth device access, and making the access method simpler and more flexible.
[0062] Please also read Figure 2 The Bluetooth gateway 30 includes at least one processor 301 (connected via a system bus or other communication methods) Figure 2 In the figure, a processor is taken as an example) and a memory 302.
[0063] Among them, the memory 302 stores instructions that can be executed by the at least one processor 301, and the instructions are executed by the at least one processor 301. The processor 301 is used to provide computing and control capabilities to control the Bluetooth gateway 30 to execute relevant commands, for example, to control the Bluetooth gateway 30 to execute any one of the access methods for Bluetooth devices provided in the following embodiments of the present application.
[0064] The memory 302, as a non-transient computer-readable storage medium, can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the access method of the Bluetooth device provided in the following embodiments of the present application. The processor 301 can implement the access method of the Bluetooth device in any of the following method embodiments by running the non-transient software programs, instructions and modules stored in the memory 302. Specifically, the memory 302 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 302 may also include a memory remotely arranged relative to the processor 301, and these remote memories may be connected to the processor 301 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0065] See also Figure 3 , Figure 3 is a flow chart of a method for accessing a Bluetooth device provided in an embodiment of the present application, such as Figure 3 As shown, the Bluetooth device access method S100 includes:
[0066] S11: receiving a preset configuration protocol sent by the client;
[0067] For Bluetooth devices with different configurations, different preset configuration protocols need to be written into the Bluetooth gateway. The preset configuration protocols vary depending on the Bluetooth devices that are allowed to access.
[0068] The preset configuration protocol specifies how the Bluetooth gateway discovers Bluetooth devices and how to obtain data from Bluetooth devices after the Bluetooth gateway establishes a connection with the Bluetooth device. The preset configuration protocol also specifies whether the Bluetooth devices allowed to access actively report data or passively report data, as well as the types of Bluetooth devices allowed to access, such as whether the Bluetooth devices allowed to access are connected devices (beacon devices) or broadcast devices (i beacon devices).
[0069] The preset configuration protocol specifies various conditions that a Bluetooth device must meet to access the Bluetooth gateway. Only Bluetooth devices that meet the relevant provisions of the preset configuration protocol can access the Bluetooth gateway.
[0070] The specific format of the preset configuration protocol can be set as needed. In the embodiment of the present application, the format of the preset configuration protocol is shown in Table 1:
[0071]
[0072] For example, the preset configuration protocol is {"cmd":"beacon","name":"_SWS_","service":"55e404d2af9fa98fe54a7dfe43535355","read":"","not if":"16962447c62361bad94b4d1e43535349","pid":"059cc0000"}.
[0073] This means that the Bluetooth device that wants to access the Bluetooth gateway must meet the following conditions: connected device, named "_SWS_", supported service identifier "55e404d2af9fa98fe54a7dfe43535355", does not support reading data, must support active reporting of data, and the product number is "059cc0000".
[0074] For another example: the preset configuration protocol is {"cmd":"i beacon","name":"_BUT","service":"FDA50693A4E24FB1AFCFC6EB0764","read":"","not if":"","pid":"059cc0000"}.
[0075] This means that the Bluetooth device that wants to access the Bluetooth gateway must meet the following conditions: broadcast type device, named "_BUT", supported service identifier "FDA50693A4E24FB1AFCFC6EB0764", does not support reading data, must support active reporting of data, and the product number is "059cc0000".
[0076] Through the preset configuration protocol, the configuration and type of the Bluetooth device to be connected to the Bluetooth gateway can be set. Therefore, through different preset configuration protocols, the Bluetooth gateway can be able to access multiple different Bluetooth devices.
[0077] The preset configuration protocol is written by the client. For example, if the client is a mobile phone terminal, a connection is established with the Bluetooth gateway through the Bluetooth function of the mobile phone terminal APP, and the configuration of the Bluetooth gateway is modified, added or deleted through the mobile phone terminal APP. Therefore, the preset configuration protocol can be written into the Bluetooth gateway through the mobile phone terminal APP, so that the Bluetooth gateway receives and stores the preset configuration protocol.
[0078] The preset configuration protocol may be written during the production phase of the Bluetooth gateway, during the use of the Bluetooth gateway, or during other periods when a new Bluetooth device needs to be connected. The embodiments of the present application do not impose any restrictions on this.
[0079] S12: monitor the broadcast packets of Bluetooth devices;
[0080] There are two communication modes for Bluetooth gateways, one is the broadcast mode (Broadcast Mode) and the other is the observation mode (Observation Procedure). In the broadcast mode, the Bluetooth gateway acts as a broadcaster (Broadcaster) and periodically sends broadcast data packets (broadcast packets) to surrounding devices. These data packets can be received by any device within the range and in the monitoring state. The broadcast mode is mainly used for connectionless one-to-many information transmission, such as device discovery, information push services, etc., to actively send broadcasts to other devices.
[0081] In the monitoring broadcast mode, the Bluetooth gateway acts as an observer, actively searches for broadcast signals from surrounding devices, monitors and reads broadcast data in the air. The monitoring broadcast mode is often used in data acquisition concentrator applications, such as sensor concentrator acquisition and other functions.
[0082] In order to actively search for broadcast packets sent by new Bluetooth devices, in the embodiment of the present application, the working mode of the Bluetooth gateway is configured to the monitoring broadcast mode by the client. Specifically, the Bluetooth gateway receives the configuration instruction sent by the client, and then configures its own communication mode to the monitoring broadcast mode according to the configuration instruction.
[0083] S13: Determine the configuration information of the Bluetooth device according to the broadcast packet;
[0084] After the Bluetooth gateway turns on the monitoring broadcast mode, it actively starts to monitor the broadcast packets of the surrounding Bluetooth devices. The broadcast packets of Bluetooth devices are data packets used by Bluetooth devices to discover devices and publish data. They are composed of several broadcast data units. Each broadcast data unit includes the length of the broadcast data unit, the type of the broadcast data unit, such as the device name, etc., as well as data, service lists, etc. The service list includes various services supported by the Bluetooth device and the service identifiers corresponding to each service.
[0085] Therefore, the basic properties, service list, service identification and other configuration information of the Bluetooth device can be obtained through the broadcast packet. The Bluetooth gateway matches the configuration information of the Bluetooth device with the preset configuration protocol. Only Bluetooth devices that match the preset configuration protocol can access the Bluetooth gateway.
[0086] For different types of Bluetooth devices, the Bluetooth gateway obtains configuration information in different ways, such as Figure 4 As shown, step S13 includes:
[0087] S131: Determine the type of the Bluetooth device according to the broadcast packet;
[0088] There are two types of Bluetooth devices: connected and broadcast. Both connected and broadcast Bluetooth devices can send broadcast packets to be discovered by other devices, but connected Bluetooth devices can accept connection requests from other devices and establish stable two-way communication connections, while broadcast Bluetooth devices only send broadcast data, do not accept connection requests, can only send data in one direction, and do not accept data from other devices.
[0089] Therefore, if the broadcast packet is a Bluetooth beacon broadcast packet (Beacon broadcast packet), the Bluetooth device is determined to be a connected Bluetooth device; if the broadcast packet is an Apple near-field beacon broadcast packet (i Beacon broadcast packet), the Bluetooth device is determined to be a broadcast Bluetooth device.
[0090] S132: Determine whether the type of the Bluetooth device matches the preset type in the preset configuration protocol;
[0091] The cmd in the preset configuration protocol specifies the types of Bluetooth devices that are allowed to access. If the type of the Bluetooth device matches the cmd in the preset configuration protocol, the subsequent matching steps and access steps will continue. If the type of the Bluetooth device does not match the cmd in the preset configuration protocol, the Bluetooth gateway will not allow the Bluetooth device to access and will directly filter out the Bluetooth devices that do not match the cmd in the preset configuration protocol.
[0092] For example: the type of the Bluetooth device is a connection type device. If the cmd in the preset configuration protocol is "beacon", it is determined to be in compliance and the subsequent matching steps are continued. If the cmd in the preset configuration protocol is "i beacon", it is determined to be incompatible and the Bluetooth device is not allowed to access the Bluetooth gateway.
[0093] S133: If yes, and the type of the Bluetooth device is a connection type, obtaining the name of the Bluetooth device in the broadcast packet, determining whether the name of the Bluetooth device is consistent with a preset name in the preset configuration protocol, and if they are consistent, establishing a connection with the Bluetooth device, and reading the first configuration information of the Bluetooth device;
[0094] If the type of the Bluetooth device is connection type, the Bluetooth gateway needs to establish a connection with the Bluetooth device before data exchange or obtaining the configuration information of the Bluetooth device can be performed. However, the Bluetooth gateway can only establish a connection with the Bluetooth device when the name of the Bluetooth device is consistent with the preset name in the preset configuration protocol.
[0095] First, obtain the name of the Bluetooth device in the broadcast packet, and compare the name of the Bluetooth device with the preset name (name) in the preset configuration protocol. If the two are consistent, the Bluetooth gateway will establish a connection with the Bluetooth device. If they are inconsistent, it means that the Bluetooth device cannot connect to the Bluetooth gateway. By comparing the name of the Bluetooth device with the preset name, Bluetooth devices whose names are consistent with the preset name in the preset configuration protocol can be filtered out. Bluetooth devices that are inconsistent with the preset name will not establish a connection, preventing too many useless connections from occupying the memory of the Bluetooth gateway, saving space for the Bluetooth gateway, and improving the working efficiency of the Bluetooth gateway.
[0096] After the Bluetooth gateway establishes a connection with the connected Bluetooth device, the first configuration information of the Bluetooth device is read in an interactive manner. Specifically, Figure 5 As shown, step S133 includes:
[0097] S1331: Sending a query instruction to the Bluetooth device;
[0098] S1332: Receive the first configuration information returned by the Bluetooth device according to the query instruction, wherein the first configuration information includes a first service identifier supported by the Bluetooth device, a data sending attribute of the Bluetooth device, and a data reading attribute of the Bluetooth device.
[0099] After receiving the query instruction, the Bluetooth device will return a response broadcast packet, which includes the first configuration information of the Bluetooth device. The first configuration information includes a service list supported by the Bluetooth device and a first service identifier corresponding to each service.
[0100] For example, the list of services supported by Bluetooth devices includes: device access service, basic read and write service, services that provide device manufacturer information, model, etc., heart rate monitoring service, and services that support monitoring and transmitting body temperature data. The Bluetooth device uses the first service identifier (UUID) to uniquely identify the specific services provided by the Bluetooth device. For example: a 16-bit service identifier "0x1800" is used to uniquely identify the device access service supported by the Bluetooth device, a 16-bit service identifier "0x1801" is used to uniquely identify the read and write service supported by the Bluetooth device, a 16-bit service identifier "0x180D" is used to uniquely identify the service for monitoring and transmitting heart rate data supported by the Bluetooth device, and a 16-bit service identifier "0x1809" is used to uniquely identify the service for monitoring and transmitting body temperature data supported by the Bluetooth device. Therefore, the specific services supported by the Bluetooth device can be known through the first service identifier.
[0101] It should be noted that the first service identifier (UUID) is a 128-bit digital identifier. For simplicity, a 16-bit UU ID can be used, which is usually used for standard services defined by Bluetooth SIG. Custom services usually use a completely customized 128-bit UU ID. For example, the preset service identifier in the preset configuration protocol in the above embodiment is: FDA50693A4E24FB1AFCFC6EB0764.
[0102] In addition, the first configuration information also includes data sending attributes of the Bluetooth device and data reading attributes of the Bluetooth device, wherein the data sending attributes refer to whether the Bluetooth device supports active data sending or data reporting, and the data reading attributes refer to whether the Bluetooth device can read data.
[0103] S133: If yes, and the type of the Bluetooth device is a broadcast type, obtaining second configuration information of the Bluetooth device from the broadcast packet.
[0104] If the Bluetooth device is a broadcast device, the second configuration information of the Bluetooth device is directly obtained from the broadcast packet. The second configuration information also includes the service identifier of the Bluetooth device. In the embodiment of the present application, the service identifier in the second configuration information is called the second service identifier.
[0105] It should be noted that the first service identifier and the second service identifier have the same function and meaning. They are only used to distinguish the service identifiers of different types of Bluetooth devices. The first service identifier is the service identifier of a connected Bluetooth device, and the second service identifier is the service identifier of a broadcast Bluetooth device. Both the first service identifier and the second service identifier are used to uniquely identify the services supported by the Bluetooth device.
[0106] S14: Determine whether the configuration information matches the preset configuration protocol;
[0107] If the Bluetooth device is a connection type device, the first service identifier, the data sending attribute, and the data reading attribute need to be compared with the preset configuration protocol one by one to determine whether they match the preset configuration protocol.
[0108] Specifically, if Figure 6 As shown, step S14 includes:
[0109] S141: Obtaining a preset service identifier in the preset configuration protocol;
[0110] S142: Determine whether the first service identifier is consistent with the preset service identifier;
[0111] S143: If they are consistent, determining whether the first configuration information matches the preset configuration protocol according to the data sending attribute and the data reading attribute.
[0112] The preset service identifier is a service identifier of an accessible Bluetooth device specified by the Bluetooth gateway. The first service identifier is compared with the preset service identifier. If the two are consistent, the next step of matching is performed.
[0113] Even if the name of the Bluetooth device is consistent with the preset name and the Bluetooth device establishes a connection with the Bluetooth gateway, it may be a similar situation, or the Bluetooth device may not be a Bluetooth device allowed to access by the Bluetooth gateway. Therefore, in order to avoid connection errors, it is further determined by the first service identifier and the preset service identifier whether the service supported by the Bluetooth device matches the service specified by the Bluetooth gateway to determine whether the Bluetooth device is a device allowed to access by the Bluetooth gateway.
[0114] If the first preset service identifier is consistent with the preset service identifier, it indicates that the service supported by the Bluetooth device allowed to access by the Bluetooth gateway is consistent with the service supported by the Bluetooth device. For example, the service supported by the Bluetooth device allowed to access by the Bluetooth gateway is heart rate monitoring, and the service supported by the Bluetooth device is also heart rate monitoring. Then, the first preset service identifier is consistent with the preset service identifier, and then it is determined whether the first configuration information matches the preset configuration protocol based on the data sending attribute and the data reading attribute.
[0115] Specifically, first determine whether there is a data reading configuration requirement in the preset configuration protocol. If so, determine whether the Bluetooth device supports data reading according to the data reading attribute of the Bluetooth device. If so, determine that the first configuration information matches the preset configuration protocol.
[0116] The Bluetooth gateway stipulates that the Bluetooth devices allowed to access must support data that can be read. If a Bluetooth device does not support this function, its corresponding first configuration information does not match the preset configuration protocol, and the Bluetooth device that does not support this function is filtered out through the data read attribute of the Bluetooth device.
[0117] Alternatively, it is determined whether there is a configuration requirement for receiving data in the preset configuration protocol. If so, it is determined whether the Bluetooth device supports sending data according to the data sending attribute of the Bluetooth device. If so, it is determined that the first configuration information matches the preset configuration protocol.
[0118] The Bluetooth gateway stipulates that the Bluetooth devices allowed to access need to support active reporting of data. If a Bluetooth device does not support this function, its corresponding first configuration information does not match the preset configuration protocol, and the Bluetooth device that does not support this function is filtered out through the data sending attributes of the Bluetooth device.
[0119] Alternatively, determine whether there are configuration requirements for reading data and receiving data in the preset configuration protocol. If both exist, determine whether the Bluetooth device supports reading data based on the data reading property of the Bluetooth device, and determine whether the Bluetooth device supports sending data based on the data sending property of the Bluetooth device. If both are supported, determine that the first configuration information matches the preset configuration protocol.
[0120] The Bluetooth gateway stipulates that the Bluetooth devices allowed to access must support active reporting of data and support data being readable. If a Bluetooth device does not support these two functions, its corresponding first configuration information does not match the preset configuration protocol. The Bluetooth devices that do not support these two functions are filtered out through the data sending attributes and the reading attributes of the Bluetooth device.
[0121] Bluetooth devices whose first configuration information does not match the preset configuration protocol do not meet the configuration requirements of the Bluetooth gateway. For any Bluetooth device that does not meet the configuration requirements, the Bluetooth gateway will disconnect in time and will not establish a long-term connection with the Bluetooth gateway that does not meet the configuration requirements, so as to prevent too many useless connections from occupying the memory of the Bluetooth gateway and save space.
[0122] It should be noted that the data sending attributes and data reading attributes of the Bluetooth device can be determined by the first service identifier of the Bluetooth device. When it is determined that there is a configuration requirement for reading data in the preset configuration protocol and / or when it is determined that there is a configuration requirement for receiving data in the preset configuration protocol, the data sending attributes and data reading attributes of the Bluetooth device can be determined again by querying to determine whether the Bluetooth device supports readable data and / or whether it supports active reporting of data.
[0123] In some embodiments, if the Bluetooth device is a broadcast device, the second service identifier needs to be compared with the preset service identifier to determine whether the second configuration information matches the preset configuration protocol to determine whether the Bluetooth device is a Bluetooth device allowed to access by the Bluetooth gateway.
[0124] Specifically, Figure 7 As shown, step S14 also includes:
[0125] S144: Obtaining a preset service identifier in the preset configuration protocol;
[0126] S145: Determine whether the second service identifier matches the preset service identifier;
[0127] S146: If matched, determine that the second configuration information matches the preset configuration protocol.
[0128] The second service identifier is compared with the preset service identifier. If the two are consistent, it is determined that the second service identifier matches the preset service identifier, and then the second configuration information matches the preset configuration protocol, indicating that the broadcast Bluetooth device is a Bluetooth device allowed to access by the Bluetooth gateway, and the two can interact with each other.
[0129] In the embodiment of the present application, the second service identifier is used to filter out Bluetooth devices that do not comply with the preset configuration protocol, thereby improving the efficiency of Bluetooth device access.
[0130] S15: If matched, the Bluetooth device is connected to the Bluetooth gateway.
[0131] If the first configuration information matches the preset configuration protocol, the Bluetooth device is connected to the Bluetooth gateway, and data is exchanged between the Bluetooth gateway and the Bluetooth device, such as reading the data of the Bluetooth device at a regular interval, or the Bluetooth device actively reporting data to the Bluetooth gateway. The Bluetooth gateway receives the data reported by the Bluetooth device. The Bluetooth gateway can also report the data of the Bluetooth device to the cloud to complete the data upload of the Bluetooth device.
[0132] If the second configuration information matches the preset configuration protocol, the Bluetooth device is connected to the Bluetooth gateway, the Bluetooth device actively reports data to the Bluetooth gateway, the Bluetooth gateway receives the data reported by the Bluetooth device, and the Bluetooth gateway can also report the data of the Bluetooth device to the cloud to complete the data upload of the Bluetooth device.
[0133] Therefore, when a new Bluetooth device is connected, the Bluetooth gateway first receives and stores the preset configuration protocol sent by the client, then starts to monitor the broadcast packets of nearby Bluetooth devices, and interprets the broadcast packets to determine the type of the Bluetooth device.
[0134] If the Bluetooth device is a connection type Bluetooth device, the Bluetooth gateway actively establishes a connection with the Bluetooth device and reads the first configuration information of the Bluetooth device. It is determined whether the first service identifier in the first configuration information matches the preset service identifier in the preset configuration protocol. If so, it is checked whether there is a configuration requirement for actively reading Bluetooth device data in the preset configuration protocol. If so, it is determined whether the Bluetooth device supports the reading of data through the read attribute in the first configuration information. If so, the Bluetooth gateway starts to read the data of the Bluetooth device regularly.
[0135] Then check whether there is a configuration requirement for receiving data in the preset configuration protocol. If there is such a configuration requirement, determine whether the Bluetooth device supports active data reporting through the data sending attribute in the first configuration information. If it does, the Bluetooth gateway starts to receive data actively reported by the Bluetooth device and reports the data to the cloud.
[0136] If the Bluetooth device is a broadcast device, the Bluetooth gateway directly obtains the second configuration information of the Bluetooth device from the broadcast, and determines whether the second service identifier in the second configuration information matches the preset service identifier in the preset configuration protocol. If so, the Bluetooth gateway starts to receive data actively reported by the Bluetooth device and reports the data to the cloud.
[0137] For any Bluetooth device that does not comply with the preset configuration protocol, the Bluetooth gateway will not maintain a long-term connection and will disconnect in time to avoid occupying the Bluetooth gateway's memory and save space.
[0138] In summary, the method modifies the configuration of the Bluetooth gateway through a preset configuration protocol, so that Bluetooth devices that comply with the preset configuration protocol can be quickly accessed, thereby improving the efficiency of accessing new Bluetooth devices. In addition, the method realizes the function of accessing different Bluetooth devices by configuring different preset configuration protocols, without the need to redevelop the Bluetooth gateway, saving the cost of Bluetooth device access, and making the access method simpler and more flexible.
[0139] It should be noted that in each of the above embodiments, there is not necessarily a certain order between the above steps. A person skilled in the art can understand, based on the description of the embodiments of the present application, that in different embodiments, the above steps may have different execution orders, that is, they may be executed in parallel, may be executed interchangeably, and so on.
[0140] As another aspect of the embodiment of the present application, the embodiment of the present application provides an access device for a Bluetooth device. The access device for a Bluetooth device may be a software module, which includes several instructions stored in a memory of the Bluetooth gateway 30. The processor may access the memory and call the instructions for execution to complete the access method for the Bluetooth device described in the above embodiments.
[0141] In some embodiments, the access device of the Bluetooth device can also be constructed by hardware devices. For example, the access device of the Bluetooth device can be constructed by one or more chips, and each chip can work in coordination with each other to complete the access method of the Bluetooth device described in the above embodiments. For another example, the access device of the Bluetooth device can also be constructed by various logic devices, such as a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machi ne) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
[0142] See also Figure 8 , Figure 8An embodiment of the present application provides an access device for a Bluetooth device, and the access device 800 for the Bluetooth device includes a receiving module 801 , a monitoring module 802 , a first determining module 803 , a second determining module 804 and an access module 805 .
[0143] The receiving module 801 is used to receive the preset configuration protocol sent by the client, the monitoring module 802 is used to monitor the broadcast packet of the Bluetooth device, the first determination module 803 is used to determine the configuration information of the Bluetooth device according to the broadcast packet, the second determination module 804 is used to determine whether the configuration information matches the preset configuration protocol, and the access module 805 is used for the Bluetooth device to access the Bluetooth gateway.
[0144] Therefore, the access device of the Bluetooth device modifies the configuration of the Bluetooth gateway through a preset configuration protocol, so that the Bluetooth device that complies with the preset configuration protocol can be quickly accessed, thereby improving the efficiency of accessing new Bluetooth devices. Moreover, the method realizes the function of accessing different Bluetooth devices by configuring different preset configuration protocols, without the need to redevelop the Bluetooth gateway, thus saving the cost of Bluetooth device access, and the access method is simpler and more flexible.
[0145] It should be noted that, since the access device of the Bluetooth device and the access method of the Bluetooth device in the above embodiment are based on the same application concept, the corresponding contents in the above method embodiment are also applicable to the device embodiment and will not be described in detail here.
[0146] The present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors, for example Figure 2 A processor 301 in the embodiment may enable the one or more processors to execute the access method of the Bluetooth device in any of the above method embodiments.
[0147] An embodiment of the present application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by the Bluetooth gateway 30, the Bluetooth gateway 30 executes any one of the access methods for Bluetooth devices described.
[0148] To sum up, the access method of the Bluetooth device modifies the configuration of the Bluetooth gateway through a preset configuration protocol, so that the Bluetooth devices that comply with the preset configuration protocol can be quickly accessed, thereby improving the efficiency of accessing new Bluetooth devices. In addition, the method realizes the function of accessing different Bluetooth devices by configuring different preset configuration protocols, without the need to redevelop the Bluetooth gateway, thus saving the cost of Bluetooth device access, and the access method is simpler and more flexible.
[0149] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Under the concept of the present invention, the technical features in the above embodiments or different embodiments may also be combined, the steps may be implemented in any order, and there are many other changes in different aspects of the present invention as described above, which are not provided in detail for the sake of simplicity. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for accessing a Bluetooth device, characterized in that: Applied to a Bluetooth gateway, the method comprises: Receiving a preset configuration protocol sent by a client; Monitor the broadcast packets of Bluetooth devices; Determine the configuration information of the Bluetooth device according to the broadcast packet; Determining whether the configuration information matches the preset configuration protocol; If they match, the Bluetooth device is connected to the Bluetooth gateway.
2. The method according to claim 1, characterized in that The determining the configuration information of the Bluetooth device according to the broadcast packet includes: Determine the type of the Bluetooth device according to the broadcast packet; Determining whether the type of the Bluetooth device matches the preset type in the preset configuration protocol; If yes, and the type of the Bluetooth device is a connection type, obtaining the name of the Bluetooth device in the broadcast packet, determining whether the name of the Bluetooth device is consistent with the preset name in the preset configuration protocol, and if they are consistent, establishing a connection with the Bluetooth device and reading the first configuration information of the Bluetooth device; If yes, and the type of the Bluetooth device is a broadcast type, the second configuration information of the Bluetooth device is obtained from the broadcast packet.
3. The method according to claim 2, characterized in that The reading the first configuration information of the Bluetooth device includes: Sending a query instruction to the Bluetooth device; The first configuration information returned by the Bluetooth device according to the query instruction is received, wherein the first configuration information includes a first service identifier supported by the Bluetooth device, a data sending attribute of the Bluetooth device, and a data reading attribute of the Bluetooth device.
4. The method according to claim 3, characterized in that The determining whether the configuration information matches the preset configuration protocol includes: Obtaining a preset service identifier in the preset configuration protocol; Determining whether the first service identifier is consistent with the preset service identifier; If they are consistent, it is determined whether the first configuration information matches the preset configuration protocol according to the data sending attribute and the data reading attribute.
5. The method according to claim 4, characterized in that The determining, according to the data sending attribute and the data reading attribute, whether the first configuration information matches the preset configuration protocol includes: Determine whether there is a read data configuration requirement in the preset configuration protocol; If so, determining whether the Bluetooth device supports data being read according to the data being read attribute of the Bluetooth device, and if so, determining that the first configuration information matches the preset configuration protocol; or, Determine whether there is a configuration requirement for receiving data in the preset configuration protocol; If so, determining whether the Bluetooth device supports data transmission according to the data transmission attribute of the Bluetooth device, and if so, determining that the first configuration information matches the preset configuration protocol; or, Determine whether there is a configuration requirement for reading data and receiving data in the preset configuration protocol; If both exist, determine whether the Bluetooth device supports reading data based on the data reading attribute of the Bluetooth device, and determine whether the Bluetooth device supports sending data based on the data sending attribute of the Bluetooth device. If both are supported, determine that the first configuration information matches the preset configuration protocol.
6. The method according to claim 5, characterized in that The method further comprises: If not matched, the connection with the Bluetooth device is disconnected.
7. The method according to claim 2, characterized in that The second configuration information includes a second service identifier supported by the Bluetooth device, and the determining whether the configuration information matches the preset configuration protocol further includes: Obtaining a preset service identifier in the preset configuration protocol; Determining whether the second service identifier matches the preset service identifier; If they match, it is determined that the second configuration information matches the preset configuration protocol.
8. The method according to claim 1, characterized in that: The method further comprises: Receiving a configuration instruction sent by the client; According to the configuration instruction, its own communication mode is configured to be a monitoring broadcast mode.
9. A Bluetooth gateway, characterized in that: The Bluetooth gateway includes at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the access method of the Bluetooth device as described in any one of claims 1-8.
10. A Bluetooth device access system, characterized in that: include: A Bluetooth device, a client, and a Bluetooth gateway as claimed in claim 9, wherein the Bluetooth gateway is communicatively connected with the client.