CN115226086A - Method and device for determining service provided by server, bluetooth equipment and storage medium - Google Patents

Method and device for determining service provided by server, bluetooth equipment and storage medium Download PDF

Info

Publication number
CN115226086A
CN115226086A CN202210674724.9A CN202210674724A CN115226086A CN 115226086 A CN115226086 A CN 115226086A CN 202210674724 A CN202210674724 A CN 202210674724A CN 115226086 A CN115226086 A CN 115226086A
Authority
CN
China
Prior art keywords
server
hash value
unique identifier
address
service provided
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210674724.9A
Other languages
Chinese (zh)
Inventor
白浩浩
吕生义
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202210674724.9A priority Critical patent/CN115226086A/en
Publication of CN115226086A publication Critical patent/CN115226086A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/06Selective distribution of broadcast services, e.g. multimedia broadcast multicast service [MBMS]; Services to user groups; One-way selective calling services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/14Direct-mode setup

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Multimedia (AREA)
  • Software Systems (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The embodiment of the application discloses a method and a device for determining service provided by a server, bluetooth equipment and a storage medium, which are used for realizing the function of a database hash characteristic value of a universal attribute protocol service under the condition that a broadcast address of the low-power-consumption Bluetooth equipment server is a random address, thereby reducing redundant data interaction and optimizing the connection speed of the equipment. The method in the embodiment of the application comprises the following steps: when a Bluetooth device is connected with a server, if the broadcast address of the server is a random address, acquiring a unique identifier and a current hash value of the server; searching a locally stored historical hash value according to the unique identifier; if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side.

Description

Method and device for determining service provided by server, bluetooth equipment and storage medium
Technical Field
The present application relates to the field of bluetooth technologies, and in particular, to a method and an apparatus for determining a service provided by a server, a bluetooth device, and a storage medium.
Background
In the existing bluetooth core protocol, the Database Hash function can only be used when the broadcast address of the service end is a Public (Public) address, and if the broadcast end uses a Random (Random) address, the broadcast address changes every time the broadcast is restarted, so the function cannot be used.
Disclosure of Invention
The embodiment of the application provides a method and a device for determining that a server provides service, bluetooth equipment and a storage medium, and is used for realizing the function of hash characteristic values of a database of a universal attribute protocol service under the condition that a broadcast address of the low-power-consumption Bluetooth equipment server is a random address, so that redundant data interaction is reduced, and the connection speed of the equipment is optimized.
A first aspect of the present application provides a method for determining that a server provides a service, which may include:
when a Bluetooth device is connected with a server, if the broadcast address of the server is a random address, acquiring a unique identifier and a current hash value of the server;
searching a locally stored historical hash value according to the unique identifier;
and if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side.
A second aspect of the present application provides an apparatus for determining that a server provides a service, which may include:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a unique identifier and a current hash value of a server if a broadcast address of the server is a random address when the Bluetooth device is connected with the server;
the processing module is used for searching a locally stored historical hash value according to the unique identifier; and if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side.
A third aspect of the present application provides a bluetooth device, which may include:
a memory storing executable program code;
a processor coupled with the memory;
the processor is configured to perform the method of the first aspect of the present application.
Yet another aspect of the embodiments of the present application provides a computer-readable storage medium, comprising instructions, which when executed on a processor, cause the processor to perform the method of the first aspect of the present application.
In another aspect, an embodiment of the present application discloses a computer program product, which, when run on a computer, causes the computer to execute the method of the first aspect of the present application.
In another aspect, an embodiment of the present application discloses an application publishing platform, which is configured to publish a computer program product, wherein when the computer program product runs on a computer, the computer is caused to execute the method of the first aspect of the present application.
According to the technical scheme, the embodiment of the application has the following advantages:
in the embodiment of the application, when the Bluetooth device is connected with a server, if the broadcast address of the server is a random address, the unique identifier and the current hash value of the server are obtained; searching a locally stored historical hash value according to the unique identifier; if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side. When the Bluetooth device is connected with the server, if the broadcast address of the server is a random address, the unique identifier and the current hash value of the server can be obtained, the historical hash value locally stored in the Bluetooth device can be found through the unique identifier, and if the current hash value is consistent with the historical hash value, the service provided by the server is considered to be unchanged, the service provided by the server does not need to be searched, and the service provided by the server can be directly used. Namely, under the condition that the broadcast address of the low-power-consumption Bluetooth BLE equipment service end is a random address, the Hash characteristic value Database Hash characteristic function of the GATT service can be realized, so that redundant data interaction is reduced, and the connection speed of the equipment is optimized.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the embodiments and the drawings used in the description of the prior art, and obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained according to the drawings.
Fig. 1 is a schematic diagram of an embodiment of a method for determining that a server provides a service in an embodiment of the present application;
fig. 2 is a schematic diagram of another embodiment of a method for determining that a server provides a service in an embodiment of the present application;
fig. 3 is a schematic flowchart of a method for determining that a server provides a service in an embodiment of the present application;
FIG. 4 is a schematic diagram of an apparatus for determining that a server provides a service in an embodiment of the present application;
FIG. 5 is a schematic diagram of an embodiment of a Bluetooth device in the embodiment of the present application;
fig. 6 is a schematic diagram of another embodiment of the bluetooth device in the embodiment of the present application.
Detailed Description
The embodiment of the application provides a method and a device for determining that a server provides service, bluetooth equipment and a storage medium, and is used for realizing the function of hash characteristic values of a database of a universal attribute protocol service under the condition that a broadcast address of the low-power-consumption Bluetooth equipment server is a random address, so that redundant data interaction is reduced, and the connection speed of the equipment is optimized.
For a person skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, and not all embodiments. The embodiments in the present application shall all belong to the protection scope of the present application.
In the following, a brief description of several terms related to the present application is made as follows:
1、profile
profile is understood to be a specification, a standard communication protocol, which exists in the master and in the slave. The bluetooth organization specifies some standard profiles, such as: HID OVER GATT, anti-lost device, cardiotachometer, etc. Each profile contains multiple services (services), each service representing a capability of a slave (server).
2、service
A service may be understood as a service, and in a Bluetooth Low Energy (BLE) slave, each service includes a plurality of characteristic values (signatures) by having a plurality of services, such as a power information service, a system information service, and the like. Each specific charateristic feature value is the subject of BLE communications. For example, the current power is 80%, so that the characterization value of the power is stored in the profile of the slave, so that the host can read 80% of the data through the characterization.
3、characteristic
The value of the characterstic characteristic, communication of BLE master and slave is realized through characterstic, which can be understood as a tag through which desired contents can be acquired or written.
4、UUID
UUID, a universal Unique Identifier (also called unified Identifier), the service and the charateristic mentioned above all require a Unique UUID to identify and collate. Each slave has a so-called profile, and both the customized simpleprofile and the standard anti-lost device profile are composed of a series of services, each service then comprises a plurality of tractristics, and the communication between the master and the slave is realized through the tractristics.
Bluetooth Low Energy (BLE) connectivity is now built on the Generic Attribute Profile (GATT). The GATT is a general specification for sending and receiving short data segments, referred to as attributes (attributes), over a bluetooth connection. It defines that two BLE devices communicate through things called Service and charasteristic. The GATT is an Attribute Protocol (ATT) Protocol, where the ATT Protocol stores data corresponding to Service and charctertic in a lookup table, and the secondary lookup table uses a 16-bit ID (bit identifier) as an index of each entry.
The GATT comes into play once the two devices establish a connection, which also means that the previous Generic Access Profile (GAP) has to be completed. Here, it should be noted that GATT connection must first go through GAP protocol. In fact, in Android development, a Media Access Control (MAC) address of a device may be directly used to initiate a connection without a scanning step. This does not mean that you do nothing through the GAP, and indeed you have done so at the chip level, the bluetooth chip initiates the connection, always scans the device first, and then initiates the connection.
Of particular note to GATT connections are: the GATT connection is exclusive. That is, a BLE peripheral can only be connected by one central device at the same time. Once the peripheral is connected, it stops broadcasting immediately so that it is invisible to other devices. When the device disconnects, it starts broadcasting again.
If the central device and the peripheral device need to communicate in both directions, the only way is to establish a GATT connection.
The two parties of the GATT communication are in a C/S relationship. The peripheral acts as a GATT Server (Server), which maintains a look-up table for ATTs and definitions of services and characteristics. The central device is a GATT Client (Client) that initiates requests to the Server. It should be noted that all communication events are initiated by the client (also called Master device) and receive the response of the server (also called Slave device).
Once the Connection is established, the peripheral device will suggest a Connection Interval (Connection Interval) to the central device, so that the central device will try to reconnect at each Connection Interval to check if there is new data. However, this connection interval is only one suggestion, and the central device may not perform exactly at this interval, e.g. the central device is busy connecting other peripherals, or the central device resources are too busy.
In the existing bluetooth core protocol, the Database Hash function can only be used when the broadcast address of the service end is a Public (Public) address, and if the broadcast end uses a Random (Random) address, the broadcast address changes every time the broadcast is restarted, so the function cannot be used.
In the embodiment of the present application, the electronic device with bluetooth function may be referred to as a bluetooth device. For example a terminal device with bluetooth functionality. The terminal device may be referred to as a User Equipment (UE), a Mobile Station (MS), a mobile terminal (mobile terminal), an intelligent terminal, and the like, and may communicate with one or more core networks through a Radio Access Network (RAN). For example, the terminal devices may be mobile phones (or called "cellular" phones), computers with mobile terminals, etc., and may also be portable, pocket, hand-held, computer-included, or vehicle-mounted mobile devices and terminal devices in future New Radio (NR) networks, which exchange voice or data with a Radio access network. Description of terminal device: in this application, the terminal device may further include a Relay, and the terminal device and the base station that can perform data communication may be regarded as the terminal device, which will be introduced in this application by the UE in a general sense.
In this embodiment, the terminal device may be a Mobile Phone (Mobile Phone), a tablet computer (Pad), a computer with a wireless transceiving function, a Virtual Reality (VR) terminal device, an Augmented Reality (AR) terminal device, a wireless terminal device in industrial control (industrial control), a wireless terminal device in self driving (self driving), a wireless terminal device in remote medical (remote medical), a wireless terminal device in smart grid (smart grid), a wireless terminal device in transportation safety (transportation safety), a wireless terminal device in city (smart city), a wireless terminal device in smart home (smart home), or the like.
By way of example and not limitation, in the embodiments of the present application, the terminal device may also be a wearable device. Wearable equipment can also be called wearable intelligent equipment, is the general term of applying wearable technique to carry out intelligent design, develop the equipment that can dress to daily wearing, like glasses, gloves, wrist-watch, dress and shoes etc.. A wearable device is a portable device that is worn directly on the body or integrated into the clothing or accessories of the user. The wearable device is not only a hardware device, but also realizes powerful functions through software support, data interaction and cloud interaction. The generalized wearable smart device includes full functionality, large size, and can implement full or partial functionality without relying on a smart phone, such as: smart watches or smart glasses and the like, and only focus on a certain type of application functions, and need to be used in cooperation with other devices such as smart phones, such as various smart bracelets for physical sign monitoring, smart jewelry and the like.
In the existing implementation scheme, the client, namely the bluetooth device, stores the values of GATT services and Database Hash characteristics of the server through the address of the server. Therefore, if the server is a random address, because the address of the server changes every time the server is broadcasted, the client considers that the server is a new device every time the client connects, the function has no meaning, and the problem that the client stores too much service data and the like can be caused.
In view of the above problems, the present invention implements a Database Hash mapping function that can implement GATT service even when BLE devices broadcast random addresses. When the address of the server changes and the Bluetooth equipment is reconnected with the server, whether GATT services of the server are modified or not can be identified, and therefore the connection speed is optimized.
It is understood that the Database Hash algorithm of the bluetooth low energy BLE GATT service is used to identify whether the GATT services of the server is added, deleted or modified. In the embodiment of the present application, the Hash value of Database is a current Hash value (Hash) calculated by AES-CMAC algorithm of RFC-4493 protocol according to the service defined in GATT Database. The client side reads and judges whether the current hash value is the same as the historical hash value of the same server side stored locally, so that whether the services of the server side are modified is judged, and whether the service discovery process is executed again is determined.
The application provides a Database Hash characteristic value (Database Hash characteristic) function which can realize a Generic Attribute profile (GATT) service (service) even if a BLE device broadcasts a random address. When the address of the server changes and the client is reconnected with the server, whether GATT services of the server are modified or not can be identified, so that the connection speed is optimized, and the power consumption of equipment is reduced.
The technical solution of the present application is further described below by way of an embodiment, and as shown in fig. 1, a schematic diagram of an embodiment of a method for determining a service provided by a server in the embodiment of the present application may include:
101. when the Bluetooth equipment is connected with a server, if the broadcast address of the server is a random address, the unique identifier and the current hash value of the server are obtained.
Optionally, when the bluetooth device is connected to the server, if the broadcast address of the server is a random address, the unique identifier of the server is obtained, which may include but is not limited to the following implementation manners:
in implementation mode 1, when the bluetooth device is connected to the server, if the broadcast address of the server is a random address, the unique identifier of the server is obtained according to an Advanced Encryption Standard-personal based Message Authentication Code (AES-CMAC) algorithm, a preset public key, and the broadcast address of the server.
Optionally, the obtaining the unique identifier of the server according to the AES-CMAC algorithm, the preset public key, and the broadcast address of the server may include:
acquiring a unique identifier of the server according to a first formula;
the first formula is Uid = AES-CMAC K (PAddr)/mod2 36
Wherein Uid is the only identification of the server, AES-CMAC is the algorithm for calculating Hash, K is the preset public key, PAddr is the public address of the server, mod2 36 Indicating the 36 lower bits of the result.
In implementation mode 2, when the bluetooth device is connected to a server, if the broadcast address of the server is a random address, the unique identifier of the server is obtained according to an MD5 Message-Digest Algorithm (MD 5 Message-Digest Algorithm), a preset public key, and the broadcast address of the server.
Optionally, the obtaining the unique identifier of the server according to the MD5 information digest algorithm, the preset public key and the broadcast address of the server may include:
acquiring the unique identifier of the server according to a second formula;
the second formula is Uid = MD5 K (PAddr)/mod2 36
Wherein Uid is the only identification of the server, MD5 is the algorithm for calculating Hash, K is the preset public key, PAddr is the public address of the server, mod2 36 Indicating the 36 lower bits of the result.
It will be appreciated that the MD5 message digest algorithm is to compute any length of information input to produce a 128 bit length "fingerprint" or "message digest", assuming that it is computationally infeasible for two different files to produce the same message digest or to produce the original information from a given message digest.
The MD5 is called Message-Digest algorithm 5, and MD5 is an irreversible algorithm, i.e. it inverts the generated ciphertext, corresponding to infinite inverses. Developed in the early 90 s, developed through MD2, MD3 and MD 4. It functions to allow large volumes of information to be "compressed" into a secure format (i.e., a string of bytes of arbitrary length is converted into a large integer of fixed length) before the private key is signed by the digital signature software.
In implementation manner 3, when the bluetooth device is connected to the server, if the broadcast address of the server is a random address, the unique identifier of the server is obtained according to a Secure Hash Algorithm (SHA), a preset public key, and the broadcast address of the server.
Optionally, the obtaining the unique identifier of the server according to the secure hash SHA algorithm, the preset public key, and the broadcast address of the server may include:
the third formula is Uid = SHA K (PAddr)/mod2 36
Wherein Uid is the only identifier of the server, SHA is the algorithm for calculating Hash, K is the preset public key, PAddr is the public address of the server, mod2 36 Indicating the 36 lower bits of the result.
It is understood that a Secure Hash Algorithm (english: secure Hash Algorithm, abbreviated SHA) is a family of cryptographic Hash functions, which is a FIPS certified Secure Hash Algorithm. An algorithm for calculating a fixed-length character string (also called a message digest) corresponding to a digital message. And if the input messages are different, the probability that the input messages correspond to different character strings is high.
Optionally, when the bluetooth device is connected to the server, if the broadcast address of the server is a random address, acquiring the unique identifier and the current hash value of the server may include: when a Bluetooth device is connected with a server, if the broadcast address of the server is a random address, reading the attribute value of the hash characteristic value of the database of the server; and acquiring the unique identifier and the current hash value of the server according to the attribute value of the database hash characteristic value of the server.
102. And searching a locally stored historical hash value according to the unique identifier.
Optionally, the unique identifier is added to an attribute value of the database hash feature value of the server.
Optionally, the size of the unique identifier is 36 bits.
Illustratively, in the Database Hash characteristic Value declaration format, the Attribute Value (Attribute Value) field adds a 36-bit Unique identifier (Unique identification) field based on the Bluetooth Special Interest Group (SIG) protocol, and this field can be obtained by Hash operation shown in formula (1), can uniquely identify a certain device, and is invariant in the device lifetime.
The Database Hash characterization declaration format is shown in Table 1:
Figure BDA0003694348170000091
TABLE 1
In the prior art, the storage space of the Attribute Value (Attribute Value) is 128 bits, and the storage space is used for storing the Database Hash Value (Database Hash). In the embodiment of the present application, the storage space of the Database Hash Value (Database Hash) is compressed to 92 bits, and the remaining 36-bit storage space in the Attribute Value (Attribute Value) is used to store the Unique identifier (Unique identification). Therefore, the protocol in the prior art can be compatible.
Uid=AES-CMAC K (PAddr)/mod2 36 Formula (1)
Wherein, uid: an identifier 36bit Unique identifier (Unique identification);
AES-CMAC: the computational HASH algorithm specified in RFC-4493;
k: a 128-bit public key, which may be all zeros (0x00000000 \ u 00000000 \ -u 00000000);
PAddr: a Public (Public) address of the device;
mod2 36 indicating a 36bit (bit) lower in the result.
103. And if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side.
Illustratively, when the bluetooth device is connected to the server, the Uid field and the current Hash Value of the server are obtained by reading the Attribute Value of the Database Hash algorithm of the server, the server is identified by the Uid, and then whether Services (Services) provided by the server are changed or not is judged. Specifically, the historical HASH value which is locally and correspondingly stored is searched through the Uid, if the current HASH value is the same as the historical HASH value, the service (Services) provided by the server is not changed, the process of searching the service provided by the server is not required to be continuously executed, and the service provided by the server can be directly used, so that the process of searching the service provided by the server is saved, and the interaction of redundant data is reduced.
In the embodiment of the application, when the Bluetooth device is connected with a server, if the broadcast address of the server is a random address, the unique identifier and the current hash value of the server are obtained; searching a locally stored historical hash value according to the unique identifier; and if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side. When the Bluetooth device is connected with the server, if the broadcast address of the server is a random address, the unique identifier and the current hash value of the server can be acquired, the historical hash value locally stored in the Bluetooth device can be found through the unique identifier, and if the current hash value is consistent with the historical hash value, the service provided by the server is not changed, the service provided by the server does not need to be found, and the service provided by the server can be directly used. Namely, under the condition that the broadcast address of the low-power-consumption Bluetooth BLE equipment service end is a random address, the Hash characteristic value Database Hash characteristic function of the GATT service can be realized, so that redundant data interaction is reduced, and the connection speed of the equipment is optimized.
As shown in fig. 2, a schematic diagram of another embodiment of the method for determining that a server provides a service in the embodiment of the present application may include:
201. when the Bluetooth equipment is connected with a server, if the broadcast address of the server is a random address, the unique identifier and the current hash value of the server are obtained.
202. And searching a locally stored historical hash value according to the unique identifier.
203. And if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side.
It should be noted that steps 201 to 203 in the embodiment of the present application are similar to steps 101 to 103 in the embodiment shown in fig. 1, and are not described again here.
Optionally, the method may further include: after the bluetooth device stops searching for the service provided by the server, the bluetooth device can directly use the service provided by the server.
204. And if the current hash value is inconsistent with the historical hash value, determining that the service provided by the server side is changed, and continuously searching the service provided by the server side.
For example, if the current HASH value is different from the historical HASH value, it indicates that there is a change in Services (Services) provided by the server, and the process of searching for Services provided by the server is continuously executed.
205. And adding the current hash value into the historical hash value, and storing the added historical hash value in a cache.
Illustratively, the current hash value is added to the historical hash value, and the added historical hash value is saved in a cache (cache). And the added historical hash value is used as a hash value corresponding to the updated service provided by the server and is used for the next time when the Bluetooth equipment is connected with the server.
Fig. 3 is a schematic flow chart of a method for determining that a server provides a service in the embodiment of the present application. The problem to be solved by the application is that under the condition that a broadcast address of a BLE equipment service end is a random address, a Database Hash characterization function of the GATT service is achieved, and therefore the connection speed is optimized.
In the embodiment of the application, when the Bluetooth device is connected with a server, if the broadcast address of the server is a random address, the unique identifier and the current hash value of the server are obtained; searching a locally stored historical hash value according to the unique identifier; if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side; and if the current hash value is inconsistent with the historical hash value, determining that the service provided by the server side is changed, and continuously searching the service provided by the server side. When the Bluetooth device is connected with the server, if the broadcast address of the server is a random address, the unique identifier and the current hash value of the server can be acquired, the historical hash value locally stored in the Bluetooth device can be found through the unique identifier, and if the current hash value is consistent with the historical hash value, the service provided by the server is not changed, the service provided by the server does not need to be searched, and the service provided by the server can be directly used; if the current hash value is inconsistent with the historical hash value, the service provided by the server is considered to be changed, and the service provided by the server needs to be searched. Namely, under the condition that the broadcast address of the low-power-consumption Bluetooth BLE equipment service end is a random address, the Hash characteristic value Database Hash characteristic function of the GATT service can be realized, so that redundant data interaction is reduced, and the connection speed of the equipment is optimized.
As shown in fig. 4, a schematic diagram of an apparatus for determining that a server provides a service in an embodiment of the present application may include:
the acquisition module 401 is configured to, when a bluetooth device is connected to a server, acquire a unique identifier and a current hash value of the server if a broadcast address of the server is a random address;
a processing module 402, configured to search a locally stored historical hash value according to the unique identifier; if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side.
Optionally, the obtaining module 401 is specifically configured to obtain the unique identifier of the server according to an AES-CMAC algorithm, a preset public key, and the broadcast address of the server; or the like, or a combination thereof,
an obtaining module 401, configured to obtain a unique identifier of the server according to an MD5 message digest algorithm, a preset public key, and a broadcast address of the server; or the like, or, alternatively,
the obtaining module 401 is specifically configured to obtain the unique identifier of the server according to a secure hash SHA algorithm, a preset public key, and the broadcast address of the server.
Optionally, the obtaining module 401 is specifically configured to obtain the unique identifier of the server according to a first formula;
the first formula is Uid = AES-CMAC K (PAddr)/mod2 36
An obtaining module 401, configured to obtain, according to a second formula, the unique identifier of the server;
the second formula is Uid = MD5 K (PAddr)/mod2 36
An obtaining module 401, specifically configured to use the third formula of Uid = SHA K (PAddr)/mod2 36
Wherein Uid is the only identification of the server, AES-CMAC, MD5 and SHA are algorithms for calculating Hash, K is a preset public key, PAddr is the public address of the server, mod2 36 Indicating the 36 lower bits of the result.
Optionally, the unique identifier is added to an attribute value of the database hash feature value of the server.
Optionally, the obtaining module 401 is specifically configured to, when the bluetooth device is connected to a server, read an attribute value of a hash feature value of a database of the server if a broadcast address of the server is a random address; and acquiring the unique identifier and the current hash value of the server according to the attribute value of the database hash characteristic value of the server.
Optionally, the processing module 402 is further configured to determine that the service provided by the server changes if the current hash value is inconsistent with the historical hash value, and continue to search for the service provided by the server.
Optionally, the processing module 402 is further configured to add the current hash value to the historical hash value, and store the added historical hash value in a cache.
As shown in fig. 5, a schematic diagram of an embodiment of a bluetooth device in the embodiment of the present application may include: the device for determining the service provided by the service end is shown in fig. 4.
As shown in fig. 6, a schematic diagram of another embodiment of the bluetooth device in the embodiment of the present application may include:
fig. 6 is a block diagram illustrating a partial structure of a mobile phone related to a bluetooth device provided in an embodiment of the present application. Referring to fig. 6, the handset includes: radio Frequency (RF) circuit 610, memory 620, input unit 630, display unit 640, sensor 650, audio circuit 660, wireless fidelity (Wi-Fi) module 670, processor 680, and power supply 690. Those skilled in the art will appreciate that the handset configuration shown in fig. 6 is not intended to be limiting and may include more or fewer components than shown, or some components may be combined, or a different arrangement of components.
The following describes each component of the mobile phone in detail with reference to fig. 6:
the RF circuit 610 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, receives downlink information of a base station and then processes the received downlink information to the processor 680; in addition, the data for designing uplink is transmitted to the base station. In general, RF circuit 610 includes, but is not limited to, an antenna, at least one Amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, the RF circuitry 610 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to Global System for Mobile communication (GSM), general Packet Radio Service (GPRS), code Division Multiple Access (CDMA), wideband Code Division Multiple Access (WCDMA), long Term Evolution (LTE), email, short Messaging Service (SMS), and the like.
The memory 620 may be used to store software programs and modules, and the processor 680 may execute various functional applications and data processing of the mobile phone by operating the software programs and modules stored in the memory 620. The memory 620 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 620 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The input unit 630 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the cellular phone. Specifically, the input unit 630 may include a touch panel 631 and other input devices 632. The touch panel 631, also referred to as a touch screen, may collect touch operations of a user (e.g., operations of the user on the touch panel 631 or near the touch panel 631 by using any suitable object or accessory such as a finger or a stylus) thereon or nearby, and drive the corresponding connection device according to a preset program. Alternatively, the touch panel 631 may include two parts of a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 680, and can receive and execute commands sent by the processor 680. In addition, the touch panel 631 may be implemented using various types, such as resistive, capacitive, infrared, and surface acoustic wave. The input unit 630 may include other input devices 632 in addition to the touch panel 631. In particular, other input devices 632 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 640 may be used to display information input by a user or information provided to the user and various menus of the mobile phone. The Display unit 640 may include a Display panel 641, and optionally, the Display panel 641 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch panel 631 may cover the display panel 641, and when the touch panel 631 detects a touch operation thereon or nearby, the touch operation is transmitted to the processor 680 to determine the type of the touch event, and then the processor 680 provides a corresponding visual output on the display panel 641 according to the type of the touch event. Although in fig. 6, the touch panel 631 and the display panel 641 are two independent components to implement the input and output functions of the mobile phone, in some embodiments, the touch panel 631 and the display panel 641 may be integrated to implement the input and output functions of the mobile phone.
The handset may also include at least one sensor 650, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 641 according to the brightness of ambient light, and the proximity sensor may turn off the display panel 641 and/or the backlight when the mobile phone moves to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), detect the magnitude and direction of gravity when stationary, and can be used for applications of recognizing gestures of a mobile phone (such as horizontal and vertical screen switching, related games, magnetometer gesture calibration), vibration recognition related functions (such as pedometers and taps), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured on the mobile phone, further description is omitted here.
Audio circuit 660, speaker 661, and microphone 662 can provide an audio interface between a user and a cell phone. The audio circuit 660 may transmit the electrical signal converted from the received audio data to the speaker 661, and convert the electrical signal into an audio signal through the speaker 661 for output; on the other hand, the microphone 662 converts the collected sound signals into electrical signals, which are received by the audio circuit 660 and converted into audio data, which are processed by the audio data output processor 680 and then transmitted via the RF circuit 610 to, for example, another cellular phone, or output to the memory 620 for further processing.
Wi-Fi belongs to the short-distance wireless transmission technology, and the mobile phone can help a user to receive and send emails, browse webpages, access streaming media and the like through the Wi-Fi module 670, and provides wireless broadband internet access for the user. Although fig. 6 shows a Wi-Fi module 670, it is understood that it does not belong to the essential constitution of the handset and can be omitted entirely as needed within the scope of not changing the essence of the application.
The processor 680 is a control center of the mobile phone, and connects various parts of the entire mobile phone by using various interfaces and lines, and performs various functions of the mobile phone and processes data by operating or executing software programs and/or modules stored in the memory 620 and calling data stored in the memory 620, thereby performing overall monitoring of the mobile phone. Optionally, processor 680 may include one or more processing units; preferably, the processor 680 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 680.
The handset also includes a power supply 690 (e.g., a battery) for powering the various components, which may preferably be logically connected to the processor 680 via a power management system, such that the power management system may be used to manage charging, discharging, and power consumption.
Although not shown, the mobile phone may further include a camera, a bluetooth module, etc., which will not be described herein.
In this embodiment of the present application, the processor 680 is configured to, when a bluetooth device is connected to a server, obtain a unique identifier and a current hash value of the server if a broadcast address of the server is a random address;
the processor 680 is configured to search a locally stored historical hash value according to the unique identifier; and if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side.
Optionally, the processor 680 is specifically configured to obtain the unique identifier of the server according to an AES-CMAC algorithm, a preset public key, and the broadcast address of the server; or the like, or, alternatively,
the processor 680 is specifically configured to obtain a unique identifier of the server according to an MD5 information digest algorithm, a preset public key, and a broadcast address of the server; or the like, or, alternatively,
the processor 680 is specifically configured to obtain the unique identifier of the server according to a secure hash SHA algorithm, a preset public key, and the broadcast address of the server.
Optionally, the processor 680 is specifically configured to obtain the unique identifier of the server according to a first formula;
the first formula is Uid = AES-CMAC K (PAddr)/mod2 36
The processor 680 is specifically configured to obtain the unique identifier of the server according to a second formula;
the second formula is Uid = MD5 K (PAddr)/mod2 36
Processor 680, specifically for the third formula Uid = SHA K (PAddr)/mod2 36
Wherein Uid is the only identification of the server, AES-CMAC, MD5 and SHA are algorithms for calculating Hash, K is a preset public key, PAddr is the public address of the server, mod2 36 Indicating the 36 lower bits of the result.
Optionally, the unique identifier is added to an attribute value of the database hash feature value of the server.
Optionally, the processor 680 is specifically configured to, when the bluetooth device connects to a server, read an attribute value of a hash feature value of a database of the server if a broadcast address of the server is a random address; and acquiring the unique identifier and the current hash value of the server according to the attribute value of the database hash characteristic value of the server.
Optionally, the processor 680 is further configured to determine that the service provided by the server changes if the current hash value is inconsistent with the historical hash value, and continue to search for the service provided by the server.
Optionally, the processor 680 is further configured to add the current hash value to the historical hash value, and store the added historical hash value in a cache.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can store or a data storage device, such as a server, a data center, etc., that is integrated with one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), among others.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, which are essential or part of the technical solutions contributing to the prior art, or all or part of the technical solutions, may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, and various media capable of storing program codes.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (10)

1. A method for determining that a server provides a service is characterized by comprising the following steps:
when a Bluetooth device is connected with a server, if the broadcast address of the server is a random address, acquiring a unique identifier and a current hash value of the server;
searching a locally stored historical hash value according to the unique identifier;
and if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side.
2. The method of claim 1, wherein the obtaining the unique identifier of the server comprises:
acquiring a unique identifier of the server according to an AES-CMAC algorithm, a preset public key and a broadcast address of the server; or the like, or a combination thereof,
acquiring a unique identifier of the server according to an MD5 information digest algorithm, a preset public key and a broadcast address of the server; or the like, or a combination thereof,
and acquiring the unique identifier of the server according to a secure hash SHA algorithm, a preset public key and the broadcast address of the server.
3. The method according to claim 2, wherein the obtaining the unique identifier of the server according to the AES-CMAC algorithm, the predetermined public key and the broadcast address of the server comprises:
acquiring a unique identifier of the server according to a first formula;
the first formula is Uid = AES-CMAC K (PAddr)/mod2 36
The acquiring the unique identifier of the server according to the MD5 information digest algorithm, the preset public key and the broadcast address of the server includes:
acquiring the unique identifier of the server according to a second formula;
the second formula is Uid = MD5 K (PAddr)/mod2 36
The obtaining the unique identifier of the server according to the secure hash SHA algorithm, the preset public key and the broadcast address of the server includes:
the third formula is Uid = SHA K (PAddr)/mod2 36
Wherein Uid is the only identification of the server, AES-CMAC, MD5 and SHA are algorithms for calculating Hash, K is a preset public key, PAddr is the public address of the server, mod2 36 Indicating the 36 lower bits of the result.
4. The method according to any one of claims 1-3, wherein the unique identifier is added to an attribute value of a database hash feature value of the server.
5. The method according to any one of claims 1 to 3, wherein when the Bluetooth device connects to a server, if the broadcast address of the server is a random address, acquiring a unique identifier and a current hash value of the server includes:
when a Bluetooth device is connected with a server, if the broadcast address of the server is a random address, reading the attribute value of the hash characteristic value of the database of the server;
and acquiring the unique identifier and the current hash value of the server according to the attribute value of the database hash characteristic value of the server.
6. The method according to any one of claims 1-3, further comprising:
and if the current hash value is inconsistent with the historical hash value, determining that the service provided by the server side changes, and continuously searching the service provided by the server side.
7. The method of claim 6, further comprising:
and adding the current hash value into the historical hash value, and storing the added historical hash value in a cache.
8. An apparatus for determining that a server provides a service, comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a unique identifier and a current hash value of a server if a broadcast address of the server is a random address when the Bluetooth equipment is connected with the server;
the processing module is used for searching a locally stored historical hash value according to the unique identifier; and if the current hash value is consistent with the historical hash value, determining that the service provided by the server side is not changed, and stopping searching the service provided by the server side.
9. A bluetooth device, comprising:
a memory storing executable program code;
a processor and a display coupled with the memory;
the processor and the display are respectively used for correspondingly executing the method according to any one of claims 1-7.
10. A computer-readable storage medium comprising instructions that, when executed on a processor, cause the processor to perform the method of any of claims 1-7.
CN202210674724.9A 2022-06-14 2022-06-14 Method and device for determining service provided by server, bluetooth equipment and storage medium Pending CN115226086A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210674724.9A CN115226086A (en) 2022-06-14 2022-06-14 Method and device for determining service provided by server, bluetooth equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210674724.9A CN115226086A (en) 2022-06-14 2022-06-14 Method and device for determining service provided by server, bluetooth equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115226086A true CN115226086A (en) 2022-10-21

Family

ID=83608269

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210674724.9A Pending CN115226086A (en) 2022-06-14 2022-06-14 Method and device for determining service provided by server, bluetooth equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115226086A (en)

Similar Documents

Publication Publication Date Title
US10959124B2 (en) Uplink data transmission method, terminal, network side device and system
CN106101979B (en) Method for short-range wireless communication and electronic device using the same
WO2017185711A1 (en) Method, apparatus and system for controlling smart device, and storage medium
KR102107132B1 (en) Access point connection method of electronic apparatus and electronic appparatus thereof
WO2018120905A1 (en) Message reminding method for terminal, and terminal
CN106446111B (en) Data migration method and terminal
CN108733337B (en) Screen display method and device, electronic equipment and computer readable storage medium
CN106550361B (en) Data transmission method, equipment and computer readable storage medium
CN104683301B (en) Password storage method and device
WO2019052291A1 (en) Unlocking methods and related products
WO2018049935A1 (en) Data migration method and terminals
CN106569910B (en) Data backup and transmission method and mobile terminal
US20210014716A1 (en) Method for processing communication range information and terminal
US20220022148A1 (en) Ssb transmission indication method and apparatus, terminal, device, and medium
WO2018049885A1 (en) Data migration method and device
CN116541865A (en) Password input method, device, equipment and storage medium based on data security
CN106484563B (en) Data migration method and terminal equipment
CN108256466B (en) Data processing method and device, electronic equipment and computer readable storage medium
CN111314900B (en) Wireless connection method, wireless connection device and mobile terminal
WO2017000495A1 (en) Method and device for adding contacts
CN112888024B (en) Data processing method, data processing device, storage medium and electronic equipment
CN107786423A (en) A kind of method and system of instant messaging
CN110602766A (en) Personal hotspot identification method and method for determining association relationship between terminals
CN108804434B (en) Message query method, server and terminal equipment
CN112261634B (en) Bluetooth transmission control method and device, terminal equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination