CN116233264A - Data transmission method and electronic equipment - Google Patents

Data transmission method and electronic equipment Download PDF

Info

Publication number
CN116233264A
CN116233264A CN202310215605.1A CN202310215605A CN116233264A CN 116233264 A CN116233264 A CN 116233264A CN 202310215605 A CN202310215605 A CN 202310215605A CN 116233264 A CN116233264 A CN 116233264A
Authority
CN
China
Prior art keywords
data
byte
target
bytes
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310215605.1A
Other languages
Chinese (zh)
Inventor
赵思航
黄世光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lenovo Beijing Ltd
Original Assignee
Lenovo Beijing Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Lenovo Beijing Ltd filed Critical Lenovo Beijing Ltd
Priority to CN202310215605.1A priority Critical patent/CN116233264A/en
Publication of CN116233264A publication Critical patent/CN116233264A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/03Protocol definition or specification 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Communication Control (AREA)

Abstract

The application discloses a data transmission method and electronic equipment, wherein the method comprises the following steps: obtaining target data; processing the target data based on a standard format to obtain a byte array; generating a data frame of a target transmission protocol based on the byte array; and transmitting the data frame.

Description

Data transmission method and electronic equipment
Technical Field
The present disclosure relates to the field of communications technologies, and in particular, to a data transmission method and an electronic device.
Background
At present, the number of bytes carried in a data frame broadcast based on a transmission protocol is limited, and when a sender transmits data each time, the sender needs to negotiate with a receiver to modify the transmission protocol once, so that the receiver can analyze the data content in the data frame, which results in lower efficiency of data transmission between the sender and the receiver.
Therefore, a technical solution capable of improving data transmission efficiency is needed.
Disclosure of Invention
In view of this, the present application provides a data transmission method and an electronic device, as follows:
a method of data transmission, the method comprising:
obtaining target data;
processing the target data based on a standard format to obtain a byte array;
generating a data frame of a target transmission protocol based on the byte array;
and transmitting the data frame.
In the above method, preferably, the standard format is a format composed of length, type and content;
wherein the length is used to characterize the type and the number of bytes occupied by the content, and the type is used to characterize the type of the content.
In the above method, preferably, the byte array includes a length byte, a type byte, and a content byte.
In the above method, preferably, the length byte is used to indicate that the target number of bytes after the length byte belongs to one target data.
In the above method, preferably, obtaining the target data includes:
target data of a target type is obtained.
Preferably, the method, based on the standard format, processes the target data to obtain a byte array, includes:
converting the target data into a target value;
obtaining a byte number of the content bytes based on the target value;
obtaining a first value for characterizing a length based on a number of bytes of the content bytes, the first value being a sum of the number of bytes of the content bytes and the number of type bytes;
obtaining a second value for characterizing the target type;
and taking the combination of the first value, the second value and the target value as the value of the byte array.
In the above method, preferably, generating the data frame of the target transport protocol based on the byte array includes:
the values of the byte arrays are sequentially written based on the data portion of the data frame, the byte arrays utilizing a set of bytes of the data portion, the bytes of the set of bytes being contiguous from byte to byte.
In the above method, preferably, the obtaining the target data includes:
obtaining a plurality of target data, wherein each target data is different in type;
wherein said processing said target data based on a standard format to obtain a byte array comprises:
processing each of the target data based on the standard format to obtain a plurality of byte arrays;
wherein generating a data frame of the target transport protocol based on the byte array comprises:
sequentially writing a value of each of said byte arrays based on a data portion of said data frame, each of said byte arrays utilizing a set of bytes of said data portion being contiguous, each of said set of bytes being byte-to-byte.
In the above method, preferably, each of the byte arrays uses a different number of bytes of a group of bytes of the data portion.
In the above method, preferably, the data frame at least includes an index field, where the index field is used to indicate a total amount of frames in a data stream where the data frame is located and a frame order of the data frame in the data stream;
wherein the frame total and the frame order are determined based on a number of bytes in the byte array and a number of bytes of a data portion of the data frame.
A method of data transmission, the method comprising:
scanning to obtain a data frame;
processing the data frame according to a target transmission protocol to obtain a byte array;
and processing the byte array based on a standard format to obtain target data.
An electronic device, comprising:
processing means for obtaining target data; processing the target data based on a standard format to obtain a byte array; generating a data frame of a target transmission protocol based on the byte array;
communication means for transmitting the data frame.
An electronic device, comprising:
communication means for scanning to obtain a data frame;
processing means for processing the data frame according to a target transport protocol to obtain a byte array; and processing the byte array based on a standard format to obtain target data.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a data transmission method according to a first embodiment of the present application;
FIG. 2 is an exemplary diagram of data transmission in the present application;
FIG. 3 is an exemplary diagram of standard formats and byte arrays in an embodiment of the present application;
fig. 4 is a diagram illustrating a structure of a data frame in an embodiment of the present application;
FIG. 5 is a diagram illustrating an example of the structure of a byte array according to an embodiment of the present application;
FIG. 6 is a diagram showing another exemplary structure of a data frame in an embodiment of the present application;
fig. 7 is a partial flowchart of a data transmission method according to a first embodiment of the present application;
FIG. 8 is a diagram illustrating another example of the structure of a byte array according to an embodiment of the present application;
fig. 9 is a diagram illustrating a structure of a data frame corresponding to target data of a Mac address in the embodiment of the present application;
fig. 10 is a diagram illustrating a structure of a data frame corresponding to two target data of Mac address and product name in the embodiment of the present application;
FIG. 11 is a diagram of framing examples corresponding to four target data of Mac address, product name, phone number and ABILITY in the embodiment of the present application;
fig. 12 is a flowchart of a data transmission method according to a second embodiment of the present application;
fig. 13 is a schematic structural diagram of an electronic device (sender) according to a third embodiment of the present application;
fig. 14 is a schematic structural diagram of an electronic device (receiving party) according to a fourth embodiment of the present application;
fig. 15 is a diagram illustrating an example of a structure of a broadcast packet applicable to a data frame in BLE according to the present application;
fig. 16 is a diagram illustrating a structure of a response packet applicable to a data frame in BLE according to the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
Referring to fig. 1, a flowchart of an implementation of a data transmission method according to an embodiment of the present application may be applicable to an electronic device capable of performing data frame processing, such as a mobile phone, a tablet, or a notebook. The electronic device in this embodiment is an electronic device in which both communication parties are transmitting parties. As shown in fig. 2, a sender transmits data to a receiver, for example, a mobile phone as a sender transmits data to a notebook as a receiver. Specifically, the technical scheme in this embodiment is mainly used for improving data transmission efficiency.
Specifically, the method in this embodiment may include the following steps:
step 101: target data is obtained.
The target data is data that needs to be transmitted, such as address of media access control layer Mac (Media AccessControl), device name, phone number, etc.
Step 102: the target data is processed based on the standard format to obtain a byte array.
Wherein the byte array is an array composed of a plurality of bytes characterizing the data content of the target data. The bytes in the byte array are combined in a standard format.
Specifically, the standard format is a preset format. For example, the standard format is a format of length, type, and content composition. The length here is used to characterize the type and the number of bytes the content occupies, and the type is used to characterize the type of content. The content here refers to the data content of the target data.
Accordingly, the byte array obtained based on the standard format includes length bytes, type bytes, and content bytes. For example, as shown in fig. 3, the length bytes in the byte array correspond to the length in the standard format, the type bytes in the byte array correspond to the type in the standard format, and the content bytes in the byte array correspond to the content in the standard format.
It should be noted that the length byte, the type byte, and the content byte in the byte array may each include one or more bytes. For example, the length byte is 1 byte, the type byte is 1 byte, and the number of bytes of the content byte is related to the data content of the target data. The 1 byte here contains 8 bits, such as 00000000-11111111 binary or 00-FF hexadecimal, and can be written with any value from 0 to 255 decimal.
Step 103: based on the byte array, a data frame of the target transport protocol is generated.
Specifically, the data frame comprises a data part and a control part, wherein the byte format of the control part is related to the target transmission protocol and is used for writing control contents corresponding to the target transmission protocol, such as the contents of data frame length, data frame type, service identification and the like; the data portion is used for writing data content that needs to be transferred. Based on this, in this embodiment, the byte array may be written into the data portion of the data frame according to the target transport protocol. For example, as shown in fig. 4, a data frame generated according to a target transmission protocol includes two data packets, such as a broadcast packet and a response packet of a bluetooth data frame, each of which includes a control portion and a data portion including a byte array.
Step 104: and transmitting the data frame.
In this embodiment, the data frame may be transmitted through a transmission channel such as a wired or wireless channel.
It should be noted that, the data frame is still based on the data frame structure of the target transmission protocol, so when data is transmitted between two communication parties, it is not necessary to frequently negotiate how many times of data is transmitted, and instead, the byte array corresponding to the target data is written in the data portion of the data frame based on the target transmission protocol, after the electronic device as the receiving party receives the data frame, the data portion of the data frame, namely the byte array, can be analyzed according to the target transmission protocol, and then the target data in the data portion is analyzed according to the standard format, therefore, the two communication parties can transmit any data according to the requirement only by negotiating the standard format.
As can be seen from the above, in the data transmission method provided in the first embodiment of the present application, after obtaining the target data, the target data is processed into the byte array according to the standard format, and then the data frame of the target transmission protocol is generated according to the byte array, so that the data frame is transmitted. It can be seen that, in this embodiment, data can be transmitted according to the target transmission protocol in combination with the standard format, without frequently modifying the transmission protocol, thereby improving the data transmission efficiency.
In one implementation, the length bytes in the byte array are used to represent that the target number of bytes after the length bytes belongs to a target data, in accordance with the standard format structure. That is, the value of the length byte, that is, the target number is the number of bytes of the type byte and the content byte belonging to the same target data as the length byte after the length byte. For example, as shown in fig. 5, the byte array contains a length byte, a type byte, and a content byte, and if the value of the length byte is 0F, 15 bytes from the length byte belong to the same target data as the length byte, that is, the sum of the number of bytes of the type byte and the number of bytes of the content byte is 15.
Based on this, after the electronic device as the receiving side in the communication party parses the byte array which is the data portion of the data frame, the electronic device reads the value in the length byte first, then reads the corresponding number of bytes from the length byte backward according to the value in the length byte, and these read bytes and the length byte belong to the same target data. Based on this, the electronic device as the receiving side can obtain the data content of the target data corresponding to the content byte and the data type of the target data through data restoration after reading the value of the type byte and the value of the type byte.
For example, as shown in fig. 6, after parsing out the data portion of the data frame, i.e., the byte array, the electronic device as the receiving side reads the value in the first byte, i.e., 15, starts reading 15 bytes from the second byte, then restores the value of the first byte of the 15 bytes to the data type of the target data, such as the type of Mac address, and restores the value of the last 14 bytes of the 15 bytes to the data content of the target data, such as the Mac address.
Based on the above implementation manner, when the target data is obtained in step 101, specifically: target data of a target type is obtained. For example, in this embodiment, the target data may be read or received through a data interface, and the data type corresponding to the data interface is the target type of the target data. That is, in the present embodiment, when the target data is obtained, the data type of the target data, that is, the target type, may be obtained at the same time.
For example, in the present embodiment, destination data of a Mac address of a device, which has a data type of the Mac address, is obtained through an address interface.
Based on this, when processing the target data based on the standard format to obtain the byte array in step 102, this may be specifically achieved as follows, as shown in fig. 7:
step 701: converting the target data into a target value.
Specifically, in this embodiment, the target data may be converted into a binary, hexadecimal, or other target value.
For example, the Mac address in this embodiment: 30:83:D2:78:E8:98 into target value: 3083d278e898. For another example, the product name in this embodiment is: * The rescuer electronic contest mobile phone is converted into a target value: e88194e683b3e68bafE69591e88085e794b5e7ab9ee6898be69cba. For another example, in this embodiment, the phone number: 18515887020 to a target value: 3138353135383837303230. for another example, in this embodiment, ABILITY16 is converted into the target value: 16.
step 702: the byte number of the content bytes is obtained based on the target value.
In this embodiment, the byte number of the content bytes is obtained according to the length of the target value.
For example, according to the target value corresponding to the Mac address: 3083d278e898, obtaining the number of bytes of content bytes: 6. for another example, according to the product name: * Target value corresponding to the rescuer electronic competition mobile phone: the length of e88194e683b3e68bafE69591e88085e794b5e7ab9ee6898be69cba, the number of bytes of content bytes: 27. for another example, according to the target value corresponding to the telephone number: 3138353135383837303230, the byte count 11 of the content bytes is obtained. For another example, according to the target value corresponding to ABILITY:16, the byte number 1 of the content bytes is obtained.
Step 703: a first value is obtained that characterizes the length based on the number of bytes of the content bytes.
Wherein the first value is the sum of the number of bytes of the content bytes and the number of type bytes.
For example, in the case where the type byte is 1 byte, a value obtained by adding 1 to the number of bytes of the content byte is taken as the first value.
Step 704: a second value is obtained that characterizes the target type.
Specifically, in this embodiment, the second value corresponding to the target type may be obtained according to the correspondence between the type and the value. For example, the type of Mac address corresponds to value 03, the type of product name corresponds to value 01, the type of phone number corresponds to value 02, and the type of abilite corresponds to value 04. Based on this, in the present embodiment, for the target type, a corresponding second value is obtained.
Step 705: the combination of the first value, the second value, and the target value is used as the value of the byte array.
Specifically, the first value is used as the value of the length byte in the byte array, the second value is used as the value of the type byte in the byte array, and the target value is used as the value of the content byte in the byte array.
For example, as shown in fig. 8, 07 (06+01) is taken as the value of the length byte in the byte array, 03 is taken as the value of the type byte in the byte array, and 3083d278e898 is taken as the value of the content byte in the byte array.
Based on this, in step 103 in this embodiment, when generating the data frame of the target transport protocol based on the byte array, the following manner may be implemented:
based on the data portion of the data frame, values of a byte array are sequentially written, the byte array utilizing a set of bytes of the data portion, the bytes of the set being contiguous from byte to byte.
Specifically, in this embodiment, in a group of bytes in the data portion of the data frame, the first value, the second value, and the target value in the byte array are written in sequence. In the group of bytes, bytes corresponding to the first value, the second value and the target value are continuous, and no idle bytes exist between the first value, the second value and the target value. For example, as shown in fig. 9, 07, 03, and 3083d278e898 are written in sequence in the data portion of the data frame, whereby 07033083d278e898 is the value of the byte array corresponding to Mac address 30:83:d2:78:e8:98, which occupies a group of bytes of the data portion of the data frame.
In one implementation manner, in this embodiment, a plurality of target data may be packaged into one or more data frames, specifically, when the target data is obtained in step 101, this is specifically: a plurality of target data is obtained, each of which is of a different type. For example, the plurality of target data obtained in step 101 may include: 30:83:D2:78:E8:98 of Mac address type, device name type, rescuer electronic contest mobile phone, 18515887020 of telephone number type, 16 of ABILITY type and the like.
Based on this, in step 102, when processing the target data based on the standard format to obtain the byte array, specifically: each target data is processed based on a standard format to obtain a plurality of byte arrays. Each byte array corresponds to one target data, and in this embodiment, the target data may be processed based on a standard format for each target data, so as to obtain a byte array corresponding to each target data. The method of obtaining each byte array may refer to the flow and corresponding content shown in fig. 6, which will not be described in detail herein.
Thus, when generating the data frame of the target transport protocol based on the byte array in step 103, it can be obtained as follows:
based on the data portion of the data frame, sequentially writing a value for each byte array, each byte array utilizing a set of bytes of the data portion that are contiguous from byte to byte.
In this embodiment, a plurality of byte arrays corresponding to the plurality of target data may be written into the data portion of the data frame according to the target transmission protocol, specifically: in the data part of the data frame, corresponding byte arrays can be written in sequence according to the sequence among the target data, no idle byte is arranged among each byte array, and no idle byte is arranged among the values in the byte arrays in a group of bytes occupied by the data part of the data frame. Furthermore, the byte array is written in a standard format for each value in a set of bytes occupied by the data portion of the data frame.
In one possible scenario, since the size of the target data may be different, the number of bytes of the corresponding resulting byte array may be different, that is, the number of bytes of a set of bytes of each byte array utilization data portion is different.
For example, as shown in fig. 10, mac address: the values of the byte arrays corresponding to 30:83:D2:78:E8:98 are: 07033083d278e898, product name: * The value of the byte array corresponding to the rescuer electronic contest mobile phone is as follows: 1c01e88194e683b3e68bafE69591e88085e794 e7ab9ee6898be69cba, the byte numbers of the two byte arrays in a group of bytes of the data portion of the data frame being different: 8 and 29, based on which the two byte arrays are written sequentially into the data portions in two data packets (broadcast packet and response packet) of the data frame to obtain the data frame.
In one implementation, the number of bytes of the data portion is also limited in the structure of the data frame corresponding to the target transmission protocol, and if the sum of the number of bytes of the byte array corresponding to the target data to be transmitted exceeds the number of bytes of the data portion of one data frame, then frame transmission is required. That is, the target data is transmitted through a plurality of data frames, and the data frames include at least an index byte for indicating the total number of frames in the data stream in which the data frames are located and the frame order of the data frames in the data stream.
The data stream where the data frame is located is a stream composed of data frames corresponding to target data to be transmitted. Each data frame in the data stream contains index bytes, and the index bytes can be multiple, wherein one part of index bytes are used for indicating the total frame quantity in the data stream of the data frame to which the index bytes belong, and the other part of index bytes are used for indicating the frame sequence of the data frame to which the index bytes belong in the data stream.
In particular, the total number of frames and the frame order may be determined based on the number of bytes in the byte array and the number of bytes of the data portion of the data frame. For example, dividing the number of bytes in the byte array by the number of bytes in the data portion of a data frame, taking the integer portion of the quotient obtained, and adding 1 to the integer portion, i.e., the total frame amount. Based on this, in step 103, first data frames of the total number of frames are created, and the frame order in the index byte in each data frame is marked, then the values in the byte array of the target data are written in sequence into the data portions of these data frames in the frame order between the data frames.
For example, as shown in fig. 11, mac address: the values of the byte arrays corresponding to 30:83:D2:78:E8:98 are: 07033083d278e898, product name: * The value of the byte array corresponding to the rescuer electronic contest mobile phone is as follows: 1c01e88194e683b3e68bafE69591e88085e794 e7ab9ee6898be69cba, the value of the byte array corresponding to telephone number 18515887020 is: 0c 02397335353837303230, the value of the byte array corresponding to ability: 020416. the four byte arrays differ in the number of bytes of a group of bytes of the data portion of the data frame by: 8. 29, 13 and 3, the total number of bytes 53 of which exceeds the number of bytes 46 of the data portion of one data frame, based on which two data frames are created in the present embodiment: data frame 1 and data frame 2, each data frame contains two data packets: broadcasting a packet and a response packet, and writing a corresponding frame total amount 2 and a frame order 0 on index bytes in a control portion of the broadcasting packet of the first data frame 1, writing a corresponding frame total amount 2 and a frame order 1 on index bytes in a control portion of the broadcasting packet of the second data frame 2, and sequentially writing values of the above four byte arrays to data portions of the two data frames to obtain a data frame.
Referring to fig. 12, a flowchart of a data transmission method according to a second embodiment of the present application is provided, and the method may be applied to an electronic device capable of performing data frame processing, such as a mobile phone, a tablet, or a notebook. The electronic device in this embodiment is an electronic device in which both communication parties are the receiving parties. The technical scheme in the embodiment is mainly used for improving the data transmission efficiency.
Specifically, the method in this embodiment may include the following steps:
step 1201: scanning to obtain a data frame.
The electronic device in this embodiment may scan the surrounding environment through a communication device, such as a bluetooth module, to obtain a data frame broadcasted by the electronic device in the surrounding environment. The data frame may include two data packets, such as a broadcast packet and a response packet.
Step 1202: the data frame is processed according to the target transport protocol to obtain an array of bytes.
Specifically, in this embodiment, the data portion of the data frame, that is, the byte array, may be first parsed according to the target transmission protocol, where the byte array may correspond to one target data or multiple target data. For example, taking two data frames as shown in fig. 11 as an example, in this embodiment, according to a target transmission protocol, such as bluetooth protocol, the data portions in the broadcast packet and the response packet included in each of the two data frames are parsed to obtain the byte array.
Step 1203: based on the standard format, the byte array is processed to obtain the target data.
In this embodiment, the byte portion corresponding to the target data in the byte array may be read according to the standard format, and then the read byte portion is converted to obtain the target data, so that any data may be transmitted as required by only negotiating the standard format between the two communication parties.
For example, taking two data frames as shown in fig. 11 as an example, in this embodiment, according to a target transmission protocol, such as a bluetooth protocol, data portions in a broadcast packet and a response packet included in each of the two data frames are parsed, according to a frame sequence represented by index bytes of each of the two data frames, the parsed data portions in the two data frames are spliced to obtain a byte array, and then according to values of standard format and length bytes of length, type and content, values of Mac address, product name, telephone number and content bytes corresponding to each of ABILITY are sequentially split, that is: the value of the content byte of the Mac address: 3083d278e898, the value of the content bytes of the product name is: e88194e683b3e68bafE69591e88085e794 e7ab9ee6898be69cba, the value of the content bytes of the telephone number is: 31383353837303230, value of content byte of ability:16, finally, converting the values of the content bytes respectively to obtain corresponding content, namely: mac address: 30:83:D2:78:E8:98, product name: * Rescue electronic competition mobile phone, telephone number: 18515887020, ABILITY:16, thereby obtaining target data.
As can be seen from the above, in the data transmission method provided in the second embodiment of the present application, after scanning to obtain a data frame, the data frame is processed according to the target transmission protocol to obtain a byte array, and then the byte array is processed according to the standard format to obtain the target data, so as to realize successful data transmission. Therefore, the data can be transmitted according to the target transmission protocol in combination with the standard format without frequently modifying the transmission protocol, thereby improving the data transmission efficiency.
Referring to fig. 13, a schematic structural diagram of an electronic device according to a third embodiment of the present application, as shown in fig. 2, the electronic device may include the following structure:
processing means 1301, such as a central processing unit CPU (centralprocessingunit), is used to obtain target data; processing the target data based on a standard format to obtain a byte array; generating a data frame of a target transmission protocol based on the byte array;
a communication device 1302, such as a bluetooth module, is used to transmit the data frames.
As can be seen from the above-mentioned scheme, in the electronic device provided in the third embodiment of the present application, after obtaining the target data, the target data is processed into the byte array according to the standard format, and then the data frame of the target transmission protocol is generated according to the byte array, so that the data frame is transmitted. Therefore, the data can be transmitted according to the target transmission protocol in combination with the standard format without frequently modifying the transmission protocol, thereby improving the data transmission efficiency.
Referring to fig. 14, a schematic structural diagram of an electronic device according to a fourth embodiment of the present application, as shown in fig. 2, the electronic device may include the following structure:
a communication device 1401, such as a bluetooth module or the like, for scanning to obtain a data frame;
processing means 1402, such as a CPU, for processing the data frame according to a target transport protocol to obtain a byte array; and processing the byte array based on a standard format to obtain target data.
As can be seen from the above-mentioned scheme, in the electronic device provided in the fourth embodiment of the present application, after scanning to obtain a data frame, the data frame is processed according to the target transmission protocol to obtain a byte array, and then the byte array is processed according to the standard format to obtain the target data, so that successful data transmission is achieved. Therefore, the data can be transmitted according to the target transmission protocol in combination with the standard format without frequently modifying the transmission protocol, thereby improving the data transmission efficiency.
Taking a bluetooth data frame as an example, in order to realize efficient data transmission, based on the technical scheme of the application, a technical scheme capable of broadcasting relatively more custom data by using bluetooth low energy BLE (BluetoothLowEnergy) is provided in the embodiment. The following are provided:
in this embodiment, the custom data (i.e., the target data in the foregoing) is assembled according to the format of the length-type-content, i.e., data, through the custom data structure. In the case where one data frame is left intact, the complete custom data is split into different data frames, and all custom data is sent in frames by identifying the total packet of data and the current index (i.e., index byte in the foregoing) at a location in the data frame. The scanning end, namely the point device of the receiving party in the previous text, can analyze the complete custom data through the index, and analyze different types of data through the custom structure.
It can be seen that, after the scheme in this embodiment is adopted, a relatively large amount of required data and various types of required data can be broadcast, and the method is not limited to the broadcast fixed format, and has a certain guarantee in terms of data integrity.
Taking a data frame based on the bluetooth protocol as an example, as shown in fig. 15 and 16, the total frame and index are represented by eight bits at one fixed byte of the data frame, such as the 11 th byte position in fig. 15, for example, the first 4bytes of the 11 th byte are the total frame (i.e., the total amount of frames), and the last 4bytes of the 11 th byte are the index (i.e., the frame order). A broadcast packet (bleadventisetata, 31 bytes) shown in fig. 15 follows a response packet (BLEResponseData, 31 bytes) shown in fig. 16, and the servicedata portion (i.e. the data portion, 19 bytes) of the two data packets is the custom data to be transmitted. In the broadcast packet shown in fig. 15, bits 0 to 11 are bytes of a BLE-based control portion, and bits 12 to 30 are bytes of a BLE-based data portion; in the response packet shown in fig. 16, bits 0 to 3 are bytes of the BLE-based control portion, and bits 4 to 30 are bytes of the BLE-based data portion.
In this embodiment, all the custom data are assembled in the format of length len+ type+ content and then placed in the servicedata portion in fig. 15 and 16 respectively, where the custom data are longer, they may be placed in the servicedata portion of two data packets of multiple data frames by framing.
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method of data transmission, the method comprising:
obtaining target data;
processing the target data based on a standard format to obtain a byte array;
generating a data frame of a target transmission protocol based on the byte array;
and transmitting the data frame.
2. The method of claim 1, the standard format being a format of length, type, and content composition;
wherein the length is used to characterize the type and the number of bytes occupied by the content, and the type is used to characterize the type of the content.
3. The method of claim 1, the byte array comprising length bytes, type bytes, and content bytes.
Wherein the length byte is used to indicate that the target number of bytes after the length byte belongs to one target data.
4. A method according to claim 2 or 3, obtaining target data comprising:
target data of a target type is obtained.
5. The method of claim 4, the processing the target data based on a standard format to obtain a byte array, comprising:
converting the target data into a target value;
obtaining a byte number of the content bytes based on the target value;
obtaining a first value for characterizing a length based on a number of bytes of the content bytes, the first value being a sum of the number of bytes of the content bytes and the number of type bytes;
obtaining a second value for characterizing the target type;
taking the combination of the first value, the second value and the target value as the value of the byte array;
wherein generating a data frame of a target transport protocol based on the byte array comprises:
the values of the byte arrays are sequentially written based on the data portion of the data frame, the byte arrays utilizing a set of bytes of the data portion, the bytes of the set of bytes being contiguous from byte to byte.
6. The method of claim 1, the obtaining target data comprising:
obtaining a plurality of target data, wherein each target data is different in type;
wherein said processing said target data based on a standard format to obtain a byte array comprises:
processing each of the target data based on the standard format to obtain a plurality of byte arrays;
wherein generating a data frame of the target transport protocol based on the byte array comprises:
sequentially writing a value of each of said byte arrays based on a data portion of said data frame, each of said byte arrays utilizing a set of bytes of said data portion being contiguous, each of said set of bytes being byte-to-byte.
Wherein each of the byte arrays utilizes a different number of bytes of a group of bytes of the data portion.
7. The method of claim 1, wherein the data frame includes at least an index field, the index field being used to indicate a total amount of frames in a data stream in which the data frame is located and an order of frames of the data frame in the data stream;
wherein the frame total and the frame order are determined based on a number of bytes in the byte array and a number of bytes of a data portion of the data frame.
8. A method of data transmission, the method comprising:
scanning to obtain a data frame;
processing the data frame according to a target transmission protocol to obtain a byte array;
and processing the byte array based on a standard format to obtain target data.
9. An electronic device, comprising:
processing means for obtaining target data; processing the target data based on a standard format to obtain a byte array; generating a data frame of a target transmission protocol based on the byte array;
communication means for transmitting the data frame.
10. An electronic device, comprising:
communication means for scanning to obtain a data frame;
processing means for processing the data frame according to a target transport protocol to obtain a byte array; and processing the byte array based on a standard format to obtain target data.
CN202310215605.1A 2023-02-28 2023-02-28 Data transmission method and electronic equipment Pending CN116233264A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310215605.1A CN116233264A (en) 2023-02-28 2023-02-28 Data transmission method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310215605.1A CN116233264A (en) 2023-02-28 2023-02-28 Data transmission method and electronic equipment

Publications (1)

Publication Number Publication Date
CN116233264A true CN116233264A (en) 2023-06-06

Family

ID=86578439

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310215605.1A Pending CN116233264A (en) 2023-02-28 2023-02-28 Data transmission method and electronic equipment

Country Status (1)

Country Link
CN (1) CN116233264A (en)

Similar Documents

Publication Publication Date Title
US20060034274A1 (en) System and method for variable length acknowledgements in a shared resource network
US20110317719A1 (en) Data link layer headers
EP2509344B1 (en) Method for transmitting and receiving multimedia information and terminal thereof
US20060136614A1 (en) System and method for variable length aggregate acknowledgements in a shared resource network
MX2013013367A (en) Apparatus and methods for media access control control replacement.
CN101529827B (en) Length indicator optimization
CN102365884A (en) Method and system for reducing header information in communication systems
Thubert et al. IPv6 over low-power wireless personal area network (6LoWPAN) routing header
ZA200505075B (en) Error processing apparatus and method for wireless communication system
KR20090029665A (en) Effective data block transmission method using a header indicator
CN103209045A (en) Data communication method, device and system
WO2006019501A2 (en) Efficient data transmission by data aggregation
WO2017000915A1 (en) Multicast transmission method, information extraction method and corresponding terminal and device
KR20000056162A (en) Data transmission protocol and terminal using short message service
WO2020220328A1 (en) Wireless communication method and apparatus
CN111555855B (en) Wireless transmission method and device
CN109526030A (en) Processing method, device and the equipment of message
AU2006290994B2 (en) Method for indicating padding in a digital mobile radio system
KR101743779B1 (en) Apparatus and method of encoding and decoding control information in a medium access control protocol data unit
CN116233264A (en) Data transmission method and electronic equipment
KR100386571B1 (en) Method and Telephone for still picture transport
US20060067328A1 (en) Method and apparatus for offset interleaving of vocoder frames
CN101141702A (en) Short message report processing method and system of black list book
CN115175110B (en) Method and system for rapidly distributing network for equipment based on multicast
CN113489718B (en) Method for generating image by recombining transmission flow of DICOM (digital imaging and communications in medicine) protocol

Legal Events

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