Data Processing Method, Apparatus, Electronic Device, and Storage Medium
By converting and recombining multiple detection data, the problem of limited data transmission space is solved, and the effect of improving data transmission efficiency and timeliness is achieved.
Patent Information
- Application Number
- CN202210993604.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-18
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2042-08-18
AI Technical Summary
During data processing, due to the limitations of the data transmission protocol, the space left for transmission of data in the data packet is limited, resulting in untimely data transmission and easy data loss, affecting the user's user experience.
By acquiring multiple detection data and converting based on the preset conversion magnification of each detection data, the converted data is obtained; then the total conversion data is determined based on all the conversion data and reorganized to obtain the processed data, thereby compressing multiple detection data and reducing space usage.
It improves the amount of information in a single data transmission, improves the efficiency of data transmission, ensures the timeliness of data transmission, and improves the user experience.
Smart Images

Figure CN115460163B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and more specifically, to a data processing method, apparatus, electronic device, and storage medium. Background Art
[0002] In the process of data processing, due to the limitations of the data transmission protocol, the space left for transmitting data in the data packet is limited; and as the user's needs increase, the amount of data to be transmitted is also increasing, and the limited space cannot meet the needs of data transmission; thus, multiple data transmissions are required, which will result in untimely data transmission, unable to meet the timeliness requirements of data transmission, and multiple transmissions are likely to cause data loss, seriously affecting the user experience. Summary of the Invention
[0003] In view of the above problems, the present invention proposes a data processing method, apparatus, electronic device, and storage medium to improve the above problems.
[0004] In a first aspect, an embodiment of the present application provides a data processing method, which includes: obtaining a plurality of detection data; respectively converting each detection data based on a preset conversion magnification corresponding to each detection data to obtain conversion data corresponding to each detection data; determining total conversion data according to all the conversion data; and performing recombination processing on the total conversion data to obtain processed data.
[0005] In a second aspect, an embodiment of the present application further provides a data processing method, which includes: obtaining processed data; wherein the processed data is obtained by the data processing method described in the first aspect; splitting the processed data to obtain total conversion data; parsing the total conversion data to obtain a plurality of conversion data; and respectively performing inverse conversion on each conversion data based on a preset conversion magnification corresponding to each conversion data to obtain detection data corresponding to each conversion data.
[0006] In a third aspect, an embodiment of the present application further provides a data processing apparatus, which includes: an obtaining module, a conversion module, a total determination module, and a recombination module. The obtaining module is configured to obtain a plurality of detection data; the conversion module is configured to respectively convert each detection data based on a preset conversion magnification corresponding to each detection data to obtain conversion data corresponding to each detection data; the total determination module is configured to determine total conversion data according to all the conversion data; and the recombination module is configured to perform recombination processing on the total conversion data to obtain processed data.
[0007] Fourthly, an embodiment of the present application further provides a data processing device, which includes: a data module, a splitting module, an analysis module, and an inverse conversion module. The data module is configured to obtain processing data, where the processing data is obtained by the data processing method described in the first aspect above. The splitting module is configured to split the processing data to obtain total conversion data. The analysis module is configured to analyze the total conversion data to obtain a plurality of conversion data. The inverse conversion module is configured to perform inverse conversion on each conversion data respectively based on a preset conversion ratio corresponding to each conversion data to obtain detection data corresponding to each conversion data.
[0008] Fifthly, an embodiment of the present application further provides an electronic device, including: one or more processors; a memory; one or more applications, where one or more applications are stored in the memory and configured to be executed by one or more processors, and one or more applications are configured to execute the data processing method described in any one of the first aspect and the second aspect above.
[0009] Sixthly, an embodiment of the present application further provides a computer-readable storage medium, where program code is stored in the computer-readable storage medium, and the program code can be called by a processor to execute the data processing method described in any one of the first aspect and the second aspect above.
[0010] The technical solution provided by the present invention obtains a plurality of detection data; based on a preset conversion ratio corresponding to each detection data, performs conversion on each detection data respectively to obtain conversion data corresponding to each detection data; determines total conversion data according to all the conversion data; and performs recombination processing based on the total conversion data to obtain processing data, thereby compressing a plurality of detection data to obtain processing data, reducing the space occupied by the plurality of detection data, improving the amount of information transmitted in a single data transmission, improving the data transmission efficiency, ensuring the timeliness of data transmission, and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, rather than all embodiments. Based on the embodiments of the present application, all other embodiments and accompanying drawings obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0012] Figure 1 FIG. shows a schematic diagram of an application environment involved in an embodiment of the present application.
[0013] Figure 2 FIG. shows a schematic flowchart of a data processing method proposed in an embodiment of the present application.
[0014] Figure 3 It shows a schematic flowchart of another data processing method proposed by an embodiment of the present application.
[0015] Figure 4 It shows a structural block diagram of a data processing device proposed by an embodiment of the present application.
[0016] Figure 5 It shows a structural block diagram of another data processing device proposed by an embodiment of the present application.
[0017] Figure 6 It shows a structural block diagram of an electronic device proposed by an embodiment of the present application.
[0018] Figure 7 It shows a structural block diagram of a computer-readable storage medium proposed by an embodiment of the present application. Detailed implementation manners
[0019] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application.
[0020] During the data processing process, limited by the data transmission protocol, the space left for transmitting data in the data packet is limited. For example, in Bluetooth wireless communication, the maximum size of a Bluetooth broadcast data packet cannot exceed 31 bytes. However, a part of the bytes in the Bluetooth broadcast data packet also needs to be reserved for implementing the content specified by the data transmission protocol (such as the custom protocol between the device side and the APP side), such as the device SKU (Stock Keeping Unit, product model) name, service identifier, pact protocol, and protocol version, etc. These contents have occupied 27 bytes of the data packet space, and only 4 bytes of space are left for transmitting data.
[0021] As the needs of users are increasing, more and more data needs to be transmitted. The limited space cannot meet the needs of data transmission, and multiple data transmissions are required. This will lead to untimely data transmission, and multiple transmissions are likely to cause data loss, seriously affecting the user experience.
[0022] To improve the above problems, the inventors propose a data processing method, apparatus, electronic device, and storage medium provided by the present application. By obtaining multiple detection data; based on the preset conversion magnification corresponding to each detection data, each detection data is respectively converted to obtain the conversion data corresponding to each detection data; the total conversion data is determined according to all the conversion data; and the processing data is obtained through recombination processing based on the total conversion data, so that multiple detection data are compressed to obtain the processing data, reducing the space occupied by the multiple detection data, improving the amount of information transmitted in a single data transmission, improving the data transmission efficiency, ensuring the timeliness of data transmission, and enhancing the user experience.
[0023] The application environment of the data processing method provided by the embodiments of the present invention will be introduced below.
[0024] Please refer to Figure 1 , the data processing method provided by the embodiments of the present invention can be applied to a data processing system 100, and the data processing system 100 includes a first data processing terminal 110 and a second data processing terminal 120.
[0025] In some embodiments, the first data processing terminal 110 can broadcast the data to be transmitted, and the second data processing terminal 120 can obtain the data transmitted by broadcast through scanning.
[0026] In other embodiments, the first data processing terminal 110 can establish a connection with the second data processing terminal 120, so as to perform data transmission through the established connection.
[0027] In this application environment, the first data processing terminal 110 and the second data processing terminal 120 can execute the data processing method provided by the embodiments of the present application.
[0028] In some embodiments, the first data processing terminal 110 can send the processing data to the second data processing terminal 120.
[0029] In other embodiments, the first data processing terminal 110 can also receive the processing data sent by the second data processing terminal 120, and the present application does not limit this.
[0030] As an example, the first data processing terminal 110 can be a terminal device with a data sending requirement, and the first data processing terminal 110 can be a smart home device, a smart wearable device, etc. The smart home device can include an air quality detector, a smart light, a smart curtain, an image acquisition device, etc. The smart wearable device can include a smart watch, a smart bracelet, etc.
[0031] As an example, the second data processing terminal 120 can be a terminal device with data reception requirements, and the second data processing terminal can be a mobile phone, a computer, a tablet, a smart control panel, etc.
[0032] In some embodiments, the first data processing terminal 110 and the second data processing terminal can be connected by wireless communication, such as Bluetooth communication connection, WIFI (Wireless Fidelity) communication connection, Zigbee communication connection, etc., which are not specifically limited herein.
[0033] In some embodiments, the first data processing terminal 110 and the second data processing terminal 120 perform data transmission based on the transmission protocol corresponding to the wireless communication connection method.
[0034] For example, when the first data processing terminal 110 and the second data processing terminal 120 are connected by Bluetooth communication, the data transmission protocol corresponding to Bluetooth communication is used for data transmission. When performing data transmission, the length of the Bluetooth data packet for data transmission does not exceed 20 bytes.
[0035] Again, for example, the first data processing terminal 110 can perform data transmission through a Bluetooth broadcast data packet, and the length of the Bluetooth broadcast data packet does not exceed 31 bytes.
[0036] In some embodiments, the second data processing terminal 120 can be provided with a corresponding application program, and the user can bind the first data processing terminal 110 through the application program.
[0037] Exemplarily, the user can start scanning the first data processing terminal 110 in the application program, for example, by inputting the product model, ID, etc. of the first data processing terminal 110 to search. When the user scans the first data processing terminal 110 on the application program of the second data processing terminal 120, the binding of the first data processing terminal 110 can be completed by clicking to connect. Furthermore, the data sent by the first data processing terminal 110 can be presented in the application program.
[0038] Optionally, the second data processing terminal 120 can start scanning the Bluetooth broadcast data packet sent by the first data processing terminal 110 in the application program; thereby obtaining the Bluetooth broadcast data packet sent by the first data processing terminal 110. At this time, the second data processing terminal 120 can perform scanning in real time or at regular intervals to confirm whether the first data processing terminal 110 sends a Bluetooth broadcast data packet.
[0039] Optionally, the first data processing terminal 110 and the second data processing terminal 120 may establish a Bluetooth communication connection. The first data processing terminal 110 and the second data processing terminal 120 may perform data interaction through the established Bluetooth communication connection, that is, the first data processing terminal 110 may transmit data to the second data processing terminal 120; the second data processing terminal 120 may also transmit data to the first data processing terminal 110. Among them, the data to be transmitted may be encapsulated to form a Bluetooth data packet for transmission.
[0040] In an embodiment of the present application, the first data processing terminal 110 may compress the detection data that needs to be transmitted according to the data processing method provided in the embodiment of the present application to obtain processed data, so that the processed data carrying more data volume can be sent to the second data processing terminal 120. The second data processing terminal 110 may also obtain and use the processed data from the received processed data according to the data processing method provided in the embodiment of the present application. The data processing method provided in the embodiment of the present application will be described in detail in the following embodiments.
[0041] It should be noted that Figure 1 is only an exemplary application scenario. The method provided in the embodiment of the present application may also run in other application scenarios, which are not limited herein.
[0042] Next, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application.
[0043] Please refer to Figure 2 , the embodiment of the present application provides a data processing method, which may be applied to the first data processing terminal in the above data processing system. As Figure 2 shown, the method includes: step 210 to step 240.
[0044] Step 210, obtain a plurality of detection data.
[0045] In an embodiment of the present application, the detection data may be data that the first data processing terminal needs for data transmission or storage.
[0046] In some embodiments, the detection data may be obtained by the first data processing terminal through detection. Taking the first terminal as an air quality detector as an example, the detection data may be the data detected by the air quality detector.
[0047] In some embodiments, the detection data may include temperature data, humidity data, PM2.5 data, CO2 (carbon dioxide), formaldehyde, VOCs (volatile organic compounds), etc. The first data processing terminal may include detection devices, such as a temperature detection device, a humidity detection device, etc., to obtain corresponding detection data.
[0048] In some embodiments, the first data processing terminal may periodically obtain detection data according to a preset detection period.
[0049] Exemplarily, when the detection data is temperature data, the preset detection period may be set to 2 s.
[0050] Exemplarily, when the detection data is humidity data, the preset detection period may be set to 2 s.
[0051] Exemplarily, when the detection data is PM2.5 data, the preset detection period may be set to 1 s.
[0052] Optionally, the preset detection periods for obtaining multiple detection data may be the same or different, and may be specifically selected according to actual usage requirements and the parameters of the detection device.
[0053] In some embodiments, when multiple detection data are obtained, the multiple detection data may be compressed to save space, which will be specifically elaborated later.
[0054] In some embodiments, when multiple detection data are obtained, the multiple detection data may be first stored in a preset area.
[0055] Optionally, according to a preset processing period, the stored multiple detection data may be periodically obtained for compression processing.
[0056] Optionally, according to the data volume of the detection data stored in the preset area, when the data volume is greater than a preset threshold, compression processing of the multiple detection data may be triggered.
[0057] In some embodiments, each detection data corresponds to a preset data type, and different types of detection data adopt different processing methods for subsequent compression processing.
[0058] In some embodiments, the multiple detection data include at least one first detection data with a data type of a first detection type and a second detection data with a data type of a second detection type. The first detection data and the second detection data are two different types of detection data.
[0059] In some embodiments, the multiple detection data include the first detection data.
[0060] In some other embodiments, the multiple detection data include the second detection data.
[0061] In some other embodiments, the multiple detection data include the first detection data and the second detection data.
[0062] Optionally, the values within the value range corresponding to the first detection data include negative numbers. Exemplarily, the first detection data may be temperature data, and the data within the value range of the temperature data includes negative numbers; for example, the value range of the temperature data may be -20°C to 60°C.
[0063] Optionally, the values within the value range corresponding to the second detection data do not include negative numbers. Exemplarily, the second detection data may be humidity data, and the data within the value range of the humidity data does not include negative numbers; for example, the value range of the humidity data may be 0.0 to 99.9%. Exemplarily, the second detection data may be PM2.5 data, and the data within the value range of the PM2.5 data does not include negative numbers; for example, the value range of the PM2.5 data may be 0 to 999.
[0064] In some embodiments, the detection data may be an integer or a decimal. When the detection data is a decimal, the number of decimal places of the detection data can be set according to actual usage needs (such as precision requirements), and this application does not limit this.
[0065] Step 220: Based on the preset conversion ratio corresponding to each detection data, convert each detection data respectively to obtain the conversion data corresponding to each detection data.
[0066] In the embodiments of this application, each detection data is preset with a corresponding preset conversion ratio.
[0067] In some embodiments, the preset conversion ratios corresponding to different detection data are different.
[0068] In some embodiments, the detection data can be multiplied by the corresponding preset conversion ratio to obtain the conversion data corresponding to each detection data.
[0069] In some embodiments, if the detection data is a decimal, first convert the detection data to an integer, and then perform the conversion based on the preset conversion ratio corresponding to each detection data.
[0070] Exemplarily, if the detection data retains two decimal places, first expand the detection data by 100 times to convert it to an integer. For example, if the detection data is 60.00, first expand the detection data by 100 times to get 6000, and then perform the conversion according to the preset conversion ratio (100) of the detection data, and the conversion data corresponding to the detection data 60.00 is 6000 * 100 = 600000.
[0071] In some embodiments, if the multiple detection data includes the first detection data, then step 220 includes the following steps to convert the first detection data.
[0072] (1) If the value of the first detection data is less than zero, then perform a negation process on the first detection data to obtain negated data, and based on the preset conversion multiple corresponding to the first detection data, convert the negated data to obtain conversion data corresponding to the first detection data.
[0073] In some embodiments, since the values within the value range corresponding to the first detection data include negative numbers. Therefore, the value of the first detection data obtained may be less than zero, or may be greater than or equal to zero. According to the different values of the first detection data, use the corresponding conversion method to convert the first detection data into the corresponding conversion data.
[0074] Exemplarily, if the value of the first detection data is less than zero, then perform a negation process on the first detection data to obtain negated data. In the embodiments of the present application, the negation process refers to determining the opposite number of the first detection data, and taking the opposite number of the first detection data as the negated data. It can be understood that when the value of the first detection data is less than zero, the opposite number of the first detection data is a positive number. Exemplarily, when the first detection data is -6, the negated data obtained by performing a negation process on the first detection data is 6.
[0075] Further, based on the preset conversion multiple corresponding to the first detection data, convert the first detection data to obtain conversion data corresponding to the first detection data.
[0076] (2) If the value of the first detection data is greater than or equal to zero, then based on the preset conversion multiple corresponding to the first detection data, convert the first detection data to obtain conversion data corresponding to the first detection data.
[0077] In some embodiments, the multiple detection data includes at least one second detection data, then step 220 includes the following steps to convert the second detection data.
[0078] Based on the preset conversion multiple corresponding to the second data, convert the second detection data to obtain conversion data corresponding to the second detection data.
[0079] In the embodiments of the present application, the multiple detection data may include one or more second detection data. Each second detection data is converted based on the corresponding preset conversion multiple to obtain the corresponding conversion data.
[0080] Step 230, determine the total conversion data according to all the conversion data.
[0081] In the embodiments of the present application, all the conversion data can be summed up to obtain the total conversion data.
[0082] Exemplarily, Table 1 shows the preset conversion multiples and conversion data of multiple detection data 160, 200, and 100; Exemplarily, the detection data and conversion data in Table 1 are represented in decimal system.
[0083] Determine the total conversion data = 16000000 + 200000 + 100 = 160200100 based on the information provided by Table 1. Among them, the digits in the hundreds, tens, and units places of the total conversion data are used to represent the detection data "100"; the digits in the hundred thousands, ten thousands, and thousands places of the total conversion data are used to represent the detection data "200"; the digits in the hundred millions, ten millions, and millions places of the total conversion data are used to represent the detection data "160".
[0084] Table 1
[0085] Detection data Preset conversion magnification Converted data 160 1000000 160000000 200 1000 200000 100 1 100
[0086] In some embodiments, the preset conversion multiples corresponding to the detection data are different, and their positions in the total conversion data will also be adjusted. For example, if the preset conversion multiple of the detection data "160" is swapped with the preset conversion multiple of the detection data "200", that is, the preset conversion multiple of the detection data "160" is adjusted to 1000, and the preset conversion multiple of the detection data "200" is adjusted to 1, then the total conversion data is adjusted to 160100200, and the position of the detection data "160" is adjusted to the corresponding digits in the hundred thousands, ten thousands, and thousands places of the total conversion data.
[0087] In some embodiments, the preset conversion multiple needs to consider avoiding the mutual interference of the positions of different detection data in the total conversion data. For example, if it is determined that the digits in the hundreds, tens, and units places of the total conversion data are used to represent one of the detection data, then the preset conversion multiples of other detection data need to be greater than 1000 so as not to affect the representation of the detection data in the hundreds, tens, and units places of the total conversion data.
[0088] Step 240: Perform recombination processing on the total conversion data to obtain the processed data.
[0089] In some embodiments, the processed data includes the value of the sign bit and the value of the data bit. Step 240 may include the following steps.
[0090] (1) Use the value of the total conversion data as the value of the data bit of the processed data.
[0091] In some embodiments, if the base corresponding to the total conversion data is different from the base corresponding to the processed data, then convert the total conversion data to the same base as the processed data, and use the value of the converted total conversion data as the value of the data bit of the processed data.
[0092] Exemplarily, if the total conversion data is in decimal while the processed data is in hexadecimal, the total conversion data is converted to 98aef68 (hexadecimal). Further, the numerical value of the data bits of the processed data is set to 98aef68.
[0093] In an embodiment of the present application, the maximum data that the processed data can carry does not exceed the maximum numerical value that the data bits can carry.
[0094] Exemplarily, if the processed data is in hexadecimal, the maximum value of the data bits of the processed data (assuming the first to the fourth bits) is "FFFF". That is to say, the maximum numerical value of the total conversion data cannot exceed "65535" (corresponding to decimal).
[0095] (2) Determine the numerical value of the sign bit of the processed data according to the first detection data among the multiple detection data.
[0096] In an embodiment of the present application, the sign bit is used to characterize the sign situation of the first detection data, that is, to characterize the magnitude relationship between the numerical value of the first detection data and zero.
[0097] In some embodiments, if the numerical value of the first detection data is less than zero, the numerical value of the sign bit of the processed data is set to one.
[0098] If the value of the first detection data is greater than or equal to zero, the numerical value of the sign bit of the processed data is set to zero.
[0099] In some embodiments, if the first detection data is not included in the multiple detection data, the numerical value of the sign bit is set to zero.
[0100] In an embodiment of the present application, the multiple detection data is compressed by the data processing method of the present application to obtain the processed data, effectively reducing the space occupied by the multiple detection data.
[0101] In some usage scenarios that require a large amount of data storage, the processed data can be used to replace the multiple detection data for storage, which can effectively reduce the storage space of the device.
[0102] In some usage scenarios that require data transmission, the processed data can be transmitted to the target device through Bluetooth communication or Bluetooth broadcast, so as to increase the amount of information transmitted in a single data transmission, improve the data transmission efficiency, and ensure the timeliness of data transmission.
[0103] Please refer to Figure 3 , the embodiment of the present application also provides a data processing method, which can be applied to the second data processing terminal in the above data processing system. As Figure 3 shown, the method includes: step 310 to step 340.
[0104] Step 310: Obtain processed data; where the processed data is obtained by the above data processing method.
[0105] In some embodiments, the processed data may be the processed data obtained after a second data processing terminal acquires multiple detection data, processed by the above data processing method, and stored in a preset storage space.
[0106] In some embodiments, the processed data may also be the processed data transmitted by a first data processing terminal. Since the processed data is obtained by compressing multiple detection data, the amount of detection data that can be obtained from the processed data received by the second data processing terminal at one time will be larger than the amount of data when directly sending the detection data.
[0107] Step 320: Split the processed data to obtain total conversion data.
[0108] In the embodiments of the present application, the processed data includes the value of the sign bit and the value of the data bit, and the total conversion data can be obtained according to the value of the data bit of the processed data.
[0109] In some embodiments, if the processed data and the total conversion data use different number systems, the value of the data bit of the processed data can be further converted to obtain the total conversion data.
[0110] Exemplarily, the processed data uses hexadecimal and the total conversion data uses decimal. If the value of the data bit of the processed data is "FFFF", the corresponding total conversion data is "65535".
[0111] Step 330: Parse the total conversion data to obtain multiple conversion data.
[0112] In the embodiments of the present application, the total conversion data is composed of multiple conversion data, and the total conversion data can be parsed according to the position of the conversion data in the total conversion data to obtain the corresponding conversion data.
[0113] Exemplarily, the total conversion data is 160200100 (corresponding to decimal), and the total conversion data includes three conversion data. Among them, the hundreds, tens, and units digits in the total conversion data correspond to one conversion data; the hundreds, tens, and units digits in the total conversion data correspond to one conversion data; the hundred millions, ten millions, and millions digits in the total conversion data correspond to one conversion data.
[0114] Then the total conversion data 160200100 can be further divided into conversion data "160000000", conversion data "200000", and conversion data "100".
[0115] Step 340: Based on the preset conversion magnification corresponding to each conversion data, perform inverse conversion on each conversion data to obtain the detection data corresponding to each conversion data.
[0116] In some embodiments, the conversion data can be divided by the corresponding preset conversion magnification to obtain the detection data corresponding to each detection data.
[0117] If the detection data is a decimal number (i.e., retaining a preset number of digits after the decimal point), then divide the conversion data by the corresponding preset conversion magnification to obtain an integer, and then convert the integer into the detection data according to the number of decimal digits of each detection data.
[0118] Exemplarily, if the detection data retains two decimal places, the conversion data is 600000, and the preset conversion magnification is 1000, then 600000 / 1000 = 6000 can be obtained, and then 6000 is reduced by 100 times, that is, the decimal point of 6000 is moved two places to the left to obtain the corresponding detection data 60.00.
[0119] In some embodiments, if the detection data corresponding to the conversion data is the first detection data, then perform inverse conversion on the conversion data based on the value of the sign bit of the processed data and the preset conversion magnification corresponding to the conversion data to obtain the first detection data corresponding to the conversion data.
[0120] Among them, the values within the value range of the first detection data include negative numbers.
[0121] In the embodiments of the present application, if the detection data corresponding to the conversion data is the first detection data, then the values within the value range of the first detection data include negative numbers, that is to say, the value of the first detection data may be less than zero. It is necessary to further determine the sign of the first detection data according to the value of the sign bit.
[0122] Exemplarily, when the value of the sign bit corresponding to the conversion data is zero, the value of the first detection data corresponding to the conversion data is greater than or equal to zero.
[0123] Exemplarily, when the value of the sign bit corresponding to the conversion data is one, the value of the first detection data corresponding to the conversion data is less than zero.
[0124] In some embodiments, if the value of the sign bit of the processed data is one, then perform inverse conversion according to the preset conversion magnification corresponding to the conversion data to obtain the data to be inversely processed corresponding to the conversion data.
[0125] Furthermore, perform inverse processing on the data to be inversely processed to obtain the first detection data corresponding to the conversion data.
[0126] In an embodiment of the present application, since the value of the first detection data is less than zero, it is necessary to perform an inverse process on the data to be inverted, that is, obtain the opposite number of the data to be inverted as the first detection data.
[0127] In some embodiments, if the value of the sign bit of the processed data is zero, an inverse conversion is performed according to the preset conversion multiple corresponding to the conversion data to obtain the first detection data corresponding to the conversion data. At this time, the value of the first detection data is greater than or equal to zero, and no inverse process is required.
[0128] In some embodiments, if the detection data corresponding to the conversion data is the second detection data, an inverse conversion is performed on the conversion data according to the preset conversion multiple corresponding to the conversion data to obtain the second detection data corresponding to the conversion data; wherein, the values within the value range of the second detection data do not include negative numbers.
[0129] A specific embodiment will be described below.
[0130] In an embodiment of the present application, the first data processing terminal is taken as an air quality detector as an example for illustration. The air quality detector can be provided with sensors to obtain detection data.
[0131] Among them, the detection data includes the temperature data, humidity data, and PM2.5 data of the environment. Among them, the value range of the temperature data is -20.0 - 60.0 °C, the value range of the humidity data is 0.0 - 99.9%, and the value range of the PM2.5 data is 0 - 999.
[0132] In an embodiment of the present application, the temperature data is the first detection data and has a corresponding sign bit in the processed data. The humidity data and the PM2.5 data are the second detection data and do not have corresponding sign bits in the processed data.
[0133] In an embodiment of the present application, the first data processing terminal can define an int - type variable devicedata of 32 bits (represented in binary) to store the processed data.
[0134] In an embodiment of the present application, the highest bit of the variable devicedata is used to represent the sign bit of the temperature data. Among them, when the value of the sign bit is 0, it represents that the value of the temperature data is greater than or equal to zero; when the value of the sign bit is 1, it represents that the value of the temperature data is less than zero.
[0135] In an embodiment of the present application, the 1st to 31st bits of the variable devicedata are data bits (from right to left) and are used to store the total conversion data.
[0136] Further, it can be determined whether the value of the temperature data is negative. If it is negative, the highest bit of the variable devicedata is written as 1, and the value of the temperature data is inverted to become a positive number.
[0137] Exemplarily, taking the value of the temperature data as 25.6 (°C), the value of the humidity data as 60.0, and the value of the PM2.5 data as 60 as an example for illustration. In the embodiments of the present application, the values of the temperature data and the humidity data are represented in decimal.
[0138] Among them, the value of the temperature data is 25.6. Since it cannot be transmitted with small data points during transmission, it is enlarged by 10 times to obtain temperature = 256. The preset conversion magnification corresponding to the temperature data is 1,000,000. Therefore, the conversion data corresponding to the temperature data is 256,000,000.
[0139] Similarly, the value of the humidity data is 60.0. It is enlarged by 10 times to obtain the corresponding conversion data Humidity = 600. The preset conversion magnification corresponding to the humidity data is 1,000. Therefore, the conversion data corresponding to the humidity data is 600,000.
[0140] The value of the PM2.5 data is 60. The preset conversion magnification corresponding to the PM2.5 data is 1. Therefore, the conversion data corresponding to the PM2.5 data is 60.
[0141] Furthermore, the total conversion data = 256,000,000 + 600,000 + 60 = 256,600,060 (corresponding to decimal), and the hexadecimal representation is 0xF4B67FC.
[0142] Since the temperature data is greater than zero, the value of the sign bit corresponding to the temperature data is zero. According to the defined protocol (custom protocol), the data is split and stored in four bytes, with the high bits first, to obtain the reorganized processed data. devicedata = 0xF4B67FC
[0143] sendData[3] = devicedata & 0xff = 0xFC
[0144] sendData[2] = (devicedata >> 8) & 0xff = 0x67
[0145] sendData[1] = (devicedata >> 16) & 0xff = 0x4B
[0146] sendData[0] = (devicedata >> 24) & 0xff = 0x0F
[0147] Transmit the reorganized processed data to the second data processing terminal via Bluetooth broadcast.
[0148] In an embodiment of the present application, after obtaining the processed data, the second data processing terminal processes the processed data to obtain detection data corresponding to the processed data.
[0149] In some embodiments, the second data processing terminal may define a 32-bit int variable revdevicedata to receive the processed data.
[0150] Exemplarily, if revdevicedata = 0xF4B67FC, the following can be obtained respectively:
[0151] getData[0] = 0x0F;
[0152] getData[1] = 0x4B;
[0153] getData[2] = 0x67;
[0154] getData[3] = 0xFC.
[0155] Furthermore, it is determined that the temperature data is greater than zero according to the highest bit of revdevicedata, and it is determined that the total conversion data is 0xF4B67FC, which is converted to decimal to obtain 256600060.
[0156] Respective detection data can be obtained according to the preset conversion magnification corresponding to the detection data set in advance and the position in the total conversion data.
[0157] For example, for the temperature data: 256600060 / 1000000 = 256, since the temperature data retains one decimal place, the temperature data is obtained as 25.6.
[0158] For the humidity data: 256600060 % 1000000 / 1000 = 600, since the humidity data retains one decimal place, the humidity is obtained as 60.0.
[0159] For the PM2.5 data: 256600060 % 1000000 % 1000 = 60, thus the PM2.5 data is obtained as 60.
[0160] Please refer to Figure 4 , an embodiment of the present application provides a data processing device 400, which includes: an acquisition module 410, a conversion module 420, a total determination module 430, and a reorganization module 440.
[0161] Among them, the acquisition module 410 is used to acquire multiple detection data.
[0162] The conversion module 420 is used to convert each detection data respectively based on the preset conversion magnification corresponding to each detection data, so as to obtain the conversion data corresponding to each detection data.
[0163] The total determination module 430 is used to determine the total conversion data according to all the conversion data.
[0164] The recombination module 440 is used to perform recombination processing based on the total conversion data to obtain the processed data.
[0165] In some embodiments, each detection data corresponds to a preset data type. The multiple detection data includes at least one of a first detection data with a data type of a first detection type and a second detection data with a data type of a second detection type.
[0166] Wherein, the values within the value range corresponding to the first detection data include negative numbers; the values within the value range corresponding to the second detection data do not include negative numbers.
[0167] In some embodiments, the multiple detection data includes the first detection data.
[0168] In some embodiments, the conversion module includes: a first conversion unit and a second conversion unit.
[0169] Wherein, the first conversion unit is used to, if the value of the first detection data is less than zero, perform negation processing on the first detection data to obtain the negated data; and convert the negated data based on the preset conversion magnification corresponding to the first detection data to obtain the conversion data corresponding to the first detection data.
[0170] The second conversion unit is used to, if the value of the first detection data is greater than or equal to zero, convert the first detection data based on the preset conversion magnification corresponding to the first detection data to obtain the conversion data corresponding to the first detection data.
[0171] In some embodiments, the multiple detection data includes at least one second detection data. The conversion module 420 is used to convert the second detection data based on the preset conversion magnification corresponding to the second data to obtain the conversion data corresponding to the second detection data.
[0172] In some embodiments, the processed data includes a sign bit and a data bit. The recombination module 440 includes a first processing unit and a second processing unit. Wherein, the first processing unit is used to use the value of the total conversion data as the value of the data bit of the processed data. The second processing unit is used to determine the value of the sign bit of the processed data according to the first detection data among the multiple detection data.
[0173] In some embodiments, the second processing unit includes a first processing unit and a second processing unit. Among them, the first processing unit is configured to set the value of the sign bit corresponding to the first detection data in the processed data to one if the value of the first detection data is less than zero. The second processing unit is configured to set the value of the sign bit corresponding to the first detection data in the processed data to zero if the value of the first detection data is greater than or equal to zero.
[0174] In some embodiments, the total determination module 430 is configured to sum all the conversion data to obtain total conversion data.
[0175] In some embodiments, the data processing device further includes a transmission module. Among them, the transmission module is configured to transmit the processed data to the target device by means of Bluetooth communication.
[0176] Please refer to Figure 5 , the embodiment of the present application further provides another data processing device 500, and the device includes: a data module 510, a splitting module 520, an analysis module 530, and an inverse conversion module 540.
[0177] Among them, the data module 510 is configured to obtain processed data; among them, the processed data is obtained by the above data processing method.
[0178] The splitting module 520 is configured to perform splitting processing on the processed data to obtain total conversion data.
[0179] The analysis module 530 is configured to perform analysis processing on the total conversion data to obtain a plurality of conversion data.
[0180] The inverse conversion module 540 is configured to perform inverse conversion on each conversion data respectively based on the preset conversion magnification corresponding to each conversion data to obtain a plurality of detection data corresponding to each conversion data.
[0181] In some embodiments, the processed data includes the value of the sign bit and the value of the data bit, and the splitting module 520 is configured to obtain the total conversion data according to the value of the data bit of the processed data.
[0182] In some embodiments, the inverse conversion module 540 includes a first conversion unit and a second conversion unit. Among them, the first conversion unit is configured to perform inverse conversion on the conversion data based on the value of the sign bit of the processed data and the preset conversion magnification corresponding to the conversion data to obtain the first detection data corresponding to the conversion data if the detection data corresponding to the conversion data is the first detection data; among them, the values within the value range of the first detection data include negative numbers.
[0183] The second conversion unit is configured to, if the detection data corresponding to the conversion data is the second detection data, perform inverse conversion on the conversion data according to a preset conversion magnification corresponding to the conversion data to obtain the second detection data corresponding to the conversion data; wherein, the values within the value range of the second detection data do not include negative numbers.
[0184] In some embodiments, the first conversion unit includes a first - time conversion unit and a second - time conversion unit. The first - time conversion unit is configured to, if the value of the sign bit of the processed data is one, perform inverse conversion on the conversion data according to a preset conversion magnification corresponding to the conversion data to obtain the data to be inversely processed corresponding to the conversion data.
[0185] The second - time conversion unit is configured to perform inverse processing on the data to be inversely processed to obtain the first detection data corresponding to the conversion data.
[0186] It should be noted that for device - type embodiments, since they are basically similar to method embodiments, the description is relatively simple. For the relevant parts, refer to the partial description of the method embodiments. For any processing method described in the method embodiments, it can be implemented by corresponding processing modules in the device embodiments, and will not be elaborated one by one in the device embodiments.
[0187] In addition, in each embodiment of the present application, each functional module can be integrated in one processing module, or each module can exist physically alone, or two or more modules can be integrated in one module. The above - mentioned integrated modules can be implemented in the form of hardware or in the form of software functional modules.
[0188] Please refer to Figure 6 , based on the above - mentioned data processing method, an embodiment of the present application further provides an electronic device 600 including a processor that can execute the foregoing data processing method.
[0189] In an embodiment of the present application, the electronic device 600 includes one or more processors 610, a memory 620, and one or more application programs. One or more application programs are stored in the memory 620. The memory 620 stores a program that can execute the content in the foregoing embodiments, and the processor 610 can execute the program stored in the memory.
[0190] Among them, the processor 610 may include one or more cores for processing data and a message matrix unit. The processor 610 connects various parts within the entire electronic device through various interfaces and circuits. By running or executing instructions, programs, code sets, or instruction sets stored in the memory, and by invoking data stored in the memory, it performs various functions of the cooking device and processes data. Optionally, the processor 610 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 610 may integrate a combination of one or several of a central processing unit 610 (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing display content; the modem is used to process wireless communication. It can be understood that the above modem may not be integrated into the processor 610 and may be implemented separately through a communication chip.
[0191] The memory 620 may include random access memory (RAM) and may also include read-only memory. The memory 620 can be used to store instructions, programs, code, code sets, or instruction sets. The memory may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for implementing at least one function (such as conversion function, recombination processing, etc.), instructions for implementing each of the following method embodiments, etc. The data storage area may also store data created during the use of the terminal (such as detection data, total conversion data), etc.
[0192] Please refer to Figure 7 , which shows a structural block diagram of a computer-readable storage medium 700 provided by an embodiment of the present application. Program code 710 is stored in the computer-readable storage medium 700, and the program code 710 can be called by the processor to execute the data processing method described in the above method embodiments.
[0193] The computer-readable storage medium 700 can be an electronic memory such as a flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium 700 has a storage space for program codes that execute any of the method steps in the above data processing method. These program codes 710 can be read out from or written into one or more computer program products. The program codes can be compressed in an appropriate form, for example.
[0194] In summary, a data processing method, apparatus, electronic device, and storage medium provided by an embodiment of the present application obtain a plurality of detection data; respectively convert each detection data according to a corresponding preset conversion magnification to obtain conversion data corresponding to each detection data; determine total conversion data according to all the conversion data; and perform recombination processing based on the total conversion data to obtain processed data, thereby compressing the plurality of detection data to obtain the processed data, reducing the space occupied by the plurality of detection data, improving the amount of information transmitted in a single data transmission, improving the efficiency of data transmission, ensuring the timeliness of data transmission, and enhancing the user experience.
[0195] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features. These modifications or replacements 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 application.
Claims
1. A data processing method, characterized in that, the method includes: obtaining a plurality of detection data; respectively converting each detection data based on a preset conversion magnification corresponding to each detection data to obtain conversion data corresponding to each detection data; determining total conversion data according to all the conversion data; performing recombination processing based on the total conversion data to obtain processed data; the size of the processed data does not exceed 4 bytes; wherein, each detection data corresponds to a preset data type, and different types of detection data adopt different processing methods for subsequent compression processing; the plurality of detection data includes at least one of first detection data of a first detection type and second detection data of a second detection type; the values within the value range corresponding to the first detection data include negative numbers; the values within the value range corresponding to the second detection data do not include negative numbers; transmitting the processed data to a target device through Bluetooth communication or Bluetooth broadcast.
2. The method according to claim 1, characterized in that, the plurality of detection data includes first detection data; the respectively converting each detection data based on a preset conversion magnification corresponding to each detection data to obtain conversion data corresponding to each detection data; includes: if the value of the first detection data is less than zero, then performing an inversion process on the first detection data to obtain inverted data; and converting the inverted data based on the preset conversion magnification corresponding to the first detection data to obtain conversion data corresponding to the first detection data; if the value of the first detection data is greater than or equal to zero, then converting the first detection data based on the preset conversion magnification corresponding to the first detection data to obtain conversion data corresponding to the first detection data.
3. The method according to claim 1, characterized in that, the plurality of detection data includes at least one second detection data; the respectively converting each detection data based on a preset conversion magnification corresponding to each detection data to obtain conversion data corresponding to each detection data; includes: converting the second detection data based on the preset conversion magnification corresponding to the second data to obtain conversion data corresponding to the second detection data.
4. The method according to claim 2, characterized in that, the processed data includes the value of a sign bit and the value of a data bit; the performing recombination processing based on the total conversion data to obtain processed data, includes: using the value of the total conversion data as the value of the data bit of the processed data; determining the value of the sign bit of the processed data according to the first detection data among the plurality of detection data.
5. The method according to claim 4, characterized in that, the determining the value of the sign bit of the processed data according to the first detection data among the plurality of detection data, includes: if the value of the first detection data is less than zero, then setting the value of the sign bit of the processed data to one; if the value of the first detection data is greater than or equal to zero, then setting the value of the sign bit of the processed data to zero.
6. The method according to any one of claims 1 to 5, characterized in that, the determining of the total conversion data according to all the conversion data includes: summing up all the conversion data to obtain the total conversion data.
7. A data processing method, characterized in that, the method includes: obtaining processing data; wherein, the processing data is obtained by the data processing method according to any one of claims 1 to 6; performing a splitting process on the processing data to obtain the total conversion data; performing a parsing process on the total conversion data to obtain a plurality of conversion data; based on the preset conversion ratio corresponding to each conversion data, respectively performing an inverse conversion on each conversion data to obtain the detection data corresponding to each conversion data.
8. The method according to claim 7, characterized in that, the processing data includes the value of the sign bit and the value of the data bit; the performing a splitting process on the processing data to obtain the total conversion data includes: using the value of the data bit of the processing data as the value of the total conversion data to obtain the total conversion data; the performing an inverse conversion on each conversion data based on the preset conversion ratio corresponding to each conversion data to obtain the detection data corresponding to each conversion data includes: if the detection data corresponding to the conversion data is the first detection data, then performing an inverse conversion on the conversion data based on the value of the sign bit of the processing data and the preset conversion ratio corresponding to the conversion data to obtain the first detection data corresponding to the conversion data; wherein, the values within the value range corresponding to the first detection data include negative numbers; if the detection data corresponding to the conversion data is the second detection data, then performing an inverse conversion on the conversion data according to the preset conversion ratio corresponding to the conversion data to obtain the second detection data corresponding to the conversion data; wherein, the values within the value range corresponding to the second detection data do not include negative numbers.
9. The method according to claim 8, characterized in that, the performing an inverse conversion on the conversion data based on the value of the sign bit of the processing data and the preset conversion ratio corresponding to the conversion data to obtain the first detection data corresponding to the conversion data includes: if the value of the sign bit of the processing data is one, then performing an inverse conversion on the conversion data according to the preset conversion ratio corresponding to the conversion data to obtain the data to be inversely processed corresponding to the conversion data; performing an inverse process on the data to be inversely processed to obtain the first detection data corresponding to the conversion data.
10. A data processing device, characterized in that, the device includes: an obtaining module, configured to obtain a plurality of detection data; a conversion module, configured to respectively perform a conversion on each detection data based on the preset conversion ratio corresponding to each detection data to obtain the conversion data corresponding to each detection data; a total determination module, configured to determine the total conversion data according to all the conversion data; a recombination module, configured to perform a recombination process based on the total conversion data to obtain processing data; the size of the processing data does not exceed 4 bytes; a transmission module, configured to transmit the processing data to a target device by means of Bluetooth communication or Bluetooth broadcasting; Among them, each detection data corresponds to a preset data type, and different processing methods are used for subsequent compression processing of different types of detection data; the multiple detection data includes at least one of first detection data with a data type of a first detection type and second detection data with a data type of a second detection type; the values within the value range corresponding to the first detection data include negative numbers; the values within the value range corresponding to the second detection data do not include negative numbers.
11. A data processing device, characterized in that the device includes: a data module for obtaining processing data; wherein, the processing data is obtained by the data processing method according to any one of claims 1 to 6; a splitting module for splitting the processing data to obtain total conversion data; an analysis module for analyzing the total conversion data to obtain a plurality of conversion data; an inverse conversion module for respectively performing inverse conversion on each conversion data based on a preset conversion magnification corresponding to each conversion data to obtain a plurality of detection data corresponding to each conversion data.
12. An electronic device, characterized in that it includes: one or more processors; a memory; one or more application programs, wherein the one or more application programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more application programs are configured to execute the data processing method according to any one of claims 1-9.
13. A computer-readable storage medium, characterized in that the computer-readable storage medium stores program codes, and the program codes can be called by a processor to execute the data processing method according to any one of claims 1-9.
Citation Information
Patent Citations
Data compression transmission method based on IEEE754 format
CN111404907A