Message packing method, terminal equipment and storage medium

By identifying and distinguishing Bluetooth messages from different sources in WearSDK devices and using preset caches to group packets, the problem of failure of the device when grouping packets is solved, and the accuracy and reliability of data transmission are improved.

CN119255305AActive Publication Date: 2025-01-03HONOR DEVICE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410096418.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-23
Publication Date
2025-01-03
Estimated Expiration
2044-01-23

AI Technical Summary

Technical Problem

When the WearSDK device grouped Bluetooth messages from multiple APPs, it was unable to distinguish messages from different sources, resulting in the group packet failure, affecting the accuracy of data transmission.

Method used

By receiving Bluetooth messages sent by the user device, identifying the message source information and adding it to the message, using a preset cache to distinguish and store messages from different sources, and grouping packets according to the protocol packet structure to avoid failure of group packets.

Benefits of technology

It realizes the distinction between Bluetooth messages from different sources and correct packet grouping, improves the accuracy and reliability of data transmission, and avoids packet loss caused by verification errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119255305A_ABST
    Figure CN119255305A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to a message packing method, terminal equipment and a storage medium. The method comprises the following steps: receiving a Bluetooth message sent by user equipment; identifying source information of the Bluetooth message, adding the source information to the Bluetooth message, and storing the updated Bluetooth message in a first preset cache; reading the updated Bluetooth message from the first preset cache, obtaining data and source information of the updated Bluetooth message, and allocating a corresponding second preset cache according to the source information; and storing the read and updated data of the Bluetooth message in a second preset cache corresponding to the source information according to a protocol packet structure to obtain a corresponding protocol packet. According to the method and the device, different Bluetooth messages from the user equipment can be grouped after being distinguished according to the source information of the Bluetooth messages, so that grouping failure caused by grouping the Bluetooth messages with different source information is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a message packaging method, terminal equipment and storage medium. Background Art

[0002] Devices that integrate the Wear Software Development Kit (WearSDK) (hereinafter referred to as WearSDK devices) can establish communication connections with multiple devices (such as mobile phones, etc.) or multiple applications (Application, APP) of a device at the same time. For example, a long protocol packet sent by an APP may be divided into multiple protocol packets. When each protocol packet is sent through the Bluetooth module, it will be divided into multiple frames of Bluetooth messages for transmission. However, Bluetooth messages from multiple APPs may be sent alternately to the WearSDK device. When the WearSDK device packages the Bluetooth messages sent by multiple APPs, it packages multiple continuously received Bluetooth messages and does not distinguish between Bluetooth messages from different APPs. As a result, after the WearSDK device packages the Bluetooth messages of multiple APPs, it will lose packets due to verification errors, resulting in packet failure and affecting the accurate transmission of data. Summary of the invention

[0003] In view of the above, it is necessary to provide a message packaging method, a terminal device and a storage medium to solve the problem that the WearSDK device fails to package the Bluetooth messages of multiple APPs.

[0004] In a first aspect, an embodiment of the present application provides a message packaging method, which is applied to a terminal device, and the method includes: receiving a Bluetooth message sent by a user device; identifying source information of the Bluetooth message, adding the source information to the Bluetooth message, and storing the Bluetooth message in a first preset cache; reading the Bluetooth message from the first preset cache, obtaining the data of the Bluetooth message and the source information, and allocating a corresponding second preset cache according to the source information; storing the read data of the Bluetooth message in a second preset cache corresponding to the source information according to a protocol packet structure to obtain a corresponding protocol packet.

[0005] When the above technical solution detects that there is a Bluetooth message in the first preset cache, it reads the Bluetooth message from the first preset cache, obtains the Bluetooth message and source information from the read information, and allocates different second preset caches according to the source information, and stores the Bluetooth message in the second preset cache corresponding to the source information, and stores the read Bluetooth message in the corresponding second preset cache according to the protocol packet structure to obtain a protocol packet. In this way, different Bluetooth messages from user devices can be distinguished according to the source information of the Bluetooth messages and then grouped, thereby avoiding the occurrence of grouping failure caused by grouping Bluetooth messages with different source information.

[0006] In one embodiment of the present application, the method further includes: if it is determined that the protocol package is to be packaged, determining the position mark of the protocol package, and packaging the protocol package according to the position mark of the protocol package to obtain a long protocol package. After completing the protocol package, the above technical solution determines the position mark of the protocol package, and packages the protocol package according to the position mark of the protocol package to obtain a long protocol package, thereby realizing the data packaging function at the application layer and facilitating application calls.

[0007] In one embodiment of the present application, the protocol packet structure includes a protocol header, and determining to group the protocol packet includes: parsing the protocol header of the protocol packet to obtain a first flag bit, and if the value of the first flag bit is a True value, determining to group the protocol packet.

[0008] In one embodiment of the present application, the position mark includes a first packet, a middle packet and a last packet, and the protocol packets are grouped according to the position mark of the protocol packets to obtain a long protocol packet, including: sequentially combining the protocol packet with the position mark as the first packet, the protocol packet with the position mark as the middle packet and the protocol packet with the position mark as the last packet to obtain a long protocol packet. The above technical scheme can realize the function of grouping multiple protocol packets by combining the protocol packet with the position mark as the first packet, the protocol packet with the position mark as the middle packet and the protocol packet with the position mark as the last packet.

[0009] In one embodiment of the present application, the identifying the source information of the Bluetooth message and adding the source information to the Bluetooth message include: identifying the Bluetooth channel information of the Bluetooth message, marking the Bluetooth channel information as a handle value; generating an information header of the Bluetooth message based on the handle value and the frame length of the Bluetooth message; and updating the Bluetooth message by inserting the information header into the head position of the Bluetooth message. The above technical solution can distinguish the received Bluetooth messages by marking the Bluetooth channel information as a handle value and generating the information header of the Bluetooth message based on the handle value and the frame length of the Bluetooth message.

[0010] In one embodiment of the present application, if the first preset cache includes multiple frames of Bluetooth messages, the reading of the Bluetooth messages from the first preset cache includes: recording the reading information of each frame of Bluetooth messages, the reading information including the read data and unread data of each frame of Bluetooth messages; if the reading information of the previous frame of Bluetooth messages of the current frame of Bluetooth messages includes unread data, reading the previous frame of Bluetooth messages; if the reading information of the previous frame of Bluetooth messages does not include unread data, reading the current frame of Bluetooth messages. The above technical solution can ensure that Bluetooth messages are not missed when packaging by recording the reading information of each frame of Bluetooth messages and reading Bluetooth messages based on the reading information.

[0011] In one embodiment of the present application, the protocol packet structure includes a protocol header, a protocol packet length, and protocol data. The data of the read Bluetooth message is stored in a second preset cache corresponding to the source information according to the protocol packet structure to obtain a corresponding protocol packet, including: reading the protocol header from the first preset cache, and storing the protocol header in the second preset cache; reading the protocol packet length from the first preset cache, and storing the protocol packet length in the second preset cache; reading the data of the protocol packet length from the first preset cache, and storing the data of the protocol packet length in the second preset cache.

[0012] In one embodiment of the present application, after reading the protocol header from the first preset cache and storing the protocol header in the second preset cache, the method further includes: setting a first timer, and clearing the second preset cache after the first timer reaches a first preset timing time. The above technical solution stores the protocol header in the second preset cache, sets a first timer, and clears the second preset cache after the first timer reaches the first preset timing time, so as to avoid the program staying in the current protocol packet assembly process.

[0013] In one embodiment of the present application, the protocol package is grouped according to the position mark of the protocol package to obtain a long protocol package, including: if it is determined that the position mark of the protocol package is the first package, judging whether there is a third preset cache; if the third preset cache does not exist, establishing the third preset cache, setting a second timer for timing, and releasing the memory of the third preset cache after the timing time reaches the second preset timing time; if the third preset cache exists, clearing the existing data in the third preset cache, resetting the second timer for timing; storing the protocol package with the position mark as the first package in the third preset cache.

[0014] In one embodiment of the present application, the protocol packets are grouped according to the position mark of the protocol packets to obtain a long protocol packet, including: if it is determined that the position mark of the protocol packet is an intermediate packet, judging whether there is the third preset cache; if there is the third preset cache, and the previous protocol packet stored in the third preset cache is the first packet or the intermediate packet, storing the protocol packet with the position mark as the intermediate packet in the third preset cache; if the third preset cache does not exist, discarding the protocol packet.

[0015] In one embodiment of the present application, the protocol package is grouped according to the position mark of the protocol package to obtain a long protocol package, including: if it is determined that the position mark of the protocol package is a tail package, judging whether there is a third preset cache; if the third preset cache exists, and the previous protocol package stored in the third preset cache is the first package or the middle package, the protocol package with the position mark as the tail package is stored in the third preset cache, parsing the functional instructions from the long protocol package, executing the functional instructions, releasing the third preset cache, and deleting the second timer.

[0016] In one embodiment of the present application, the method further comprises: verifying the protocol packet according to a preset verification algorithm. The above technical solution verifies the protocol packet according to a preset verification algorithm to verify whether the protocol packet after the Bluetooth message is packaged is correct, so as to discard the protocol packet after verification error.

[0017] In an embodiment of the present application, the method further includes: parsing a function instruction from the protocol package or the long protocol package, and executing the function instruction.

[0018] In a second aspect, an embodiment of the present application provides a terminal device, which includes a memory and a processor: the memory is used to store program instructions; the processor is used to read and execute the program instructions stored in the memory, and when the program instructions are executed by the processor, the terminal device executes the above-mentioned message packaging method.

[0019] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which stores program instructions. When the program instructions are executed on a terminal device, the terminal device executes the above-mentioned message packaging method.

[0020] In addition, the technical effects brought about by the second to third aspects can be found in the descriptions related to the methods of each design in the above method part, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 Schematic diagram of packaging existing Bluetooth messages.

[0023] Figure 2 This is an application environment diagram of the message packaging method in one embodiment of the present application.

[0024] Figure 3 A schematic diagram of the process of Bluetooth message packaging provided in one embodiment of the present application.

[0025] Figure 4 A flowchart of a message packaging method provided in one embodiment of the present application.

[0026] Figure 5 A schematic diagram of the process of Bluetooth message packaging provided by another embodiment of the present application.

[0027] Figure 6 A schematic diagram of packaging Bluetooth messages provided in an embodiment of the present application.

[0028] Figure 7 A flow chart of a method for packaging Bluetooth messages provided in one embodiment of the present application.

[0029] Figure 8 A flow chart of a method for grouping protocol packets to obtain a long protocol packet provided in an embodiment of the present application.

[0030] Fig. 9 A schematic diagram of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0031] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way.

[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by technicians in the technical field in this application. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. It should be understood that, unless otherwise specified in this application, " / " means or. For example, A / B can represent A or B. "And / or" in this application is only a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. "At least one" means one or more. "Multiple" means two or more than two. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, a, b and c seven situations.

[0033] Devices that integrate the Wear Software Development Kit (WearSDK) (hereinafter referred to as WearSDK devices) can establish communication connections with multiple devices (such as mobile phones, etc.) or multiple applications (Application, APP) of a device at the same time. For example, a long protocol packet sent by an APP may be divided into multiple protocol packets. When each protocol packet is sent through the Bluetooth module, it will be divided into multiple frames of Bluetooth messages for transmission. However, Bluetooth messages from multiple APPs may be sent alternately to the WearSDK device. When the WearSDK device groups Bluetooth messages sent by multiple APPs, it will group multiple continuously received Bluetooth messages and will not distinguish between Bluetooth messages from different APPs (refer to Figure 1 As shown in the figure, after the WearSDK device packages the Bluetooth messages of multiple apps, it will lose the packets due to verification errors, resulting in the failure of packaging and affecting the accurate transmission of data.

[0034] refer to Figure 2 As shown, it is an application environment diagram of the message packaging method in one embodiment of the present application. The message packaging method is applied in the WearSDK device 10. The WearSDK device 10 can be a device that integrates a wearable device software development kit and is used for interaction. The WearSDK device 10 also has a Bluetooth function. In one embodiment of the present application, the WearSDK device 10 can be a headset, a speaker, a watch, a bracelet and other devices. The above examples are only exemplary, but are not limited to this in actual applications.

[0035] In one embodiment of the present application, the WearSDK device 10 can communicate with multiple user devices 20 (the user devices 20 can be multiple mobile phones, for example, mobile phone 1 and mobile phone 2). In one embodiment of the present application, the user device 20 includes a first Bluetooth module 21 and at least one APP 22, and the WearSDK device 10 includes a second Bluetooth module 11 and a WearSDK module 12. The APP in the user device 20 can send a message to the WearSDK device 10 through the first Bluetooth module 21. Figure 3 As shown, it is a schematic diagram of the process of Bluetooth message grouping in an embodiment of the present application. The APP 22 in the user device 20 can divide the long protocol packet to be sent into multiple shorter protocol packets, and send the divided protocol packets to the WearSDK device 10 through the first Bluetooth module 21. When the first Bluetooth module 21 transmits the protocol packet, it can divide the protocol packet into multiple frames of Bluetooth messages according to the maximum transmission length of the message defined by the maximum transmission unit (Maximum Transmission Unit, MTU) of the first Bluetooth module 21, and send each frame of Bluetooth message to the WearSDK device 10 through a Bluetooth channel (Channel), wherein each Bluetooth channel corresponds to an APP 22. In one embodiment of the present application, the protocol packet includes a protocol packet structure, and the protocol packet structure includes a protocol header, a protocol packet length, and protocol data, wherein the protocol header includes the interaction information of the APP, the protocol packet length includes the data length information of the protocol packet, and the protocol data includes the data content of the protocol packet. Each frame of Bluetooth message can carry content such as the protocol header, the protocol packet length, and the protocol data.

[0036] In one embodiment of the present application, the second Bluetooth module 11 of the WearSDK device 10 receives the Bluetooth message sent by the user device 20, identifies the Bluetooth channel information of the Bluetooth message, and marks the identified Bluetooth channel information as a handle value. The second Bluetooth module 11 sends the identified Bluetooth message and the Handle value corresponding to the Bluetooth message to the WearSDK module 12. The WearSDK module 12 packages the received Bluetooth message according to the Handle value corresponding to the Bluetooth message, so that the WearSDK module can distinguish and package the Bluetooth messages from different apps according to the Handle value.

[0037] Avoid package assembly failure.

[0038] In one embodiment of the present application, the WearSDK device 10 can also communicate with other WearSDK devices. For example, the WearSDK device 10 communicates with other WearSDK devices through a master-slave communication mode. For another example, the WearSDK device 10 acts as a slave and communicates with other WearSDK devices that act as a host.

[0039] The following will be combined Figure 4 The following is a flowchart of a message packaging method provided by an embodiment of the present application. Figure 4 The method of the example includes one or more steps, but does not constitute a limitation of the present application. In addition, the order of the steps of the method is only an example, and the order of the steps can be changed. Without departing from the content disclosed in the present application, additional steps can be added or steps can be reduced. The method specifically includes the following steps.

[0040] Step S401: receiving a Bluetooth message sent by a user equipment.

[0041] In one embodiment of the present application, the Bluetooth message can be one of setting sound effect information, querying device information, querying configuration information, and downloading an Over-the-Air-Technology (OTA) upgrade package. The above example is only an exemplary description, but it is not limited to this in actual application. The following uses the user device as a mobile phone, the WearSDK device as a headset, and the Bluetooth message as setting sound effect information and querying device information as an example to illustrate the message packaging method of the embodiment of the present application.

[0042] In one embodiment, the first APP of the mobile phone (such as a music APP) divides the long protocol packet of the sound effect information into multiple shorter first protocol packets, and transmits the divided first protocol packets through the first Bluetooth module (such as Figure 1 When transmitting the first protocol packet, the first Bluetooth module divides the first protocol packet into multiple frames of first Bluetooth messages according to the maximum transmission length of the message defined by the maximum transmission unit of the first Bluetooth module, and sends each frame of the first Bluetooth message to the headset through the first Bluetooth channel, wherein the first Bluetooth channel corresponds to the first APP.

[0043] The second APP of the mobile phone (such as the system setting APP) divides the long protocol packet of the device information query into multiple shorter second protocol packets, and sends the divided second protocol packets to the headset through the first Bluetooth module. When the first Bluetooth module transmits the second protocol packet, it divides the second protocol packet into multiple frames of second Bluetooth messages according to the maximum transmission length of the message defined by the maximum transmission unit of the first Bluetooth module, and sends each frame of the second Bluetooth message to the headset through the second Bluetooth channel, where the second Bluetooth channel corresponds to the second APP. In one embodiment of the present application, the first Bluetooth message and the second Bluetooth message both carry content such as the protocol header, the protocol packet length, and the protocol data.

[0044] refer to Figure 3 , the second Bluetooth module of the headset (such as Figure 2 The second Bluetooth module 11) in the mobile phone receives the first Bluetooth message and the second Bluetooth message sent by the first Bluetooth module of the mobile phone respectively.

[0045] Step S402: identifying source information of the Bluetooth message, updating the Bluetooth message by adding the source information to the Bluetooth message, and storing the updated Bluetooth message in a first preset cache.

[0046] refer to Figure 5 , the second Bluetooth module of the headset (such as Figure 2 When the second Bluetooth module 11 in the headset receives the first Bluetooth message sent by the mobile phone, it identifies the Bluetooth channel information of sending the first Bluetooth message, marks the identified Bluetooth channel information as the first handle value, and sends the first Bluetooth message and the first handle value of the first Bluetooth message to the WearSDK module of the headset (for example Figure 2 WearSDK module 12 in the headset). The WearSDK module of the headset receives the first Bluetooth message sent by the second Bluetooth module and the first handle value of the first Bluetooth message. Based on the first handle value and the frame length of the first Bluetooth message, an information header of the first Bluetooth message is generated, and the WearSDK module of the headset inserts the information header of the first Bluetooth message into the header position of the first Bluetooth message to update the first Bluetooth message, and stores the updated first Bluetooth message in a first preset cache (for example, marked as R_Buffer). In this embodiment, the first handle value in the information header is used to indicate the source information of the first Bluetooth message. For example, the first handle value indicates that the first Bluetooth message comes from the first APP.

[0047] Similarly, when the second Bluetooth module of the headset receives the second Bluetooth message sent by the mobile phone, it identifies the Bluetooth channel information of the second Bluetooth message, marks the identified Bluetooth channel information as the second handle value, and sends the second Bluetooth message and the second handle value of the second Bluetooth message to the WearSDK module of the headset. The WearSDK module of the headset receives the second Bluetooth message and the second handle value of the second Bluetooth message sent by the second Bluetooth module, and generates an information header of the second Bluetooth message based on the second handle value and the frame length of the second Bluetooth message. The WearSDK module of the headset inserts the information header of the second Bluetooth message into the header position of the second Bluetooth message to update the second Bluetooth message, and stores the updated second Bluetooth message in the first preset cache R_Buffer. In this embodiment, the second handle value in the information header is used to indicate the source information of the second Bluetooth message. For example, the second handle value in the information header is used to indicate that the second Bluetooth message comes from the second APP.

[0048] In one embodiment of the present application, the WearSDK module of the headset updates the Bluetooth messages by inserting the received Bluetooth messages into the information headers in sequence according to the order in which the Bluetooth messages are received, and stores the updated Bluetooth messages in the first preset buffer R_Buffer.

[0049] Step S403, reading the Bluetooth message from the first preset buffer, obtaining the data and source information of the Bluetooth message from the read Bluetooth message, and allocating different second preset buffers according to different source information.

[0050] In one embodiment of the present application, when the WearSDK module detects that there is a Bluetooth message in the first preset cache R_Buffer, it reads the Bluetooth message from the first preset cache R_Buffer, obtains the data of the Bluetooth message and the source information of the Bluetooth message from the read Bluetooth message, and allocates a second preset cache according to the source information. For different source information, the WearSDK module can allocate different second preset caches.

[0051] In this embodiment, when the WearSDK module detects that there is a first Bluetooth message in the first preset cache R_Buffer, it reads the first Bluetooth message from the first preset cache R_Buffer, obtains data of the first Bluetooth message and a first handle value of the first Bluetooth message from the read first Bluetooth message, and allocates a second preset cache corresponding to the first handle value according to the first handle value.

[0052] In this embodiment, when the WearSDK module detects that there is a second Bluetooth message in the first preset cache R_Buffer, it reads the second Bluetooth message from the first preset cache R_Buffer, obtains data of the second Bluetooth message and the second handle value of the second Bluetooth message from the read second Bluetooth message, and allocates a second preset cache corresponding to the second handle value according to the second handle value.

[0053] Step S404: store the read data in a second preset cache corresponding to the source information according to the protocol packet structure to obtain a protocol packet.

[0054] In one embodiment of the present application, the WearSDK module reads the data of the Bluetooth message stored in the first preset cache, and stores the read data in the second preset cache according to the protocol packet structure consisting of the protocol header, protocol packet length, and protocol data, and packages the stored data to obtain a protocol packet.

[0055] In this embodiment, the WearSDK module obtains the protocol header, protocol packet length, and protocol data from the data of the first Bluetooth message, and stores the read data in a second preset cache corresponding to the first handle value according to the protocol packet structure, and packages the stored data to obtain the first protocol packet. In this embodiment, the WearSDK module obtains the protocol header, protocol packet length, and protocol data from the data of the second Bluetooth message, and stores the read data in a second preset cache corresponding to the second handle value according to the protocol packet structure, and packages the stored data to obtain the second protocol packet.

[0056] In one embodiment of the present application, the WearSDK module stores the protocol package obtained after packetizing the Bluetooth message in a first preset cache.

[0057] Step S405, determining whether to group the protocol package, if the protocol package is to be grouped, executing step S406, otherwise, if the protocol package is not to be grouped, executing step S407.

[0058] In one embodiment of the present application, the WearSDK module reads the protocol packet from the first preset cache, and parses the protocol header of the protocol packet to determine whether to group the protocol packet. In one embodiment of the present application, the WearSDK module parses the protocol header of the protocol packet to obtain a first flag bit, and if the value of the first flag bit is a preset first value (such as a False value), it is determined not to group the protocol packet, and if the value of the first flag bit is a preset second value (such as a True value), it is determined to group the protocol packet.

[0059] In this embodiment, the WearSDK module parses the protocol header of the first protocol packet to obtain the first flag bit. If the value of the first flag bit of the first protocol packet is a False value, it is determined that the first protocol packet is not to be packaged. If the value of the first flag bit of the first protocol packet is a True value, it is determined that the first protocol packet is to be packaged. Similarly, the WearSDK module parses the protocol header of the second protocol packet to obtain the first flag bit. If the value of the first flag bit of the second protocol packet is a False value, it is determined that the second protocol packet is not to be packaged. If the value of the first flag bit of the second protocol packet is a True value, it is determined that the second protocol packet is to be packaged.

[0060] Step S406, determining the position mark of the protocol package, and grouping the protocol package according to the position mark of the protocol package to obtain a long protocol package.

[0061] In one embodiment of the present application, after determining to group the protocol package, the WearSDK module determines the position mark of the protocol package from the protocol header. For example, according to the position of the protocol package in the long protocol package, the position mark of the protocol package is divided into the first package, the middle package and the tail package, wherein the first package indicates that the protocol package is located at the head position of the long protocol package, the tail package indicates that the protocol package is located at the tail position of the long protocol package, and the middle package indicates that the protocol package is located in the middle position between the head position and the tail position of the long protocol package. The grouping of the protocol packages according to the position mark of the protocol package to obtain the long protocol package includes: sequentially combining the protocol package with the position mark as the first package, the protocol package with the position mark as the middle package, and the protocol package with the position mark as the tail package to obtain the long protocol package. In one embodiment of the present application, the number of the middle packages includes multiple. The grouping of the protocol packages according to the position mark of the protocol package to obtain the long protocol package includes: sequentially combining the protocol package with the position mark as the first package, all the protocol packages with the position mark as the middle package, and the protocol package with the position mark as the tail package to obtain the long protocol package.

[0062] In this embodiment, the WearSDK module sequentially combines the first protocol package whose position is marked as the first package, the first protocol package whose position is marked as the middle package, and the first protocol package whose position is marked as the last package to obtain a first long protocol package; and sequentially combines the second protocol package whose position is marked as the first package, the second protocol package whose position is marked as the middle package, and the second protocol package whose position is marked as the last package to obtain a second long protocol package.

[0063] Step S407, parse the protocol packet or the long protocol packet to obtain the function instruction, and execute the corresponding function according to the function instruction.

[0064] In this embodiment, the WearSDK module parses the setting instructions corresponding to the sound effect setting function from the first protocol package or the first long protocol package, and sets the sound effect of the headset according to the setting instructions; parses the query instructions corresponding to the device information query function from the second protocol package or the second long protocol package, and queries the device information of the headset according to the query instructions.

[0065] In one embodiment of the present application, after step S404, the method further includes: verifying the protocol packet according to a preset verification algorithm. In one embodiment of the present application, the preset verification algorithm includes one of a cyclic redundancy check (CRC) algorithm, a parity check algorithm, and a Hamming code verification algorithm. In this embodiment of the present application, the protocol packet is verified according to the preset verification algorithm to verify whether the protocol packet after the Bluetooth message is packaged is correct. If it is not correct, the protocol packet is discarded.

[0066] In the above embodiment of the present application, when the WearSDK module detects that there is a Bluetooth message in the first preset cache, it reads the Bluetooth message from the first preset cache, obtains the Bluetooth message and source information from the read information, and allocates different second preset caches according to the source information, stores the Bluetooth message in the second preset cache corresponding to the source information, and stores the read Bluetooth message in the corresponding second preset cache according to the protocol packet structure to obtain a protocol packet, so that Bluetooth messages from different APPs can be distinguished according to the source information of the Bluetooth message and then packaged (reference Figure 6 At the same time, after completing the protocol package, the WearSDK module determines the position mark of the protocol package, and packages the protocol package according to the position mark of the protocol package to obtain a long protocol package, thus realizing the data packaging function at the application layer and facilitating application calls.

[0067] refer to Figure 7 FIG. 1 is a flow chart of a method for packaging Bluetooth messages in a first preset buffer provided by an embodiment of the present application, which specifically includes the following steps.

[0068] Step S701: Determine whether a Bluetooth message exists in a first preset buffer.

[0069] In one embodiment of the present application, the WearSDK module stores each received Bluetooth message in a first preset buffer and records the read information of each Bluetooth message. The read information includes the read data and unread data of the Bluetooth message.

[0070] Step S702, determining whether the previous frame of the Bluetooth message of the current frame of the Bluetooth message in the first preset buffer has been read. If the previous frame of the Bluetooth message has been read, executing step S703, if the previous frame of the Bluetooth message has not been read, executing step S704.

[0071] In one embodiment of the present application, if it is determined based on the read information of the previous frame of Bluetooth message that there is unread information in the previous frame of Bluetooth message, the WearSDK module determines that the previous frame of Bluetooth message has not been read; if it is determined based on the read information of the current frame of Bluetooth message that there is no unread information in the previous frame of Bluetooth message, the WearSDK module determines that the reading of the previous frame of Bluetooth message is completed.

[0072] Step S703, read the current frame Bluetooth message from the first preset buffer, and determine whether the current frame Bluetooth message has an information header. If the current frame Bluetooth message has an information header, execute step S704; if the current frame Bluetooth message does not have an information header, execute step S719.

[0073] Step S704: Acquire a handle value from the current frame Bluetooth message or the previous frame Bluetooth message, and determine a second preset buffer corresponding to the handle value.

[0074] In one embodiment of the present application, the WearSDK module establishes a second preset cache corresponding to the handle value according to the handle value in the information header of each frame of Bluetooth message obtained, and the second preset cache can be a structure. If the second preset cache corresponding to the handle value of the current frame Bluetooth message already exists, the second preset cache is directly obtained; if the second preset cache corresponding to the handle value of the current frame Bluetooth message does not exist, the second preset cache corresponding to the handle value of the current frame Bluetooth message is created.

[0075] Step S705, determining whether the previous protocol packet of the current protocol packet in the second preset cache has been assembled. If the previous protocol packet has been assembled, executing step S706, if the previous protocol packet has not been assembled, executing step S708.

[0076] In one embodiment of the present application, the WearSDK module records the assembly status of each protocol package, wherein the assembly status includes the status of reading the length of the protocol package (indicating that the current status is that the WearSDK module is reading the length of the protocol package), the status of reading the data of the protocol package (indicating that the current status is that the WearSDK module is reading the data of the protocol package) and the assembly completion status. If it is determined that the assembly status of the previous protocol package of the current protocol package in the second preset cache is a completed status, it is determined that the assembly of the previous protocol package is completed; if it is determined that the assembly status of the previous protocol package in the second preset cache is not a completed status (such as the status of reading the length of the protocol package, the status of reading the data of the protocol package), it is determined that the previous protocol package is not assembled.

[0077] Step S706, read the data of the current frame Bluetooth message from the first preset cache, and determine whether the data of the Bluetooth message has a protocol header. If it is determined that the data of the Bluetooth message has a protocol header, execute step S707; if it is determined that the data of the Bluetooth message does not have a protocol header, execute step S719. Step S707, store the protocol header in the second preset cache, set the first timer, and clear the second preset cache after the first timer reaches the first preset timing time.

[0078] In an embodiment of the present application, the protocol header is stored in a second preset cache, a first timer is set, and the second preset cache is cleared after the first timer reaches a first preset timing time, so as to prevent the program from staying in the current protocol packet assembly process.

[0079] Step S708, determine whether the packetization state of the previous frame protocol packet is in the state of reading the protocol packet length. If the packetization state of the previous frame protocol packet is in the state of reading the protocol packet length, execute step S709; if the packetization state of the previous frame protocol packet is not in the state of reading the protocol packet length, execute step S711.

[0080] Step S709, read the data of the current frame Bluetooth message from the first preset buffer, and determine whether the data of the current frame Bluetooth message has a protocol packet length. If the protocol packet length exists, execute step S710, if not, execute step S719.

[0081] Step S710: Store the protocol packet length in the data of the current frame Bluetooth message into a second preset buffer.

[0082] Step S711, determining that the packet assembly state of the previous frame protocol packet is in a state of reading protocol packet data.

[0083] In an implementation example of the present application, if it is determined that the packet assembly state of the previous frame protocol packet is in the state of reading protocol packet data, the WearSDK module determines that the length of the data read from the current frame Bluetooth message is less than the protocol packet length.

[0084] Step S712, read the data of the Bluetooth message from the first preset buffer, and determine whether the length of the read data is greater than or equal to the protocol packet length. If the length of the read data is greater than or equal to the protocol packet length, execute step S713; if the length of the read data is less than the protocol packet length, execute step S719.

[0085] Step S713: store the read data into a second preset cache.

[0086] Step S714, determining that the assembly of a protocol packet is completed.

[0087] Step S715, verify the protocol packet according to the preset verification algorithm, and determine whether the verification is passed. If the verification is passed, execute step S716, if the verification is not passed, execute step S719.

[0088] In one embodiment of the present application, the preset check algorithm includes at least one of a cyclic redundancy check algorithm, a parity check algorithm, and a Hamming code check algorithm.

[0089] Step S716, determining whether to group the protocol packet. If the protocol packet is to be grouped, executing step S717, if not, executing step S718.

[0090] In one embodiment of the present application, the WearSDK module parses the protocol header of the protocol packet to obtain a first flag bit. If the value of the first flag bit is a False value, it is determined not to group the protocol packet. If the value of the first flag bit is a True value, it is determined to group the protocol packet.

[0091] Step S717, grouping the protocol packets into a long protocol packet.

[0092] In one embodiment of the present application, the WearSDK module determines the position mark of the protocol packet from the protocol header, and sequentially combines the protocol packet with the position mark as the first packet, the protocol packet with the position mark as the middle packet, and the protocol packet with the position mark as the tail packet to obtain a long protocol packet.

[0093] Step S718, processing the protocol packet or the long protocol packet.

[0094] In one embodiment of the present application, processing a protocol package or a long protocol package includes: the WearSDK module sends the protocol package to a business module (not shown in the figure) in the WearSDK, the business module parses the function instructions from the protocol package, and executes the corresponding function according to the function instructions.

[0095] Step S719: Process the remaining Bluetooth messages in the first preset buffer.

[0096] In the above-mentioned embodiment of the present application, the WearSDK module can read the data of the Bluetooth message stored in the first preset cache, and store the read data in the second preset cache according to the protocol packet structure composed of the protocol header, protocol packet length, and protocol data, and obtain the protocol packet after packaging the stored data.

[0097] refer to Figure 8 FIG. 1 is a flow chart of a method for assembling a protocol package to obtain a long protocol package provided in an embodiment of the present application, which specifically includes the following steps.

[0098] Step S801: read a protocol packet from a first preset buffer.

[0099] Step S802: parse the protocol header of the protocol packet to determine whether to group the protocol packet. If the protocol packet is to be grouped, execute step S803; if not, execute step S804.

[0100] In one embodiment of the present application, the WearSDK module parses the protocol header of the protocol packet to obtain a first flag bit. If the value of the first flag bit is a False value, it is determined not to group the protocol packet. If the value of the first flag bit is a True value, it is determined to group the protocol packet.

[0101] Step S803: Process the protocol packet.

[0102] In one embodiment of the present application, processing the protocol packet includes: the WearSDK module sends the protocol packet to the business module in the WearSDK module, the business module parses the function instructions from the protocol packet (such as the setting instructions corresponding to the sound effect function or the query instructions corresponding to the device information query function), and executes the corresponding function according to the function instructions.

[0103] Step S804: determine the location mark of the protocol packet.

[0104] In one embodiment of the present application, the WearSDK module determines the position mark of the protocol packet from the protocol header. For example, according to the position of the protocol packet in the long protocol packet, the position mark of the protocol packet can be divided into the first packet, the middle packet and the last packet.

[0105] Step S805: If the position mark of the protocol packet is determined to be the first packet, determine whether there is a third preset cache. If there is no third preset cache, execute step S806; if there is a third preset cache, execute step S808.

[0106] Step S806: establishing a third preset cache.

[0107] In the embodiment of the present application, the third preset cache is used to store protocol packets, and the stored protocol packets are grouped to obtain a long protocol packet.

[0108] Step S807, setting a second timer to start timing, and releasing the memory of the third preset cache after the timing time reaches the second preset timing time.

[0109] In the embodiment of the present application, a second timer is set to perform timing, and after the timing time reaches the second preset timing time, the memory of the third preset cache is released to prevent the program from staying in the current long protocol packet assembly process.

[0110] Step S808: clear existing data in the third preset buffer.

[0111] Step S809: reset the second timer to start timing.

[0112] In the embodiment of the present application, the second timer is reset to start a new long protocol packet assembly process.

[0113] Step S810: Store the protocol packet with the position mark as the first packet into the third preset cache.

[0114] Step S811: if it is determined that the position mark of the protocol packet is an intermediate packet, determine whether there is a third preset cache. If there is a third preset cache, execute step S812; if there is no third preset cache, execute step S815.

[0115] Step S812, determine whether the previous protocol packet stored in the third preset cache is the first packet or the middle packet. If the previous protocol packet stored in the third preset cache is the first packet or the middle packet, execute step S813; if the previous protocol packet stored in the third preset cache is not the first packet or the middle packet, execute step S814.

[0116] Step S813: Store the protocol packet whose position is marked as an intermediate packet into the third preset cache.

[0117] Step S814: release the third preset buffer and delete the second timer.

[0118] Step S815: discard the protocol packet.

[0119] Step S816: If it is determined that the position mark of the protocol packet is the tail packet, determine whether there is a third preset cache. If there is a third preset cache, execute step S817; if there is no third preset cache, execute step S822.

[0120] Step S817, determine whether the previous protocol packet stored in the third preset cache is the first packet or the middle packet. If the previous protocol packet stored in the third preset cache is the first packet or the middle packet, execute step S818. If the previous protocol packet stored in the third preset cache is not the first packet or the middle packet, execute step S821.

[0121] Step S818: Store the protocol packet whose position is marked as the tail packet into the third preset cache.

[0122] Step S819, processing the protocol packet.

[0123] The specific implementation content of step S819 refers to the implementation content of step S803, and will not be repeated here.

[0124] Step S820: release the third preset buffer and delete the second timer.

[0125] Step S821: release the third preset buffer and delete the second timer.

[0126] Step S822, discard the protocol packet.

[0127] In the above embodiment, after completing the protocol package, the WearSDK module can determine the position mark of the protocol package, and group the protocol package according to the position mark of the protocol package to obtain a long protocol package, thereby realizing the grouping function of the protocol package.

[0128] The following is an introduction to the terminal devices involved in the embodiments of the present application.

[0129] refer to Fig. 9 , which is a schematic diagram of the hardware structure of a terminal device provided in an embodiment of the present application. The terminal device 100 may include a processor 110, an internal memory 130, an external memory interface 120, a display screen 140, and a sensor module 150. The sensor module 150 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.

[0130] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may include more or fewer components than those shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware. The terminal device 100 may be Figure 2 WearSDK device in.

[0131] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0132] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0133] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0134] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0135] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0136] The terminal device 100 implements the display function through a GPU, a display screen 140, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 140 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.

[0137] The display screen 140 is used to display images, videos, etc. The display screen 140 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the terminal device 100 may include 1 or N display screens 140, where N is a positive integer greater than 1.

[0138] The internal memory 130 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM). The random access memory may include static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM, for example, the fifth generation DDR SDRAM is generally referred to as DDR5 SDRAM), etc. The non-volatile memory may include a disk storage device and a flash memory. Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle; single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc. according to the storage unit potential level; universal flash storage (UFS), embedded multi media card (eMMC), etc. according to the storage specification.

[0139] The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data, etc.

[0140] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 110 .

[0141] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the terminal device 100. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in the external non-volatile memory.

[0142] The internal memory 130 or the external memory interface 120 is used to store one or more computer programs. The one or more computer programs are configured to be executed by the processor 110. The one or more computer programs include multiple instructions. When the multiple instructions are executed by the processor 110, the message packaging method executed on the terminal device 100 in the above embodiment can be implemented to implement the message packaging function of the terminal device 100.

[0143] This embodiment also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement the message packaging method in the above-mentioned embodiment.

[0144] In addition, some embodiments of the present application also provide a device, which may specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor may execute the computer-executable instructions stored in the memory so that the chip executes the message packaging method in the above-mentioned method embodiments.

[0145] Among them, the electronic device, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above and will not be repeated here.

[0146] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0147] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0148] The unit described as a separate component may or may not be physically separated, and the component displayed as a unit may be a physical unit or multiple physical units, that is, it may be located in one place, or it may be distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, each functional unit in each embodiment of the present application may be integrated in a processing unit, or each unit may exist physically separately, or two or more units may be integrated in one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0149] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of some embodiments of the present application are essentially or partly contributed to the prior art or all or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0150] The above implementation modes are only used to illustrate the technical solutions of the present application and are not intended to limit the present application. Although the present application has been described in detail with reference to the above preferred implementation modes, a person skilled in the art should understand that the technical solutions of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.

Claims

1. A message packaging method, applied to a terminal device, characterized in that: The method comprises: Receive Bluetooth messages sent by user equipment; Identifying source information of the Bluetooth message, adding the source information to the Bluetooth message, and storing the Bluetooth message in a first preset cache; Reading the Bluetooth message from the first preset buffer, obtaining data of the Bluetooth message and the source information, and allocating a corresponding second preset buffer according to the source information; The data of the read Bluetooth message is stored in a second preset cache corresponding to the source information according to the protocol packet structure to obtain a corresponding protocol packet.

2. The message packaging method according to claim 1, characterized in that: The method further comprises: If it is determined to group the protocol package, the position mark of the protocol package is determined, and the protocol package is grouped according to the position mark of the protocol package to obtain a long protocol package.

3. The message packaging method according to claim 2, characterized in that: The protocol packet structure includes a protocol header, and the determining to group the protocol packet includes: The protocol header of the protocol packet is parsed to obtain a first flag bit, and if the value of the first flag bit is a preset value, it is determined to group the protocol packet.

4. The message packaging method according to claim 2, characterized in that: The position mark includes a first packet, a middle packet and a tail packet, and the protocol packets are grouped according to the position mark of the protocol packets to obtain a long protocol packet, including: The protocol packet whose position is marked as the first packet, the protocol packet whose position is marked as the middle packet, and the protocol packet whose position is marked as the last packet are sequentially combined to obtain a long protocol packet.

5. The message packaging method according to claim 1, characterized in that: The identifying source information of the Bluetooth message and adding the source information to the Bluetooth message includes: Identify the Bluetooth channel information for sending the Bluetooth message, and mark the Bluetooth channel information as a handle value; Generate an information header of the Bluetooth message based on the handle value and the frame length of the Bluetooth message; The Bluetooth message is updated by inserting the information header into the head position of the Bluetooth message.

6. The message packaging method according to claim 1, characterized in that: If the first preset buffer includes a multi-frame Bluetooth message, the reading the Bluetooth message from the first preset buffer includes: Recording the read information of each frame of Bluetooth message, wherein the read information includes the read data and the unread data of each frame of Bluetooth message; If the read information of the previous frame of Bluetooth message of the current frame of Bluetooth message includes unread data, read the previous frame of Bluetooth message; If the read information of the previous frame of Bluetooth message does not include unread data, read the current frame of Bluetooth message.

7. The message packaging method according to claim 1, characterized in that: The protocol packet structure includes a protocol header, a protocol packet length, and protocol data. The data of the read Bluetooth message is stored in a second preset cache corresponding to the source information according to the protocol packet structure to obtain a corresponding protocol packet, including: Reading the protocol header from the first preset cache, and storing the protocol header in the second preset cache; Reading the protocol packet length from the first preset buffer, and storing the protocol packet length in the second preset buffer; The data of the protocol packet length is read from the first preset buffer, and the data of the protocol packet length is stored in the second preset buffer.

8. The message packaging method according to claim 7, characterized in that: After reading the protocol header from the first preset cache and storing the protocol header in the second preset cache, the method further includes: A first timer is set, and the second preset cache is cleared after the first timer reaches a first preset timing time.

9. The message packaging method according to claim 2, characterized in that: The step of grouping the protocol packets according to the position marks of the protocol packets to obtain a long protocol packet includes: If it is determined that the position mark of the protocol packet is the first packet, determining whether there is a third preset cache; If the third preset cache does not exist, establish the third preset cache, set a second timer to count, and release the memory of the third preset cache after the counted time reaches the second preset counted time; If the third preset cache exists, clear the existing data in the third preset cache and reset the second timer to start timing; The protocol packet with the position mark as the first packet is stored in the third preset cache.

10. The message packaging method according to claim 9, characterized in that: The step of grouping the protocol packets according to the position marks of the protocol packets to obtain a long protocol packet includes: If it is determined that the location mark of the protocol packet is an intermediate packet, determining whether the third preset cache exists; If the third preset cache exists, and the last protocol packet stored in the third preset cache is the first packet or the middle packet, the protocol packet whose position is marked as the middle packet is stored in the third preset cache; If the third preset cache does not exist, the protocol packet is discarded.

11. The message packaging method according to claim 10, characterized in that: The step of grouping the protocol packets according to the position marks of the protocol packets to obtain a long protocol packet includes: If it is determined that the position mark of the protocol packet is a tail packet, determining whether the third preset cache exists; If the third preset cache exists and the previous protocol packet stored in the third preset cache is the first packet or the middle packet, the protocol packet whose position is marked as the tail packet is stored in the third preset cache, the function instruction is parsed from the long protocol packet, and the function instruction is executed, the third preset cache is released, and the second timer is deleted.

12. The message packaging method according to claim 1, characterized in that: The method further comprises: The protocol packet is verified according to a preset verification algorithm.

13. The message packaging method according to claim 1 or 2, characterized in that: The method further comprises: Parse the functional instruction from the protocol packet or the long protocol packet, and execute the functional instruction.

14. A terminal device, characterized in that: The terminal device includes a memory and a processor: The memory is used to store program instructions; The processor is used to read and execute the program instructions stored in the memory. When the program instructions are executed by the processor, the terminal device executes the message packaging method according to any one of claims 1 to 13.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions, and when the program instructions are executed on a terminal device, the terminal device executes the message packaging method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Bluetooth device communication method and device

    CN103561479A

  • Extended data transmission method and extended data transmission system based on Bluetooth low power consumption

    CN104661172A

  • Serial port multiplexing method and electronic device

    CN107347178A

  • Data packet recombination control system and data packet recombination method

    CN114465966A

  • Data transmitting device, data communicating device, and computer readable medium

    US20120218914A1