Data transmission method and apparatus

By associating the identification information of peripheral devices with information and callback methods, the problem of data transmission accuracy and security under multiple low-power Bluetooth device connections is solved, realizing accurate data transmission and status monitoring between mobile phones and peripheral devices.

CN116264677BActive Publication Date: 2026-06-26MIDEA GROUP CO LTD +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
MIDEA GROUP CO LTD
Filing Date
2021-12-13
Publication Date
2026-06-26

Smart Images

  • Figure CN116264677B_ABST
    Figure CN116264677B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of mobile communication, and provides a data transmission method and device.The method comprises the following steps: associating the identification information of a peripheral device with peripheral information of the peripheral device and a callback method; determining a target peripheral device from a plurality of peripheral devices according to the received identification information, and at least one of the peripheral information callback method of the target peripheral device; and performing data transmission between the target peripheral device and an application program according to at least one of the peripheral information and the callback method of the target peripheral device.The data transmission method and device provided by the application can accurately determine the target peripheral device from a plurality of peripheral devices through the identification information of the peripheral device, and the peripheral information and the callback method of the target peripheral device, so that the accurate data transmission between the application program and the target peripheral device is realized, the accuracy of data transmission in the scene of connecting a plurality of peripheral devices is effectively solved, and a good intelligent experience is provided for users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of mobile communication technology, and in particular to data transmission methods and apparatus. Background Technology

[0002] Bluetooth Low Energy (BLE) communication technology is a crucial means for mobile phones to establish connections and communicate with peripherals. The process of establishing a connection between a Bluetooth Low Energy device and a mobile phone, including state management and data interaction, requires manual management by the programmer. However, in communication between a mobile phone and a single Bluetooth Low Energy device, there is no need to consider the accuracy of data transmission or the stability of business logic.

[0003] In scenarios where a mobile phone connects to multiple Bluetooth Low Energy devices, managing the connection process, state management, and data interaction to enable more accurate and stable completion of relevant business tasks has become a problem that must be solved. Summary of the Invention

[0004] This invention aims to at least solve one of the technical problems existing in the prior art. To this end, this invention proposes a data transmission method. According to the data transmission method of this invention, the target peripheral device is accurately identified among multiple peripheral devices through the identification information of the peripheral device, along with the peripheral information of the target peripheral device and the callback method, thereby realizing accurate data transmission between the application and the target peripheral device. This effectively solves the problem of data transmission accuracy in scenarios where multiple peripheral devices are connected, providing users with a good intelligent experience.

[0005] The present invention also proposes a data transmission device.

[0006] A data transmission method according to a first aspect of the present invention includes:

[0007] Associate the identification information of the peripheral device with the peripheral information and callback method of the peripheral device;

[0008] The target peripheral device is determined from a plurality of peripheral devices based on the received identification information, and at least one of the peripheral information and callback method of the target peripheral device is determined.

[0009] Data transmission between the target peripheral device and the application is performed based on at least one of the peripheral information of the target peripheral device and the callback method.

[0010] According to the data transmission method of the present invention, the target peripheral device is accurately identified among multiple peripheral devices by using the identification information of the peripheral device, and the peripheral information and callback method of the target peripheral device are also identified. This enables accurate data transmission between the application and the target peripheral device, effectively solving the problem of data transmission accuracy in scenarios where multiple peripheral devices are connected, and providing users with a good intelligent experience.

[0011] According to one embodiment of the present invention, the data transmission method further includes:

[0012] The identification information of the peripheral device is associated with the encryption and decryption methods of the peripheral device.

[0013] According to the data transmission method of the present invention, by associating the identification information of the peripheral device with the encryption and decryption methods of the peripheral device, the security of data transmission can be guaranteed in scenarios where multiple peripheral devices are connected.

[0014] According to one embodiment of the present invention, the step of determining a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method, includes:

[0015] Receive the first data sent by the target peripheral device;

[0016] The identification information of the target peripheral device is determined from the first data, and the decryption method and data interaction callback method of the target peripheral device are determined based on the identification information of the target peripheral device.

[0017] The decryption method of the target peripheral device is used to decrypt the data to be sent in the first data.

[0018] The data interaction callback method of the target peripheral device is used to send the decrypted data to be sent to the application.

[0019] According to the data transmission method of the present invention, the callback method and decryption method of the target peripheral device are determined by the identification information of the peripheral device, and the data sent by the target peripheral device is sent to the application according to the decryption method and the callback method, thereby realizing the accuracy and security of data transmission between the peripheral device and the application.

[0020] According to one embodiment of the present invention, the step of determining a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method, includes:

[0021] Receive the second data sent by the application;

[0022] The identification information of the target peripheral device is determined from the second data, and the encryption method and peripheral information of the target peripheral device are determined based on the identification information of the target peripheral device.

[0023] The encryption method of the target peripheral device is used to encrypt the data to be sent in the second data.

[0024] The peripheral information of the target peripheral device is used to send the encrypted data to be sent to the target peripheral device.

[0025] According to the data transmission method of the present invention, the peripheral information and encryption method of the target peripheral device are determined by the identification information of the peripheral device, and the data sent by the application is sent to the application according to the encryption method and the peripheral information, thereby realizing the accuracy and security of data transmission between the peripheral device and the application.

[0026] According to one embodiment of the present invention, the step of determining a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method, includes:

[0027] Receive third data sent by the target peripheral device;

[0028] The identification information of the target peripheral device is determined from the third data, and the disconnection callback method of the target peripheral device is determined based on the identification information of the target peripheral device.

[0029] The disconnection callback method of the target peripheral device is used to upload the disconnection information of the target peripheral device to the application.

[0030] According to the data transmission method of this invention, the peripheral device is disconnected from the target peripheral device by using the identification information of the peripheral device, and after receiving the disconnection success information sent by the target peripheral device, the disconnection callback method is called to upload the disconnection information of the target peripheral device to the application, thus ensuring the accuracy of data transmission.

[0031] According to one embodiment of the present invention, the step of determining a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method, includes:

[0032] Receive the fourth data sent by the target peripheral device;

[0033] The identification information of the target peripheral device is determined from the fourth data, and the status callback method of the target peripheral device is determined based on the identification information of the target peripheral device;

[0034] The target peripheral device status callback method is used to upload the status information of the target peripheral device to the application.

[0035] According to the data transmission method of the present invention, the status callback method of the peripheral device is determined by the identification information of the peripheral device, and the status callback method is called to accurately upload the status of the peripheral device to the application, thereby realizing precise monitoring of the status of the peripheral device.

[0036] According to one embodiment of the present invention, associating the identification information of the peripheral device with the peripheral information of the peripheral device and the callback method includes:

[0037] The identification information of the peripheral device is used as the key, the peripheral information of the peripheral device and the callback method are used as the value to form a key-value pair;

[0038] The key-value pairs are stored in a preset device pool.

[0039] According to the data transmission method of the present invention, by forming key-value pairs with identification information as the key and peripheral information and callback method of the peripheral device as the value, and storing them in the device pool, the peripheral information and callback method of the target peripheral device can be directly determined in the device pool, thus ensuring the accuracy of data transmission.

[0040] According to one embodiment of the present invention, the identification information of the peripheral device is determined in the following manner:

[0041] The peripheral device is identified by Bluetooth scanning;

[0042] The system receives broadcast packet data sent by the peripheral device and parses the broadcast packet data to determine the identification information of the peripheral device.

[0043] According to the data transmission method of the present invention, the unique identifier of the peripheral device is determined by parsing the broadcast data sent by the peripheral device, thereby ensuring the accuracy of the identification information of the peripheral device.

[0044] A data transmission apparatus according to a second aspect of the present invention includes:

[0045] The association module is used to associate the identification information of the peripheral device with the peripheral information and callback method of the peripheral device;

[0046] The determination module is configured to determine a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method;

[0047] The transmission module is used to perform data transmission between the target peripheral device and the application based on at least one of the peripheral information of the target peripheral device and the callback method.

[0048] According to the data transmission device of the present invention, the target peripheral device is accurately identified among multiple peripheral devices by using the identification information of the peripheral device, and the peripheral information and callback method of the target peripheral device are also identified. This enables accurate data transmission between the application and the target peripheral device, effectively solving the problem of data transmission accuracy in scenarios where multiple peripheral devices are connected, and providing users with a good intelligent experience.

[0049] An electronic device according to a third aspect of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of any of the data transmission methods described above.

[0050] According to a fourth aspect of the present invention, a non-transitory computer-readable storage medium is provided thereon storing a computer program that, when executed by a processor, implements the steps of any of the above-described data transmission methods.

[0051] The above-described one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:

[0052] By accurately identifying the target peripheral device among multiple peripheral devices using the identification information of the peripheral device, along with the peripheral information and callback method of the target peripheral device, accurate data transmission between the application and the target peripheral device is achieved. This effectively solves the problem of data transmission accuracy in scenarios where multiple peripheral devices are connected, providing users with a good intelligent experience.

[0053] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0054] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0055] Figure 1 This is a flowchart illustrating the data transmission method provided in an embodiment of the present invention;

[0056] Figure 2 This is one of the flowcharts illustrating the data transmission method provided in the embodiments of the present invention;

[0057] Figure 3 This is a second schematic flowchart illustrating the data transmission method provided in the embodiments of the present invention;

[0058] Figure 4 This is a schematic diagram of the data transmission device provided in an embodiment of the present invention;

[0059] Figure 5 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation

[0060] The embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and should not be construed as limiting the scope of the invention.

[0061] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0062] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0063] Figure 1 This is a flowchart illustrating the data transmission method provided in an embodiment of the present invention, with reference to... Figure 1 The data transmission method provided in this embodiment of the invention includes the following steps:

[0064] Step 110: Associate the identification information of the peripheral device with the peripheral information and callback method of the peripheral device;

[0065] Step 120: Determine the target peripheral device from multiple peripheral devices based on the received identification information, and at least one of the peripheral information and callback method of the target peripheral device;

[0066] Step 130: Perform data transmission between the target peripheral device and the application based on at least one of the peripheral information of the target peripheral device and the callback method.

[0067] It should be noted that the data transmission method provided by this invention can be executed by a mobile electronic device, such as a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc., and this invention does not impose specific limitations. The following describes the technical solution of this invention in detail using a mobile phone executing the data transmission method provided in this embodiment as an example.

[0068] Optionally, in step 110, the identification information of the peripheral device is associated with the peripheral information of the peripheral device and the callback method.

[0069] When a mobile phone establishes a Bluetooth connection with a peripheral device, it records the device's identification information (denoted as key), peripheral information (denoted as peripheral), and callback methods, and associates and stores the identification information, peripheral information, and callback methods of each peripheral device.

[0070] The identification information refers to the unique identifier of the peripheral device, such as the address of the peripheral device, such as the Universal Unique Identifier (UUID) or the Media Access Control (MAC) address.

[0071] Optionally, when the mobile phone scans nearby peripheral devices as the central device, it saves the relevant information of the peripheral devices. iOS can use the UUID of the peripheral device as the unique identifier of the peripheral device (denoted as key), while Android can use the MAC address of the peripheral device as the key.

[0072] Peripheral information refers to the parameter information of peripheral devices, which may include, for example, the device name, the device signal strength, the device model, etc.

[0073] Callback methods are functions registered by the business layer to the connection layer for data communication. Callback methods can include status callback methods, data interaction callback methods, and disconnection callback methods. By associating the peripheral device's key with the callback method, the callback method can be saved using the key as a unique identifier.

[0074] In step 120, a target peripheral device is determined from multiple peripheral devices based on the received identification information, and at least one of the peripheral information and callback method of the target peripheral device is determined.

[0075] Based on step 110, the peripheral device's identification information, peripheral information, and callback method have been linked together. By determining the peripheral device's identification information from the data sent by the application (APP) or peripheral device, the target peripheral device, along with its peripheral information and callback method, can be identified from among multiple peripheral devices simultaneously connected to the mobile phone.

[0076] In step 130, data transmission between the target peripheral device and the application is performed based on at least one of the peripheral device information and callback method. Data sent by the application can be sent to the peripheral device via the target peripheral device's peripheral information; alternatively, data sent by the target peripheral device can be sent to the application via the target peripheral device's callback method. This achieves accurate data transmission between the target peripheral device and the application.

[0077] For example, Figure 2 This is one of the flowcharts illustrating the data transmission method provided in the embodiments of the present invention, see below. Figure 2 ,

[0078] When the phone enables Bluetooth scanning, it scans for devices A, B, and C, and records the device identification information (key), peripheral information, and callback method for each device.

[0079] When initiating a connection request to device A, the key1, peripheral1, and callback1 of device A are associated and stored; similarly, when initiating a connection request to device B, the key2, peripheral2, and callback2 of device B are associated and stored; and when initiating a connection request to device C, the key3, peripheral3, and callback3 of device C are associated and stored. As shown in Table 1:

[0080] Table 1. Related device information

[0081] Equipment A key1-peripheral1-callback1 Equipment B key2-peripheral2-callback2 Equipment C key3-peripheral3-callback3 … …

[0082] When a mobile phone is connected to multiple peripheral devices, by parsing the data sent by the peripheral devices and determining the key, it can be determined which device sent the data. Based on the key, the callback can be determined, and the data can be sent to the APP through the callback, thus realizing the data transmission between peripheral devices and the APP.

[0083] By parsing the data sent by the app and determining the key, it is possible to determine which device the data is to be sent to. Based on the key, the peripheral can be determined, and the data can be sent to the target peripheral device through the peripheral, thus realizing data transmission between the peripheral device and the app.

[0084] The data transmission method provided in this invention accurately identifies the target peripheral device among multiple peripheral devices by using the identification information of the peripheral device, along with the peripheral information and callback method of the target peripheral device. This enables accurate data transmission between the application and the target peripheral device, effectively solving the problem of data transmission accuracy in scenarios where multiple peripheral devices are connected, and providing users with a good intelligent experience.

[0085] In one embodiment, the data transmission method provided by this invention further includes:

[0086] Associate the identification information of peripheral devices with their encryption and decryption methods.

[0087] Optionally, once the mobile phone and peripheral device are successfully connected, they can negotiate a key to ensure the accuracy of the connection and data transmission. Therefore, when establishing a Bluetooth connection between the mobile phone and the peripheral device, different keys can be set for different peripheral devices and recorded to obtain the encryption and decryption methods of the peripheral devices.

[0088] By associating the encryption and decryption methods of peripheral devices with their identification information, the target peripheral device can be identified after obtaining the identification information, and the decryption and encryption methods of the target peripheral device can also be determined.

[0089] The data transmission method provided in this embodiment of the invention can ensure the security of data transmission in scenarios where multiple external devices are connected by associating the identification information of the peripheral device with the encryption and decryption methods of the peripheral device.

[0090] In one embodiment, determining a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method, includes:

[0091] Receive the first data sent by the target peripheral device;

[0092] The identification information of the target peripheral device is determined from the first data, and the decryption method and data interaction callback method of the target peripheral device are determined based on the identification information of the target peripheral device.

[0093] The decryption method of the target peripheral device is used to decrypt the data to be sent in the first data.

[0094] The data interaction callback method of the target peripheral device is used to send the decrypted data to be sent to the application.

[0095] Optionally, after the mobile phone establishes a Bluetooth connection with the peripheral device, data interaction can be performed.

[0096] When the target peripheral device sends data to the app, it first sends the data to the phone. After receiving the data sent by the target peripheral device, the phone parses the data to obtain the identification information of the target peripheral device. This allows it to identify the target peripheral device from among multiple connected peripheral devices, as well as the decryption method and data interaction callback method of the target peripheral device.

[0097] The received data is decrypted using the Bluetooth protocol and the target peripheral device's decryption method, and then sent to the app via a data interaction callback method. Once the app receives the data, it can perform subsequent business operations. The app can also inform the user of data sent by the target peripheral device via voice, text, or video.

[0098] The data transmission method provided in this embodiment of the invention determines the callback method and decryption method of the target peripheral device through the identification information of the peripheral device, and sends the data sent by the target peripheral device to the application according to the decryption method and the callback method, thereby realizing the accuracy and security of data transmission between the peripheral device and the application.

[0099] In one embodiment, determining a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method, includes:

[0100] Receive the second data sent by the application;

[0101] The identification information of the target peripheral device is determined from the second data, and the encryption method and peripheral information of the target peripheral device are determined based on the identification information of the target peripheral device.

[0102] The encryption method of the target peripheral device is used to encrypt the data to be sent in the second data.

[0103] The peripheral information of the target peripheral device is used to send the encrypted data to the target peripheral device.

[0104] Optionally, after the mobile phone and the peripheral device establish a Bluetooth connection, data interaction can begin. When the APP sends data to the peripheral device, it first sends the data to the mobile phone. After receiving the data sent by the APP, the mobile phone parses the data sent by the APP to obtain the identification information of the target peripheral device. It can then identify the target peripheral device from among the multiple connected peripheral devices, as well as the encryption method and peripheral information of the target peripheral device.

[0105] The data sent by the APP is assembled according to the Bluetooth protocol, then encrypted using encryption methods, and finally sent to the target peripheral device according to the peripheral device information.

[0106] The data transmission method provided in this invention determines the peripheral information and encryption method of the target peripheral device through the identification information of the peripheral device, and sends the data sent by the application to the target peripheral device according to the encryption method and the peripheral information, thereby achieving the accuracy and security of data transmission between the peripheral device and the application.

[0107] In one embodiment, determining a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method, includes:

[0108] Receive third data sent by the target peripheral device;

[0109] The identification information of the target peripheral device is determined from the third data, and the disconnection callback method of the target peripheral device is determined based on the identification information of the target peripheral device;

[0110] The disconnection callback method for the target peripheral device is used to upload the disconnection information of the target peripheral device to the application.

[0111] Optionally, when the mobile phone actively disconnects from the target peripheral device, the target peripheral device is identified based on the device's identification information, the disconnection method is executed, and a callback notification of successful disconnection is awaited.

[0112] When a callback indicating a successful passive disconnection is received from the target peripheral device, or a callback indicating that the target peripheral device has actively disconnected the Bluetooth connection, the disconnection callback method of the target peripheral device can be determined based on the device's identification information. By calling the disconnection callback method, the device disconnection information can be accurately reported to the APP.

[0113] At the same time, based on the identification information of the target peripheral device, the pre-stored peripheral information and callback methods of the target peripheral device are cleared.

[0114] The data transmission method provided in this embodiment of the invention disconnects from the target peripheral device using the identification information of the peripheral device, and after receiving the disconnection success information sent by the target peripheral device, calls the disconnection callback method to upload the disconnection information of the target peripheral device to the application, thus ensuring the accuracy of data transmission.

[0115] In one embodiment, determining a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method, includes:

[0116] Receive the fourth data sent by the target peripheral device;

[0117] The identification information of the target peripheral device is determined from the fourth data, and the status callback method of the target peripheral device is determined based on the identification information of the target peripheral device;

[0118] The target peripheral device's status callback method is used to upload the target peripheral device's status information to the application.

[0119] Optionally, during the connection process with the peripheral device, the system can monitor changes in the Bluetooth status and connection status of the target peripheral device and monitor the status information of the peripheral device in real time.

[0120] Based on the data sent by the peripheral device, find the status callback method of the peripheral device. By calling the callback method of the peripheral device, the current status of the peripheral device can be reported to the APP, so as to accurately know the current status of the device.

[0121] The data transmission method provided in this embodiment of the invention determines the status callback method of the peripheral device through the identification information of the peripheral device, and then calls the status callback method to accurately upload the status of the peripheral device to the application, thereby realizing precise monitoring of the status of the peripheral device.

[0122] In one embodiment, associating the identification information of the peripheral device with the peripheral information of the peripheral device and the callback method includes:

[0123] The peripheral device's identification information is used as the key, and the peripheral device's peripheral information and callback method are used as the value to form a key-value pair;

[0124] Store key-value pairs in a preset device pool.

[0125] Optionally, when initiating a Bluetooth connection to a peripheral device, a device pool is created, with the peripheral device's identification information as the key and the peripheral device's peripheral information and callback method as the value, forming key-value pairs, and the key-value pairs are stored in the device pool.

[0126] The data transmission method provided in this embodiment of the invention forms key-value pairs using identification information as the key and peripheral information and callback method of the peripheral device as the value, and stores them in the device pool. This allows the peripheral information and callback method of the target peripheral device to be determined directly in the device pool, ensuring the accuracy of data transmission.

[0127] In one embodiment, the identification information of the peripheral device is determined in the following way:

[0128] Identify peripheral devices via Bluetooth scanning;

[0129] It receives broadcast packet data sent by peripheral devices and parses the broadcast packet data to determine the identification information of the peripheral devices.

[0130] Optionally, power on the peripheral device and set it to Bluetooth broadcast mode, allowing it to be discovered by the mobile phone as the central Bluetooth administrator. Open the app, obtain Bluetooth permissions, and turn on the phone's Bluetooth; use the mobile phone as the Bluetooth central device, and set the peripheral's service UUID and rules for discovering the peripheral device.

[0131] When a mobile phone enables Bluetooth to scan for nearby peripheral devices, it receives broadcast packet data sent by the peripheral devices. By parsing the peripheral device broadcast packet data, the UUID or MAC of the peripheral device can be obtained, which is the identification information of the peripheral device.

[0132] The data transmission method provided in this embodiment of the invention determines the unique identifier of the peripheral device by parsing the broadcast data sent by the peripheral device, thus ensuring the accuracy of the peripheral device's identification information.

[0133] Figure 2 This is one of the flowcharts illustrating the data transmission method provided in the embodiments of the present invention. Figure 3 This is a second schematic flowchart illustrating the data transmission method provided in this embodiment of the invention, referred to... Figure 2 and Figure 3 The data transmission method provided in this embodiment of the invention includes the following steps:

[0134] Step 1: When the mobile phone scans nearby peripheral devices as the central device, it saves the relevant information of the peripheral devices. iOS can use the peripheral device's UUID as its unique identifier (denoted as the key, the same below), while Android can use the peripheral device's MAC address as the key. The specific steps are as follows:

[0135] 1. Power on the Bluetooth device and put it into Bluetooth broadcast mode so that the device can be discovered by a Bluetooth administrator using a mobile phone as the central hub;

[0136] 2. Open the app, obtain Bluetooth permission, and turn on your phone's Bluetooth; use your phone as the Bluetooth central device, and set the service UUID of the peripheral device and the rules for discovering the device;

[0137] 3. The phone enables Bluetooth to scan and discover nearby peripherals, receives broadcast packet data sent by nearby peripherals, parses the broadcast packet data, and obtains the UUID or MAC of the peripheral object;

[0138] 4. Determine the target device according to the rules for discovering peripherals, record the peripheral object (denoted as peripheral), and record the unique identifier key corresponding to the peripheral, then stop scanning.

[0139] Step 2: When connecting devices and communicating data, the status callbacks and data communication during the Bluetooth connection establishment process between the phone and the peripheral device need to find the corresponding peripheral device in the device pool through the key to ensure accurate data transmission. The specific steps are as follows:

[0140] 1. Based on the peripheral device obtained in step 1, the central device initiates a connection request to the peripheral device;

[0141] 2. Create a device pool, and store device information such as the peripheral and callback methods in the device pool using the key and peripheral of the peripheral device as key-value pairs;

[0142] 3. Monitor changes in Bluetooth status and connection status during the connection process, find the status callback method of the target peripheral device in the device pool based on the peripheral key, and call the callback method to report the status of the target peripheral device to the upper-layer business.

[0143] 4. After successful connection, key negotiation will be performed to ensure the security of Bluetooth connection and data exchange;

[0144] 5. Entering the data interaction stage, when the mobile phone receives data sent by the target peripheral device, it first determines the key in the peripheral. Based on the key in the device pool, it determines the data interaction callback method and decryption method in the device information. It decrypts the data according to the Bluetooth protocol and decryption method, and reports the decrypted data to the APP through the data interaction callback method.

[0145] 6. When the APP needs to send data to the device, it assembles the data according to the Bluetooth protocol and then encrypts the data using an encryption method; based on the key sent in, it finds the peripheral in the device pool, and the Bluetooth central administrator sends the encrypted data to the target peripheral device.

[0146] Step 3: When disconnecting the device, if the phone loses connection with the peripheral, the corresponding peripheral needs to be located in the device pool using the key. The connection to the corresponding peripheral should be canceled and the data cleared. The specific steps are as follows:

[0147] 1. When the phone actively disconnects from the peripheral device, the peripheral is located based on the key, the disconnect method is executed, and a callback notification of successful disconnection is awaited;

[0148] 2. When a callback for successful passive disconnection or a callback for active Bluetooth disconnection is received, the disconnection callback method in the device information in the device pool is obtained based on the peripheral key, and the device disconnection information is accurately reported to the APP.

[0149] 3. Clear the device information in the device pool using the key, and the device connection ends.

[0150] Based on the above steps, by storing device information such as the peripheral device's unique identifier key, status callback methods, data interaction callback methods, and disconnection callback methods, the system can accurately locate the corresponding device callback method when a relevant service is detected, and report the data to the upper-level business layer. The upper-level business layer can then accurately process the service, thereby ensuring the stability of the app's functionality. Furthermore, these steps ensure that when the phone is connected to multiple devices, it can accurately notify the specific devices during device connection, data transmission, and connection termination, further enhancing the stability of the upper-level business logic.

[0151] Figure 4 This is a schematic diagram of the structure of a data transmission device provided in an embodiment of the present invention. (Refer to...) Figure 4 The data transmission device provided by the present invention includes:

[0152] The association module 410 is used to associate the identification information of the peripheral device with the peripheral information and callback method of the peripheral device;

[0153] The determination module 420 is used to determine the target peripheral device from multiple peripheral devices based on the received identification information, and at least one of the peripheral information of the target peripheral device and the callback method;

[0154] The transmission module 430 is used to perform data transmission between the target peripheral device and the application based on at least one of the peripheral information of the target peripheral device and the callback method.

[0155] The data transmission device provided in this embodiment of the invention accurately identifies the target peripheral device among multiple peripheral devices through the identification information of the peripheral device, as well as the peripheral information and callback method of the target peripheral device, thereby realizing accurate data transmission between the application and the target peripheral device. This effectively solves the problem of data transmission accuracy in scenarios where multiple peripheral devices are connected, and provides users with a good intelligent experience.

[0156] In one embodiment, the data transmission apparatus provided by this invention further includes:

[0157] The second association module is used to associate the identification information of peripheral devices with the encryption and decryption methods of peripheral devices.

[0158] In one embodiment, the determining module 420 is specifically used for:

[0159] Receive the first data sent by the target peripheral device;

[0160] The identification information of the target peripheral device is determined from the first data, and the decryption method and data interaction callback method of the target peripheral device are determined based on the identification information of the target peripheral device.

[0161] The decryption method of the target peripheral device is used to decrypt the data to be sent in the first data.

[0162] The data interaction callback method of the target peripheral device is used to send the decrypted data to be sent to the application.

[0163] In one embodiment, the determining module 420 is specifically used for:

[0164] Receive the second data sent by the application;

[0165] The identification information of the target peripheral device is determined from the second data, and the encryption method and peripheral information of the target peripheral device are determined based on the identification information of the target peripheral device.

[0166] The encryption method of the target peripheral device is used to encrypt the data to be sent in the second data.

[0167] The peripheral information of the target peripheral device is used to send the encrypted data to the target peripheral device.

[0168] In one embodiment, the determining module 420 is specifically used for:

[0169] Receive third data sent by the target peripheral device;

[0170] The identification information of the target peripheral device is determined from the third data, and the disconnection callback method of the target peripheral device is determined based on the identification information of the target peripheral device;

[0171] The disconnection callback method for the target peripheral device is used to upload the disconnection information of the target peripheral device to the application.

[0172] In one embodiment, the determining module 420 is specifically used for:

[0173] Receive the fourth data sent by the target peripheral device;

[0174] The identification information of the target peripheral device is determined from the fourth data, and the status callback method of the target peripheral device is determined based on the identification information of the target peripheral device;

[0175] The target peripheral device's status callback method is used to upload the target peripheral device's status information to the application.

[0176] In one embodiment, the association module 410 is specifically used for:

[0177] The peripheral device's identification information is used as the key, and the peripheral device's peripheral information and callback method are used as the value to form a key-value pair;

[0178] Store key-value pairs in a preset device pool.

[0179] In one embodiment, the identification information of the peripheral device is determined in the following way:

[0180] Identify peripheral devices via Bluetooth scanning;

[0181] It receives broadcast packet data sent by peripheral devices and parses the broadcast packet data to determine the identification information of the peripheral devices.

[0182] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute the following methods:

[0183] Associate the identification information of the peripheral device with the peripheral device's peripheral information and callback method;

[0184] The target peripheral device is determined from multiple peripheral devices based on the received identification information, and at least one of the peripheral information of the target peripheral device and the callback method is selected.

[0185] Data transfer between the target peripheral device and the application is performed based on at least one of the peripheral device information and callback methods of the target peripheral device.

[0186] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0187] Furthermore, this invention discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when these instructions are executed by a computer, the computer can perform the data transmission methods provided in the above-described method embodiments, such as:

[0188] Associate the identification information of the peripheral device with the peripheral device's peripheral information and callback method;

[0189] The target peripheral device is determined from multiple peripheral devices based on the received identification information, and at least one of the peripheral information of the target peripheral device and the callback method is selected.

[0190] Data transfer between the target peripheral device and the application is performed based on at least one of the peripheral device information and callback methods of the target peripheral device.

[0191] On the other hand, embodiments of the present invention also provide a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is implemented to perform the data transmission methods provided in the above embodiments, including, for example:

[0192] Associate the identification information of the peripheral device with the peripheral device's peripheral information and callback method;

[0193] The target peripheral device is determined from multiple peripheral devices based on the received identification information, and at least one of the peripheral information of the target peripheral device and the callback method is selected.

[0194] Data transfer between the target peripheral device and the application is performed based on at least one of the peripheral device information and callback methods of the target peripheral device.

[0195] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0196] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0197] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

[0198] The above embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. Although the invention has been described in detail with reference to the embodiments, those skilled in the art should understand that various combinations, modifications, or equivalent substitutions of the technical solutions of the invention do not depart from the spirit and scope of the invention and should be covered within the scope of the claims of the invention.

Claims

1. A data transmission method, characterized in that, include: Associate the identification information of the peripheral device with the peripheral information and callback method of the peripheral device; The target peripheral device is determined from a plurality of peripheral devices based on the received identification information, and at least one of the peripheral information and callback method of the target peripheral device is determined. Data transmission between the target peripheral device and the application is performed based on at least one of the peripheral device information and callback method of the target peripheral device. Associating the identification information of the peripheral device with the encryption and decryption methods of the peripheral device; The association of the peripheral device's identification information with the peripheral device's peripheral information and callback method includes: When multiple peripheral devices are connected, the identification information of the peripheral devices is used as the key, the peripheral information of the peripheral devices and the callback method are used as the value to form a key-value pair; The key-value pairs are stored in a preset device pool.

2. The data transmission method according to claim 1, characterized in that, The step of determining the target peripheral device from a plurality of peripheral devices based on the received identification information, and at least one of the peripheral information of the target peripheral device and a callback method, includes: Receive the first data sent by the target peripheral device; The identification information of the target peripheral device is determined from the first data, and the decryption method and data interaction callback method of the target peripheral device are determined based on the identification information of the target peripheral device. The decryption method of the target peripheral device is used to decrypt the data to be sent in the first data. The data interaction callback method of the target peripheral device is used to send the decrypted data to be sent to the application.

3. The data transmission method according to claim 1, characterized in that, The step of determining the target peripheral device from a plurality of peripheral devices based on the received identification information, and at least one of the peripheral information of the target peripheral device and a callback method, includes: Receive the second data sent by the application; The identification information of the target peripheral device is determined from the second data, and the encryption method and peripheral information of the target peripheral device are determined based on the identification information of the target peripheral device. The encryption method of the target peripheral device is used to encrypt the data to be sent in the second data. The peripheral information of the target peripheral device is used to send the encrypted data to be sent to the target peripheral device.

4. The data transmission method according to claim 1, characterized in that, The step of determining the target peripheral device from a plurality of peripheral devices based on the received identification information, and at least one of the peripheral information of the target peripheral device and a callback method, includes: Receive third data sent by the target peripheral device; The identification information of the target peripheral device is determined from the third data, and the disconnection callback method of the target peripheral device is determined based on the identification information of the target peripheral device; The disconnection callback method of the target peripheral device is used to upload the disconnection information of the target peripheral device to the application.

5. The data transmission method according to claim 1, characterized in that, The step of determining the target peripheral device from a plurality of peripheral devices based on the received identification information, and at least one of the peripheral information of the target peripheral device and a callback method, includes: Receive the fourth data sent by the target peripheral device; The identification information of the target peripheral device is determined from the fourth data, and the status callback method of the target peripheral device is determined based on the identification information of the target peripheral device; The target peripheral device status callback method is used to upload the status information of the target peripheral device to the application.

6. The data transmission method according to any one of claims 1-5, characterized in that, The identification information of the peripheral device is determined in the following way: The peripheral device is identified by Bluetooth scanning; The system receives broadcast packet data sent by the peripheral device and parses the broadcast packet data to determine the identification information of the peripheral device.

7. A data transmission device, characterized in that, include: The association module is used to associate the identification information of the peripheral device with the peripheral information and callback method of the peripheral device; The determination module is configured to determine a target peripheral device from a plurality of peripheral devices based on received identification information, and at least one of peripheral information of the target peripheral device and a callback method; The transmission module is used to perform data transmission between the target peripheral device and the application based on at least one of the peripheral information of the target peripheral device and the callback method; The device further includes a second association module, specifically used for: Associating the identification information of the peripheral device with the encryption and decryption methods of the peripheral device; The associated module is specifically used for: When multiple peripheral devices are connected, the identification information of the peripheral devices is used as the key, the peripheral information of the peripheral devices and the callback method are used as the value to form a key-value pair; The key-value pairs are stored in a preset device pool.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the data transmission method as described in any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the data transmission method as described in any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the data transmission method as described in any one of claims 1 to 6.