Data interaction method and device, storage medium and equipment
By searching and subscribing to the broadcast of Bluetooth devices between devices, and directly sending data request broadcasts to obtain service data packets, the problem of cumbersome and inefficient data interaction between devices in the prior art is solved, and a more efficient and concise data interaction process is achieved. .
Patent Information
- Application Number
- CN202410953972.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2025-02-14
AI Technical Summary
In the prior art, the data interaction process between devices is cumbersome and inefficient, especially when the device needs to actively acquire data from another device, it needs to pass through application software and intermediate devices, resulting in complex and time-consuming process.
By searching for Bluetooth devices within a preset range, determine the device that has subscribed to its broadcast, and send a data request to broadcast to obtain the required service data packet. This method directly performs data interaction between devices without waiting for data accumulation or through application software operations.
The data interaction efficiency between devices is improved, making the process simpler and more direct. The first device can actively obtain data from other devices without the need to rely on intermediate devices, and save power and resources.
Smart Images

Figure CN119449816A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a data interaction method, device, storage medium and equipment. Background Art
[0002] With the development of technology, data exchange between devices through wireless communication is becoming more and more common. If one device wants to obtain data from another device, there are two ways to obtain data.
[0003] For example, in the scenario of data transmission between the first device and the second device, if the first device wants to obtain the data of the second device, the first way is to wait for the data in the second device to accumulate to a certain level, and then the second device sends the data to the first device; the second way is that if the user wants to obtain the data of the second device and display it in the first device, a series of cumbersome operations are required to obtain the data of the second device. For example, if a smart water dispenser (i.e., the first device) wants to obtain the drinking data of the smart water cup (i.e., the second device) and display it, the user can first start the application software for the smart water dispenser installed on the terminal device, and then the user controls the smart water dispenser through the application software to send a request to the smart water cup to obtain the drinking data and display it on the screen of the smart water dispenser. It can be clearly seen that this process is cumbersome and the waiting time is long.
[0004] Therefore, how to improve the efficiency of data interaction between devices and make the data interaction process simpler is an urgent problem to be solved. Summary of the invention
[0005] The present application provides a data interaction method, apparatus, storage medium and device to improve the efficiency of data interaction and make the data interaction process simpler.
[0006] This application adopts the following technical solutions:
[0007] This application provides a data interaction method, including:
[0008] Search for Bluetooth devices within the preset range and obtain a list of Bluetooth devices;
[0009] Determine whether there is a Bluetooth device in the Bluetooth device list that has subscribed to its broadcast, and if so, use the Bluetooth device in the Bluetooth device list that has subscribed to its broadcast as the second device;
[0010] Sending a data request broadcast to the second device;
[0011] receiving a service data packet broadcasted and returned by the second device in response to the data request;
[0012] Determine whether the service data carried in the service data packet needs to be processed by itself;
[0013] If so, the business data is sent to its own electronic control module, and the business data is processed by the electronic control module.
[0014] In the present application, the first device can actively request to obtain data from other devices without waiting, nor does it need to perform data request operations through application software and use "intermediate devices" to achieve data interaction. The first device and the second device directly interact with each other, which improves the data interaction efficiency and makes the data interaction process simpler.
[0015] Optionally, before sending the data request broadcast for the second device, the method further includes:
[0016] Determine whether the time from the last receipt of the service data packet returned by the second device is not less than a preset time;
[0017] Sending a data request broadcast to the second device includes:
[0018] If the time from the last receipt of the service data packet returned by the second device to the preset time is not less than the preset time, a data request broadcast is sent to the second device.
[0019] In the present application, a data request broadcast can be sent only when the time since the last service data packet returned by the second device was received is not less than a preset time to control the frequency of data interaction.
[0020] Optionally, determining whether there is a Bluetooth device in the Bluetooth device list that has subscribed to its broadcast includes:
[0021] Obtaining a preset whitelist, the preset whitelist including unique device identifiers of Bluetooth devices that have subscribed to its broadcast;
[0022] For each Bluetooth device in the Bluetooth device list, determining whether the unique device identifier of the Bluetooth device matches the unique device identifier in the preset whitelist;
[0023] If so, it is determined that the broadcast of the Bluetooth device has been subscribed.
[0024] In this application, a preset whitelist is provided, in which the unique device identifiers of subscribed Bluetooth devices are stored, and the first device generates a data request broadcast according to the preset whitelist and the Bluetooth device list. The first device can only send a data request broadcast to devices that have subscribed to the broadcast, thereby improving the accuracy and efficiency of data interaction.
[0025] Optionally, before sending the data request broadcast for the second device, the method further includes:
[0026] Acquire a service identifier of the second device, where the service identifier is used to identify each service data;
[0027] A data request broadcast for the second device is generated according to the service identifier of the second device.
[0028] The present application can generate a data request broadcast according to the acquired service identifier of the second device, so that corresponding service data can be obtained according to the service identifier.
[0029] Optionally, the service data packet carries a unique device identifier of the second device;
[0030] Before determining whether the service data carried in the service data packet needs to be processed by itself, the method further includes:
[0031] Determining whether the unique device identifier of the second device carried in the service data packet is in the preset whitelist;
[0032] If it is determined that the unique device identifier of the second device carried in the service data packet is in the preset white list, it is determined whether the service data carried in the service data packet needs to be processed by itself.
[0033] The present application first determines whether the received service data packet comes from a device whose broadcast it has subscribed to, and then determines whether the service data needs to be processed. That is, the first device will only process the service data packet sent by the second device if it has subscribed to the broadcast of the second device, thereby improving the accuracy and efficiency of data interaction and processing.
[0034] Optionally, the service data packet carries a service identifier of the second device and service data corresponding to the service identifier, and the preset whitelist further includes service identifiers of Bluetooth devices that have subscribed to its broadcast, and the service identifier is used to identify each service data;
[0035] Before determining whether the service data carried in the service data packet needs to be processed by itself, the method further includes:
[0036] Determine whether the service identifier carried in the service data packet is in the preset whitelist;
[0037] If the service identifier carried in the service data packet is in the preset white list, it is determined whether the service data carried in the service data packet needs to be processed by itself.
[0038] In this application, before processing a business data packet, it is also necessary to determine whether the business data in the business data packet is the business data required by itself. Only after it is determined that the business data carried in the business data packet is in the preset whitelist, can it continue to determine whether to process the business data for local consumption.
[0039] Optionally, before sending the service data to its own electric control module, the method further includes:
[0040] The business data is verified.
[0041] This application verifies the business data before processing it to avoid situations where the business data format is illegal or the business data cannot be processed.
[0042] Optionally, determining whether the business data needs to be processed by itself includes:
[0043] Obtaining an electronic control firmware consumption data identifier corresponding to the business data carried in the business data packet;
[0044] Determining whether the electronic control firmware consumption data identifier is a preset electronic control identifier;
[0045] If so, the business data needs to be processed by itself;
[0046] If not, the business data does not need to be processed itself.
[0047] In the present application, when the electronic control firmware consumption data identifier is a preset electronic control identifier, the electronic control module performs local consumption processing on the business data, so that the first device uses the data of the second device for consumption processing, thereby improving data utilization.
[0048] Optionally, the service data packet is determined by the second device when it is determined that the unique device identifier carried in the data request broadcast is the unique device identifier of the second device, and the service identifier carried in the data request broadcast is in the service identifier list of the second device, wherein the service identifier is used to identify each service data.
[0049] In the present application, before the second device determines the service data packet, it first determines that the unique device identifier in the data request broadcast is the unique device identifier of the second device, and that the service identifier carried by the data request broadcast is in the service identifier list of the second device, and then it responds to the data request to avoid unnecessary communication and data interaction.
[0050] Optionally, the service data packet is determined by the second device when it is determined that service data corresponding to the service identifier carried in the data request broadcast is stored in a designated storage space of the second device.
[0051] In the present application, before determining the service data packet, the second device determines whether there is corresponding service data in the designated storage space to avoid broadcasting empty packets and causing waste of resources.
[0052] The present application provides a data interaction device, comprising:
[0053] A search module, used to search for Bluetooth devices within a preset range and obtain a list of Bluetooth devices;
[0054] A judging module, configured to judge whether there is a Bluetooth device in the Bluetooth device list that has subscribed to its broadcast, and if so, use the Bluetooth device in the Bluetooth device list that has subscribed to its broadcast as the second device;
[0055] A sending module, configured to send a data request broadcast to the second device;
[0056] A receiving module, configured to receive a service data packet broadcasted and returned by the second device in response to the data request;
[0057] The processing module is used to determine whether the business data carried in the business data packet needs to be processed by itself; if so, the business data is sent to its own electronic control module, and the business data is processed by the electronic control module.
[0058] The present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned data interaction method is implemented.
[0059] The present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned data interaction method when executing the program.
[0060] At least one of the above technical solutions adopted in this application can achieve the following beneficial effects:
[0061] In the data interaction method provided by the present application, a Bluetooth device within a preset range is searched to obtain a Bluetooth device list, and a Bluetooth device in the Bluetooth device list that has subscribed to its broadcast is used as a second device. Then a data request broadcast is sent to the second device, and a service data packet returned by the second device in response to the data request broadcast is received. It is determined whether the service data carried in the service data packet needs to be processed by itself. If so, the service data is sent to its own electronic control module, and the service data is processed by the electronic control module.
[0062] It can be seen from the above method that in this application, the first device actively sends a broadcast to the surrounding devices to request the required business data. Then, the business data packets replied by other devices are received and consumed, so that the first device can obtain the data of other devices, so as to expand the functions and application scenarios of the first device and improve data utilization. In this application, the first device does not passively wait for other devices to broadcast business data, but actively obtains business data from other devices, and does not need to use additional tools or "intermediate devices" to realize data interaction, which improves the efficiency of data interaction and makes the interaction between devices more concise. And the first device only broadcasts request data when it searches for the existence of a second device in the surrounding area. The timing of broadcasting is also strategic, which avoids blindly requesting data and causing invalid data interaction processes, and also has energy-saving and power-saving effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the specification of the present application. The illustrative embodiments and descriptions of the specification of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0064] Figure 1 A flowchart of a data interaction method provided in this application;
[0065] Figure 2 A schematic diagram of a storage format of a preset whitelist is provided for this application;
[0066] Figure 3 A schematic diagram of a storage format of a preset whitelist is provided for this application;
[0067] Figure 4 A timing diagram of data interaction provided for this application;
[0068] Figure 5 A schematic diagram of a data interaction device provided by the present application;
[0069] Figure 6 A method corresponding to the present application Figure 1 Schematic diagram of electronic equipment. DETAILED DESCRIPTION
[0070] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0071] With the development of science and technology, the data interaction between two devices is usually wireless communication. Generally, the data interaction between two devices needs to be completed through applications or applets, which is a cumbersome process, or forwarded with the help of "intermediate devices" (such as gateways, cloud platforms, etc.) to achieve data interaction between the two devices. In addition, the party obtaining the data can only receive the data passively, the interaction efficiency is not high enough, and there is no specific strategy method for actively obtaining data from other devices.
[0072] Based on this, the present application provides a data interaction method, which searches for Bluetooth devices within a preset range, obtains a list of Bluetooth devices, and uses the Bluetooth devices in the Bluetooth device list that have subscribed to its broadcast as the second device. Then send a data request broadcast for the second device, and receive a business data packet returned by the second device in response to the data request broadcast. Determine whether the business data carried in the business data packet needs to be processed by itself. If so, send the business data carried in the business data packet to its own electronic control module, and process the business data carried in the business data packet through the electronic control module. The first device in the present application can directly and actively request other devices to obtain the data it needs, and does not need to obtain data through special tools such as application software and applets or with the help of "intermediate devices", which improves the efficiency of device interaction and makes the interaction process simpler.
[0073] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0074] Figure 1 A flow chart of a data interaction method provided in this application includes the following steps:
[0075] S101: Searching for Bluetooth devices within a preset range to obtain a Bluetooth device list.
[0076] The first device searches for Bluetooth devices within a preset range according to a set search frequency by means of Bluetooth broadcasting, and obtains a Bluetooth device list, wherein the Bluetooth device list is used to store the unique device identifiers of the Bluetooth devices within the preset range searched by the first device. The first device may include a Bluetooth module, wherein the Bluetooth module may be used for data interaction between the first device and other Bluetooth devices (such as the second device). Of course, the data transmission between the first device and the second device is not limited to Bluetooth transmission, but may also be WiFi transmission, in which case the first device may include a WiFi module.
[0077] S102: Determine whether there is a Bluetooth device in the Bluetooth device list that has subscribed to its broadcast, and if so, use the Bluetooth device in the Bluetooth device list that has subscribed to its broadcast as the second device.
[0078] The first device determines whether the broadcast of the Bluetooth device in the Bluetooth device list has been subscribed by the first device, and if there is a Bluetooth device that has subscribed to its broadcast, it is used as the second device. That is, when the device whose broadcast the first device has subscribed to appears within the preset range of the first device, it is used as the second device, and the first device can actively send a data request to interact with the second device.
[0079] It should be noted that the second device here does not refer to a specific device, and there may be more than one device. For any device, as long as its broadcast has been subscribed by the first device and appears within the preset range of the first device, it can be regarded as a second device. Therefore, the first device can send data requests to multiple second devices at the same time to request the second devices to interact with data.
[0080] The second device can be an IOT device such as a smart kitchen appliance or smart home appliance with Bluetooth function. The second device is not specifically limited here. In the embodiment, the second device mainly refers to other devices with Bluetooth function except the first device. Any first device or second device can send and receive Bluetooth broadcasts. The device that actively sends a data request broadcast can be understood as the above-mentioned first device, and accordingly, the device that responds to the data request broadcast and returns a business data packet can be understood as the above-mentioned second device. Equal data interaction is achieved between the first device and the second device through broadcasting.
[0081] S103: Send a data request broadcast to the second device.
[0082] When there is a Bluetooth device that has subscribed to its broadcast in the Bluetooth device list obtained by the first device according to the set frequency, it is regarded as the second device, and a data request broadcast is sent to the second device.
[0083] In order to avoid wasting the power of the first device by repeatedly and frequently broadcasting data requests, in the present application, after determining that it has subscribed to the broadcast of a second device and before sending a data request broadcast to the second device, the first device needs to first determine whether the time since the last time it received a service data packet returned by the second device is not less than a preset time. That is, the first device needs to first determine whether the time since the last time it received a service data packet returned by the second device is greater than or equal to the preset time. If so, send a data request broadcast to the second device.
[0084] For determining whether the broadcast of each Bluetooth device in the Bluetooth device list has been subscribed by the first device, the present application provides a preset whitelist, which stores the unique device identifiers of the devices whose broadcasts the first device has subscribed to. Specifically, the first device obtains the preset whitelist, and then, for each Bluetooth device in the Bluetooth device list, determines whether the unique device identifier of the Bluetooth device matches the unique device identifier in the preset whitelist, and if so, determines that the broadcast of the Bluetooth device has been subscribed. Furthermore, the first device can use the Bluetooth device as a second device and generate a data request broadcast for the second device.
[0085] When generating a data request broadcast, the first device obtains the service identifier of the second device, where the service identifier is used to identify each service data (that is, the service identifier can be used to know what kind of service data the first device needs to obtain from the second device). Then, the first device generates a data request broadcast for the second device based on the service identifier of the second device.
[0086] It should be noted that the service identifier corresponding to the service data that the first device needs to obtain from the second device can be stored in a separate table or in a preset whitelist. In practical applications, it is sometimes necessary to use the unique device identifier and the corresponding service identifier of the Bluetooth device at the same time. In order to reduce the consumption of storage resources, the unique device identifier and the corresponding service identifier of the Bluetooth device can be stored in a preset whitelist. The preset whitelist stores both the unique device identifier of the device to which the first device has subscribed to broadcast and the service identifier of the device to which the first device has subscribed to broadcast, such as Figure 2 shown.
[0087] Figure 2 A schematic diagram of a storage format of a preset whitelist is provided for this application.
[0088] from Figure 2 It can be seen that the first row of the table is the table header, the data stored in the first column is the unique device identifier of the second device that has subscribed to its broadcast (such as MAC1, MAC2), and the data stored in the second column is the service identifier of the second device that has subscribed to its broadcast (such as Topic1, Topic2).
[0089] In actual applications, there may be multiple first devices and multiple second devices. When multiple first devices send data request broadcasts, each data request broadcast may carry a unique device identifier of the target second device. This is to enable multiple second devices to determine whether to reply to the business data based on the unique device identifier in the data request broadcast when receiving the data request broadcast.
[0090] For example, for a data synchronization scenario, the first devices are device A and device B, and the second devices are device C and device D. Device A wants to obtain the business data of device C (device A has subscribed to the broadcast of device C), and device B wants to obtain the business data of device D (device B has subscribed to the broadcast of device D). When device A broadcasts a data request broadcast A (carrying the unique device identifier of device C) and device B broadcasts a data request broadcast B (carrying the unique device identifier of device D), at this time, although device C and device D can both receive data request broadcast A and data request broadcast B, device C and device D can determine whether the unique device identifier carried in the data request broadcast matches their own unique device identifier, and then decide whether to broadcast a reply to the received data request broadcast.
[0091] Furthermore, when the second device determines that it is itself that is making the reply, it determines the service data corresponding to the data request, determines a service data packet according to the service data, and broadcasts the service data packet.
[0092] Of course, in order to obtain more accurate business data, rather than directly requesting all the business data in the second device, the first device may also carry the business identifier of the second device in the data request broadcast broadcasted by the first device. Continuing with the above example, when device A broadcasts a data request broadcast A (carrying the unique device identifier of device C and the business identifier of device C), at this time, when device C receives data request broadcast A, it first determines whether the unique device identifier in data request broadcast A is the unique device identifier of device C. If so, it then determines whether the business identifier carried in data request broadcast A is in the business identifier list of device C. If so, it obtains the corresponding business data according to the business identifier carried in data request broadcast A, so as to determine the business data packet according to the business data.
[0093] In addition, when the second device receives a data request broadcast carrying a service identifier, when it is determined that the service identifier carried in the data request broadcast is in the service identifier list of the second device, the second device reads the designated storage space of the second device to determine whether the designated storage space stores service data corresponding to the service identifier. When the designated storage space stores service data corresponding to the service identifier, the second device obtains service data corresponding to the service identifier stored in the designated storage space to determine the service data packet corresponding to the data request broadcast, which carries the service data. If the designated storage space does not store service data corresponding to the service identifier, the second device does not respond to the data request broadcast.
[0094] It should be noted that in order to avoid the second device from repeatedly broadcasting the same business data, after the second device broadcasts the business data packet, the second device can clear the broadcasted business data in the above-mentioned designated storage space, and also avoid a large amount of cached data occupying the memory resources of the second device.
[0095] S104: Receive a service data packet broadcasted back by the second device in response to the data request.
[0096] The second device broadcasts the determined service data packet, and the first device receives the service data packet broadcast by the second device.
[0097] In actual scenarios, the first device can not only receive the service data packets broadcasted by the second device, but also receive service data packets broadcasted by multiple other devices. However, these service data packets are not necessarily all needed by the first device. Therefore, the service data packet can carry the unique device identifier of the device that broadcasts the service data packet. The first device determines whether the unique device identifier in the service data packet is the unique device identifier of the device that has been subscribed to the broadcast by the first device (that is, whether the unique device identifier in the service data packet is in the preset whitelist). If so, the first device can proceed to the next step of processing the corresponding service data packet.
[0098] When the service data packet also carries the service identifier corresponding to the second device and the service data corresponding to the service identifier, the first device needs to determine whether it is the service data it needs based on the service identifier in the service data packet (that is, if the service identifier corresponding to the service data required by the first device is stored in the preset whitelist, determine whether the service identifier carried in the service data packet is in the preset whitelist). If so, the first device can proceed to the next step of processing the service data packet.
[0099] It should be noted that when the second device broadcasts a business data packet, sometimes the business data packet may be larger. Specifically, if the data volume corresponding to the business data packet exceeds the preset data volume, the second device will sub-packetize the business data packet before broadcasting the business data packet to obtain each sub-business data packet for broadcasting. After receiving each sub-business data packet, the first device needs to assemble the sub-business data packet first to obtain a complete business data packet.
[0100] S105: Determine whether the service data carried in the service data packet needs to be processed by itself.
[0101] In some embodiments, the first device first parses the received service data packet to obtain the service data of the second device, and then determines whether the service data of the second device needs to be processed by itself.
[0102] Before determining whether the business data carried in the business data packet needs to be processed by itself, in order to avoid abnormal situations when the first device processes the business data, the first device can also verify the business data in the business data packet, such as whether the business data in the business data packet is complete, whether the data format of the business data in the business data packet is legal, etc. After verification, it can determine whether the business data carried in the business data packet needs to be processed by itself.
[0103] Furthermore, the first device can determine whether the parsed business data of the second device needs to be processed by itself. Specifically, it obtains the electronic control firmware consumption data identifier corresponding to the business data carried by the business data packet, and determines whether the electronic control firmware consumption data identifier is a preset electronic control identifier. If so, the business data carried in the business data packet needs to be processed by itself; if not, the business data carried in the business data packet does not need to be processed by itself.
[0104] Of course, the service identifier mentioned here and the electronic control firmware consumption data identifier corresponding to the service identifier can be stored in a preset whitelist. For example, the preset whitelist in the present application can also store a preset time, which is the preset minimum time interval for allowing a data interaction between the second device and the first device (that is, the minimum time interval for allowing the first device to receive a service data packet sent by the second device each time). Only when the time since the first device last received a service data packet sent by the second device is greater than or equal to the preset time, the first device sends a data request broadcast to the second device. And the electronic control firmware consumption data identifier corresponding to the business data (the electronic control firmware consumption data identifier indicates whether the first device processes the business data corresponding to the business identifier). If processing is required, the electronic control firmware consumption data identifier corresponding to the business data is the preset electronic control identifier; if processing is not required, the electronic control firmware consumption data identifier corresponding to the business data is not the preset electronic control identifier, such as Figure 3 shown.
[0105] Figure 3 A schematic diagram of a storage format of a preset whitelist is provided for this application.
[0106] from Figure 3 As can be seen from the above, the preset whitelist can store the unique device identifier of the second device to which the first device has subscribed to broadcast and the corresponding service identifier, and can also store the minimum time interval (i.e., the minimum time interval for allowing the first device to receive the service data packet sent by the second device each time) Figure 3 to determine whether to send a data request broadcast according to the preset time. Figure 3The electronic control firmware consumption data identifier in the first device refers to whether the first device needs to perform local consumption processing on the service data in the service data packet, and the preset electronic control identifier is 1. If local consumption processing is required, the 1 in the column corresponding to the electronic control firmware consumption data identifier (such as Figure 3 ), that is, the electric control firmware consumption data identifier corresponding to the business data is a preset electric control identifier, then the first device needs to push the business data to the electric control module in the first device so that the electric control module performs local consumption processing on the business data; if no processing is required, the 0 in the column of the electric control firmware consumption data identifier (such as Figure 3 As shown in ), that is, the electronic control firmware consumption data identifier corresponding to the business data is not the preset electronic control identifier, the first device does not process the business data and can discard the business data packet.
[0107] S106: If yes, the business data is sent to its own electric control module, and the business data is processed by the electric control module.
[0108] If the business data carried in the business data packet needs to be processed by the first device itself (that is, the electronic control firmware consumption data identifier corresponding to the business data carried in the business data packet is a preset electronic control identifier), the first device sends the business data carried in the business data packet to its own electronic control module, and processes the business data carried in the business data packet through the electronic control module.
[0109] The first device receives the service data packet replied by the second device and performs local consumption processing, so that the first device can indirectly obtain the data of the second device and utilize the data of the second device, thereby expanding the functions and application scenarios of the first device and improving data utilization.
[0110] The first device does not need to trigger data interaction through additional tools or operations, nor does it need to rely on "middle devices" to achieve data interaction. The first device and the second device automatically interact with each other equally and directly through broadcasting, which improves the efficiency of data interaction and makes the interaction method between devices more concise.
[0111] Moreover, the first device only sends a broadcast request for data when it searches for the existence of a second device nearby. The timing of sending the broadcast is also strategic, which avoids blindly requesting data and causing invalid data interaction processes, and also has energy-saving and power-saving effects.
[0112] In order to more clearly illustrate the application scenarios of the method in the present application, two examples of usage scenarios are provided below.
[0113] For example, assuming that the first device is a smart light and the second device is a smart bracelet, the smart light requests to obtain the business data corresponding to the sleep state of the smart bracelet to determine whether the user using the smart bracelet has entered the sleep state. Then the smart light determines whether it needs to process the business data based on the received business data corresponding to the sleep state. If processing is required, the smart light is controlled to turn on or off according to the business data based on the preset processing logic of the electric control module.
[0114] For another example, suppose the first device is a chef machine and the second device is a smart refrigerator. The chef machine requests to obtain a list of ingredients stored in the smart refrigerator. After the smart refrigerator receives the data request broadcast by the chef machine, it identifies all the ingredients stored in the smart refrigerator through the sensor in the smart refrigerator, generates an ingredient list and sends it to the chef machine in the form of a broadcast. After receiving the ingredient list, the chef machine determines that it needs to process the ingredient list itself. If processing is required, it will send the modified ingredient list to the electronic control module, and the electronic control module will display the ingredient list on the electronic display screen of the chef machine according to the preset processing logic.
[0115] The service data packet returned by the second device may also carry the power information of the second device. After receiving the service data packet, the first device sends the power information carried in the service data packet to its own electric control module, and processes the power information through the electric control module. For example, when the electric control module of the first device receives the power information, it can determine whether the power value of the second device is less than the preset power. If it is less than the preset power, the electric control module sends a prompt to the user to remind the user that the second device needs to be charged in time or its battery needs to be replaced.
[0116] During this process, user participation is not required, and the first device does not need to wait for the second device to passively send business data. It can actively initiate data interaction with the second device. The interaction timing is more flexible, which improves data interaction efficiency.
[0117] Next, this application will use a complete example to explain in detail the implementation process of the method in this application, such as Figure 4 shown.
[0118] Figure 4 A timing diagram of data interaction provided for this application.
[0119] from Figure 4It can be seen that the first device includes two modules: a Bluetooth module and an electronic control module. The Bluetooth module in the first device searches for Bluetooth devices and obtains a list of Bluetooth devices. Then, for each Bluetooth device in the Bluetooth device list, it is determined whether the broadcast of the Bluetooth device has been subscribed. If so, the Bluetooth device is used as the second device. It is further determined whether the time from the first device to the last time it received a service data packet returned by the Bluetooth device is greater than or equal to the preset time. If so, a data request broadcast is sent, wherein the data request broadcast carries a unique device identifier and a service identifier.
[0120] Furthermore, the second device has cached and accumulated business data for a period of time since the last time it sent a business data packet, and receives a data request broadcast sent by the first device. At this time, the second device can determine whether the unique device identifier carried in the data request broadcast is the second device's own unique device identifier, and determine whether the business identifier in the data request broadcast is in the second device's own business identifier list. If so, further determine whether the cache of business data corresponding to the business identifier is empty. If not empty, obtain the business data to generate a business data packet and broadcast it.
[0121] When the first device receives a business data packet, it first determines whether the unique device identifier and business identifier in the business data packet are in the preset whitelist. If they are in the preset whitelist, it then determines whether it is necessary to perform local consumption processing on the business data in the business data packet based on the electronic control firmware consumption data identifier corresponding to the business identifier (that is, the electronic control firmware consumption data identifier corresponding to the above-mentioned business data). If so, the business data is pushed to the electronic control module through the serial port so that the electronic control module uses the business data for local consumption processing.
[0122] In the present application, the first device can actively search for Bluetooth devices within a preset range and send a data request broadcast to the second device to obtain the business data of the second device. There is no need to passively wait for the business data sent by the second device. The interaction timing is more flexible and the efficiency of data interaction is greatly improved.
[0123] When the second device that has subscribed to its broadcast appears in the communication range of the first device, the first device can send a data request broadcast to the second device instead of blindly sending a broadcast. This not only saves the power of the first device, but also avoids occupying resource space for unnecessary communication.
[0124] This specification also provides a preset whitelist. The first device can store the unique device identifier of the second device that has subscribed to its broadcast in the preset whitelist, and can also store the service identifier of the second device that has subscribed to the broadcast in the preset whitelist to generate a more accurate data request broadcast based on the preset whitelist.
[0125] The first device receives the service data packet and determines whether the unique device identifier carried in the service data packet is in the preset whitelist, and whether the service identifier carried in the service data packet is in the preset whitelist. If both are in the whitelist, the service data packet is further processed.
[0126] Furthermore, the first device may verify the service data in the service data packet before processing it, so as to avoid incomplete service data, format errors, etc. caused by abnormal situations.
[0127] When broadcasting a service data packet, the second device may also carry the power level of the second device to inform the first device of the power level of the second device. In this way, the first device may also remind the user to charge or replace the battery of the second device in a timely manner.
[0128] In addition, after receiving the data request broadcast, the second device can determine and broadcast the reply service data packet only when the service data corresponding to the service identifier carried in the data request broadcast is not empty, which avoids the waste of resources caused by sending empty packets. When the service data packet is too large, the second device can also sub-packetize the service data packet and broadcast it in the form of sub-packets.
[0129] The above are one or more data interaction methods of the present application. Based on the same idea, the present application also provides corresponding data interaction devices, such as Figure 5 shown.
[0130] Figure 5 A schematic diagram of a data interaction device provided for this application includes:
[0131] A search module 501 is used to search for Bluetooth devices within a preset range and obtain a list of Bluetooth devices;
[0132] The judging module 502 judges whether there is a Bluetooth device in the Bluetooth device list that has subscribed to its broadcast, and if so, uses the Bluetooth device in the Bluetooth device list that has subscribed to its broadcast as the second device;
[0133] A sending module 503, configured to send a data request broadcast to the second device;
[0134] A receiving module 504 is configured to receive a service data packet broadcasted back by the second device in response to the data request;
[0135] The processing module 505 is used to determine whether the business data carried in the business data packet needs to be processed by itself; if so, the business data is sent to its own electronic control module, and the business data is processed by the electronic control module.
[0136] The present application also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 A data interaction method provided.
[0137] This application also provides Figure 6 The one shown corresponds to Figure 1 A schematic diagram of the electronic device. Figure 6 As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Of course, in addition to the software implementation, this application does not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0138] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0139] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0140] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0141] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0142] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0143] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0144] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0146] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0147] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0148] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0149] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0150] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0151] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0152] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0153] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A data interaction method, characterized in that: The method is applied to a first device, comprising: Search for Bluetooth devices within the preset range and obtain a list of Bluetooth devices; Determine whether there is a Bluetooth device in the Bluetooth device list that has subscribed to its broadcast, and if so, use the Bluetooth device in the Bluetooth device list that has subscribed to its broadcast as the second device; Sending a data request broadcast to the second device; receiving a service data packet broadcasted and returned by the second device in response to the data request; Determine whether the service data carried in the service data packet needs to be processed by itself; If so, the business data is sent to its own electronic control module, and the business data is processed by the electronic control module.
2. The method according to claim 1, characterized in that Before sending the data request broadcast for the second device, the method further includes: Determine whether the time from the last receipt of the service data packet returned by the second device is not less than a preset time; Sending a data request broadcast to the second device includes: If the time from the last receipt of the service data packet returned by the second device to the preset time is not less than the preset time, a data request broadcast is sent to the second device.
3. The method according to claim 1, characterized in that Determining whether there is a Bluetooth device in the Bluetooth device list that has subscribed to its broadcast includes: Obtaining a preset whitelist, the preset whitelist including unique device identifiers of Bluetooth devices that have subscribed to its broadcast; For each Bluetooth device in the Bluetooth device list, determining whether the unique device identifier of the Bluetooth device matches the unique device identifier in the preset whitelist; If so, it is determined that the broadcast of the Bluetooth device has been subscribed.
4. The method according to claim 1, characterized in that Before sending the data request broadcast for the second device, the method further includes: Acquire a service identifier of the second device, where the service identifier is used to identify each service data; A data request broadcast for the second device is generated according to the service identifier of the second device.
5. The method according to claim 3, characterized in that The service data packet carries a unique device identifier of the second device; Before determining whether the service data carried in the service data packet needs to be processed by itself, the method further includes: Determining whether the unique device identifier of the second device carried in the service data packet is in the preset whitelist; If it is determined that the unique device identifier of the second device carried in the service data packet is in the preset white list, it is determined whether the service data carried in the service data packet needs to be processed by itself.
6. The method according to claim 3 or 5, characterized in that The service data packet carries the service identifier of the second device and the service data corresponding to the service identifier, and the preset whitelist also includes the service identifiers of the Bluetooth devices that have subscribed to its broadcast, and the service identifier is used to identify each service data; Before determining whether the service data carried in the service data packet needs to be processed by itself, the method further includes: Determine whether the service identifier carried in the service data packet is in the preset whitelist; If the service identifier carried in the service data packet is in the preset white list, it is determined whether the service data carried in the service data packet needs to be processed by itself.
7. The method according to claim 1, characterized in that Before sending the service data to its own electric control module, the method further includes: The business data is verified.
8. The method according to claim 1, characterized in that Determining whether the business data needs to be processed by itself includes: Obtaining an electronic control firmware consumption data identifier corresponding to the business data carried in the business data packet; Determining whether the electronic control firmware consumption data identifier is a preset electronic control identifier; If so, the business data needs to be processed by itself; If not, the business data does not need to be processed itself.
9. The method according to claim 1, characterized in that The service data packet is determined by the second device when it is determined that the unique device identifier carried in the data request broadcast is the unique device identifier of the second device, and the service identifier carried in the data request broadcast is in the service identifier list of the second device.
10. The method according to claim 9, characterized in that The service data packet is determined by the second device when it is determined that the service data corresponding to the service identifier carried in the data request broadcast is stored in the designated storage space of the second device.
11. A data interaction device, characterized in that: include: A search module, used to search for Bluetooth devices within a preset range and obtain a list of Bluetooth devices; A judging module, configured to judge whether there is a Bluetooth device in the Bluetooth device list that has subscribed to its broadcast, and if so, use the Bluetooth device in the Bluetooth device list that has subscribed to its broadcast as the second device; A sending module, configured to send a data request broadcast to the second device; A receiving module, configured to receive a service data packet broadcasted and returned by the second device in response to the data request; A processing module, used to determine whether the service data carried in the service data packet needs to be processed by itself; If so, the business data is sent to its own electronic control module, and the business data is processed by the electronic control module.
12. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
13. 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, the method according to any one of claims 1 to 10 is implemented.