BLE-based communication method, device, equipment, system and storage medium

文档序号:1893205 发布日期:2021-11-26 浏览:16次 中文

阅读说明:本技术 基于ble的通讯方法、装置、设备、系统以及存储介质 (BLE-based communication method, device, equipment, system and storage medium ) 是由 张心 于 2020-05-20 设计创作,主要内容包括:本公开提供一种基于BLE的通讯方法、装置、设备、系统以及存储介质,所述方法包括:确定对端设备的协议数据单元所支持的最大数据长度的协议数据单元,以使所述对端设备基于所述最大数据长度的协议数据单元对待发送的目标数据进行分包处理,生成一个或多个数据分包;接收所述对端设备发送的所述一个或多个数据分包;基于所述数据分包进行重组得到所述目标数据,并对所述目标数据进行处理。本公开实施例有利于提高数据传输效率。(The present disclosure provides a communication method, device, apparatus, system and storage medium based on BLE, the method comprising: determining a protocol data unit with the maximum data length supported by a protocol data unit of opposite-end equipment, so that the opposite-end equipment performs packet processing on target data to be sent based on the protocol data unit with the maximum data length to generate one or more data packets; receiving the one or more data packets sent by the opposite terminal equipment; and recombining based on the data sub-packets to obtain the target data, and processing the target data. The embodiment of the disclosure is beneficial to improving the data transmission efficiency.)

1. A BLE-based communication method is applied to wearable equipment and comprises the following steps:

determining the maximum data length supported by a protocol data unit of opposite-end equipment, so that the opposite-end equipment performs packet processing on target data to be sent based on the protocol data unit with the maximum data length to generate one or more data packets;

receiving the one or more data packets sent by the opposite terminal equipment;

and recombining based on the data sub-packets to obtain the target data, and processing the target data.

2. The method of claim 1, wherein the determining the maximum data length supported by the pdu of the peer device comprises:

sending a link layer characteristic query request to the opposite terminal equipment;

obtaining a link layer characteristic response returned by the opposite terminal device in response to the link layer characteristic query request; the link layer characteristic is responsive to a maximum data length supported by a protocol data unit describing the peer device.

3. The method according to claim 2, further comprising, after said obtaining a link layer feature response returned by said peer device in response to said link layer feature query request:

if the maximum data length is the first length, sending a data length change request to the opposite terminal equipment; the data length change request is used for triggering the opposite terminal equipment to change the data length applied by the protocol data unit from a second length to the first length; the second length is less than the first length.

4. The method of claim 1, wherein the data packets comprise a control field; the control field is used for describing one or more services which are originally provided by the wearable device;

the processing the target data comprises:

and processing the target data according to the service pointed by the control field.

5. The method according to claim 4, wherein the service pointed to by the control field is determined by the peer device from a pre-stored set of services; the set of services includes all services that the wearable device is capable of providing.

6. The method of claim 4, wherein the control field comprises a transmission status flag field and a target characteristic field;

the transmission state flag field is used for describing the data transmission state of the data sub-package;

the target feature field is used for describing one or more target features corresponding to one or more services which are provided by the wearable device.

7. The method of claim 6, wherein the target feature field comprises an enumerated value that describes the target feature.

8. The method of claim 1, wherein the data packets comprise a sequence field; the sequence field is used for describing the arrangement sequence of the data sub-packets;

the recombining based on the data sub-packets to obtain the target data comprises:

and recombining the data sub-packets based on the arrangement sequence pointed by the sequence field to obtain the target data.

9. A communication device based on BLE, characterized in that, be applied to wearable equipment, include:

a length determining module, configured to determine a protocol data unit with a maximum data length supported by a protocol data unit of an opposite-end device, so that the opposite-end device performs packet processing on target data to be sent based on the protocol data unit with the maximum data length to generate one or more data packets;

a data sub-packet receiving module, configured to receive the one or more data sub-packets sent by the peer device;

and the target data processing module is used for recombining based on the data sub-packets to obtain the target data and processing the target data.

10. The apparatus of claim 9, wherein the length determination module comprises:

the query request sending submodule is used for sending a link layer characteristic query request to the opposite terminal equipment;

a response obtaining submodule, configured to obtain a link layer feature response returned by the peer device in response to the link layer feature query request; the link layer feature is responsive to a protocol data unit describing a maximum data length supported by a protocol data unit of the peer device.

11. The apparatus of claim 10, further comprising, after the response obtaining sub-module:

a change request sending submodule, configured to send a data length change request to the peer device if the maximum data length is a first length; the data length change request is used for triggering the opposite terminal equipment to change the data length applied by the protocol data unit from a second length to the first length; the second length is less than the first length.

12. The apparatus of claim 9, wherein the data packets comprise a control field; the control field is used for describing one or more services to be provided by the wearable device;

the target data processing module includes: and processing the target data according to the service pointed by the control field.

13. The apparatus according to claim 12, wherein the service pointed to by the control field is determined by the peer device from a pre-stored set of services; the set of services includes all services that the wearable device is capable of providing.

14. The apparatus of claim 12, wherein the control field comprises a transmission status flag field and a target characteristic field;

the transmission state flag field is used for describing the data transmission state of the data sub-package;

the target feature field is used for describing one or more target features corresponding to one or more services which are provided by the wearable device.

15. The apparatus of claim 14, wherein the target feature field comprises an enumerated value that describes the target feature.

16. The apparatus of claim 9, wherein the data packets comprise a sequence field;

the sequence field is used for describing the arrangement sequence of the data sub-packets;

the target data processing module further comprises: and recombining the data sub-packets based on the arrangement sequence pointed by the sequence field to obtain the target data.

17. A wearable device, comprising:

a processor;

a memory for storing the processor-executable instructions;

wherein the content of the first and second substances,

the processor, when configured to invoke the executable instructions, performs the method of any of the above claims 1 to 8.

18. A communication system comprising the wearable device of claim 17 and a peer device;

the wearable device is used for determining the maximum data length supported by a protocol data unit of the opposite-end device and feeding back the maximum data length to an application program on the opposite-end device;

the application program on the opposite terminal equipment is used for performing sub-packet processing on target data to be sent based on the protocol data unit with the maximum data length to generate one or more data sub-packets sent to the wearable equipment;

the wearable device is further used for conducting recombination on the basis of the data sub-packets to obtain the target data and processing the target data.

19. A computer-readable storage medium, having stored thereon a computer program which, when executed by one or more processors, causes the processors to perform the method of any one of claims 1 to 8.

Technical Field

The present disclosure relates to the field of bluetooth communication technologies, and in particular, to a communication method, apparatus, device, system and computer-readable storage medium based on BLE.

Background

Wearable equipment (such as wrist-watch, bracelet, armband etc.) often need carry out data transmission at the in-process of carrying out the interaction with corresponding control end (such as cell-phone, flat board etc.), and one of them transmission mode carries out data transmission based on Bluetooth, and Bluetooth Low Energy (BLE) is one of the hottest door's in the wearable technology at present, and Bluetooth Low Energy aims at being used for the emerging application in fields such as medical care, motion body-building, beacon, security protection, family amusement, etc. Bluetooth Low Energy aims at keeping same communication range and simultaneously showing reduction power consumption and cost compared with Bluetooth classic, Bluetooth Low Energy aims at. However, the data transmission through the BLE technology has the problem of low transmission efficiency at present.

Disclosure of Invention

To overcome the problems in the related art, the present disclosure provides a BLE-based communication method, apparatus, device, system, and computer-readable storage medium.

According to a first aspect of the embodiments of the present disclosure, a BLE-based communication method is provided, including:

determining a protocol data unit with the maximum data length supported by a protocol data unit of opposite-end equipment, so that the opposite-end equipment performs packet processing on target data to be sent based on the protocol data unit with the maximum data length to generate one or more data packets;

receiving the one or more data packets sent by the opposite terminal equipment;

and recombining based on the data sub-packets to obtain the target data, and processing the target data.

According to a second aspect of the embodiments of the present disclosure, there is provided a BLE-based communication device applied to a wearable device, including:

a length determining module, configured to determine a protocol data unit with a maximum data length supported by a protocol data unit of an opposite-end device, so that the opposite-end device performs packet processing on target data to be sent based on the protocol data unit with the maximum data length to generate one or more data packets;

a data sub-packet receiving module, configured to receive the one or more data sub-packets sent by the peer device;

and the target data processing module is used for recombining based on the data sub-packets to obtain the target data and processing the target data. According to a third aspect of embodiments of the present disclosure, there is provided a wearable device comprising:

a processor;

a memory for storing processor-executable instructions;

wherein the content of the first and second substances,

the processor is configured to perform the operations of the method as described above when the executable instructions are invoked.

According to a fourth aspect of the embodiments of the present disclosure, a communication system is provided, which includes the wearable device of the third aspect and an opposite-end device;

the wearable device is used for determining the maximum data length supported by a protocol data unit of the opposite-end device and feeding back the maximum data length to an application program on the opposite-end device;

the application program on the opposite terminal equipment is used for performing sub-packet processing on target data to be sent based on the protocol data unit with the maximum data length to generate one or more data sub-packets sent to the wearable equipment;

the wearable device is further used for conducting recombination on the basis of the data sub-packets to obtain the target data and processing the target data.

According to a fifth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program, which, when executed by one or more processors, causes the processors to perform the operations in the method as described above.

The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:

in the disclosure, after establishing a connection with an opposite terminal device, a maximum data length supported by a protocol data unit of the opposite terminal device is determined, so that the opposite terminal device performs packet processing on target data to be sent based on the protocol data unit of the maximum data length to generate one or more data packets, and thus data is encapsulated on the basis of the maximum data length supported by the protocol data unit of the opposite terminal device, which can ensure that the opposite terminal device can transmit as much data as possible each time, and is beneficial to improving transmission efficiency.

In the present disclosure, the maximum data length supported by the protocol data unit of the peer device is queried through the link layer feature query request, so that the peer device encapsulates data based on the maximum data length, which is beneficial to improving data transmission efficiency.

In this disclosure, when it is determined that the maximum data length is the first length, a data length change request may be sent to the peer device, so that the peer device changes the data length applied by the protocol data unit from a second length to the first length, where the second length is smaller than the first length, so that the peer device can encapsulate data based on the maximum data length, which is beneficial to improving data transmission efficiency.

In the present disclosure, the data sub-packets include a control field; the control field is used for describing one or more services to be provided by the wearable device this time, the service pointed by the control field is determined by the opposite terminal device from a pre-stored service set, the service set comprises all services which can be provided by the wearable device, and the process of scanning and discovering the services by the opposite terminal device is not needed, so that the communication efficiency is improved.

In the present disclosure, the control field includes a transmission status flag field and a target feature field; the transmission state flag field is used for describing the data transmission state of the data sub-packets, so that the ordered transmission of the data sub-packets is ensured; the target feature field is used for describing one or more target features corresponding to one or more services which are provided by the wearable device at present, so that the wearable device can be located to the corresponding services through the target features.

In this disclosure, the target feature field includes an enumerated value for describing the target feature, so as to avoid that the target feature occupies too many bytes, which is beneficial to reducing data transmission amount and improving transmission efficiency.

It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.

Fig. 1 is a diagram illustrating a link layer packet structure defined for the bluetooth 4.0/4.1 protocol according to an example embodiment of the present disclosure.

Fig. 2 is a diagram illustrating a link layer packet structure defined for the bluetooth 4.2 protocol according to an example embodiment of the present disclosure.

Figure 3 is a flow chart illustrating a BLE-based communication method according to an exemplary embodiment of the present disclosure.

Figure 4 is a block diagram illustrating a BLE-based communication device according to an exemplary embodiment of the present disclosure.

FIG. 5 is an architectural diagram illustrating an electronic device according to an exemplary embodiment of the present disclosure.

Fig. 6 is a block diagram of a communication system according to an exemplary embodiment of the present disclosure.

Detailed Description

Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.

The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present disclosure. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.

Wearable equipment (such as wrist-watch, bracelet, armband etc.) often need carry out data transmission at the in-process of carrying out the interaction with corresponding control end (such as electronic equipment such as cell-phone, flat board), and one of them transmission mode carries out data transmission based on Bluetooth, and Bluetooth Low Energy (BLE) is one of the hottest technique in the wearable technology at present, and Bluetooth Low Energy aims at being used for the emerging application in fields such as medical care, motion body-building, beacon, security protection, family amusement, compares classic Bluetooth, and Bluetooth Low Energy aims at keeping same communication range simultaneously showing reduction power consumption and cost. The payload of a Protocol Data Unit (PDU) supported by the current BLE technology includes 27 bytes and 251 bytes, but Data transmission is performed by default with 27 bytes, which causes a problem of low Data transmission efficiency.

As an example, referring to fig. 1, a link layer Data packet structure defined by bluetooth 4.0/4.1 Protocol has a Data length of 41 bytes, and there are 1-byte preamble (preamble), 4-byte Access Address (Access Address), 3-byte Cyclic Redundancy Check (CRC) and 33-byte Protocol Data unit (PDU, Protocol Data Uint), where the 33-byte Protocol Data unit includes 2-byte Data Header (Header), 27-byte Payload (Payload), and optionally 4-byte Message Integrity Check (MIC), where the 27-byte Payload (Payload) further includes 3-byte ATT Data Header and 4-byte L2CAP Data Header (not shown in the figure), the maximum transmission unit of the application layer is 20 bytes, that is, when the Payload of the Protocol Data unit (PDU, Protocol Data Uint) is 27 bytes, the application program at the control end can use 20 bytes, causing a problem of low data transmission efficiency.

Referring to fig. 2, the link layer Data packet structure defined for the bluetooth 4.2 Protocol, the bluetooth 4.2 Protocol and the updated version support Data Length Extension function (DLE), the Data Length of which is 265 bytes, and there are 1-byte preamble, 4-byte Access Address (Access Address), 3-byte Cyclic Redundancy Check (CRC) and 257-byte Protocol Data Unit (PDU), the 257-byte Protocol Data unit includes 2-byte Header, 251-byte Payload (Payload) and optionally 4-byte Message Integrity Check (MIC), wherein the 251-byte Payload (Payload) further includes 3-byte ATT Data Header and 4-byte L2CAP Data Header, then the maximum transmission unit (ATT Payload) of the application layer is 244 bytes, that is, when the Payload of the Protocol Data unit (PDU, Protocol Data) is 251, 244 bytes can be used by the application on the control side.

In view of the above problem, embodiments of the present disclosure provide a communication method, an apparatus, a wearable device, a system, and a computer-readable storage medium based on BLE, where before data transmission, the wearable device may determine a maximum data length supported by a protocol data unit of an opposite terminal device, so that the opposite terminal device encapsulates target data to be transmitted based on the protocol data unit with the maximum data length, which is beneficial to improving data transmission efficiency.

Referring to fig. 3, for the communication method based on BLE provided by the embodiment of the present disclosure, the method may be applied to a wearable device, where the wearable device includes but is not limited to a watch, a bracelet, an arm band, or a foot ring, and the wearable device may communicate with an opposite device through BLE bluetooth technology. The method comprises the following steps:

in step S301, the maximum data length supported by the protocol data unit of the peer device is determined, so that the peer device performs packet processing on target data to be transmitted based on the protocol data unit with the maximum data length, and generates one or more data packets.

In step S302, the one or more data packets sent by the peer device are received.

In step S303, the target data is obtained by performing reassembly based on the data packets, and the target data is processed.

In an embodiment, the data length of the protocol data unit of the peer device is information about a link layer, and belongs to system infrastructure information, and considering that an operating system (such as an android system, an IOS system, or the like) of the peer device does not open infrastructure information to an application layer, an application installed on the peer device cannot directly know infrastructure information of a local device, and the BLE4.2 protocol allows a master device (peer device) and a slave device (wearable device) to negotiate the data length during a process of establishing a bluetooth connection with the peer device due to a bluetooth standard protocol. Accordingly, a maximum data length supported by a protocol data unit of a peer device may be determined by the wearable device.

In one implementation, the wearable device may send a link layer feature query request to an operating system of the peer device, where the operating system of the peer device returns a link layer feature response to the wearable device in response to the link layer feature query request, where the link layer feature response is used to describe a maximum data length supported by a protocol data unit of the peer device, so that the wearable device may determine the maximum data length supported by the protocol data unit of the peer device. Then, the wearable device may feed back information about the maximum data length to an application program of the peer device, so that the peer device may encapsulate target data to be sent based on the maximum data length.

Further, if the maximum data length is a first length, the wearable device may send a data length change request to the peer device, where the data length change request is used to trigger the peer device to change the data length applied by the protocol data unit from a second length to the first length; the second length is less than the first length. In this embodiment, by changing the data length applied to the protocol data unit of the peer device, the peer device can transmit data with the maximum data length supported by the peer device, which is beneficial to improving the data transmission efficiency.

In an example, a Data length (payload) of a Protocol Data Unit (PDU) supported by a current BLE technology includes 27 bytes and 251 bytes, and if the determined maximum Data length (maximum payload) is 251 bytes, considering that Data transmission is performed by using 27 bytes by default, the wearable device may send a Data length change request to the peer device, and an operating system of the peer device changes a Data length applied by the Protocol Data unit from 27 bytes to 251 bytes in response to the Data length change request. If the determined maximum data length (maximum payload) is 27 bytes, which indicates that the peer device does not support 251 bytes, 27 bytes are still used for data transmission.

In an exemplary embodiment, after the peer device establishes a connection with the wearable device, the wearable device may determine whether the peer device supports a data length extension function through a new feature (feature request) provided by BLE 4.2: the wearable device may send an LL _ FEATURE _ REQ command to an operating system of the peer device to acquire a bluetooth characteristic of the peer device, where the operating system of the peer device returns an LL _ FEATURE _ RSP response after receiving the LL _ FEATURE _ REQ command, and the wearable device analyzes an LE Data Length Extension flag bit in the LL _ FEATURE _ RSP response, and if the flag bit is 0, it indicates that the default maximum payload amount of the peer device is 27 bytes, and if the flag bit is 1, it indicates that the maximum payload amount supported by the peer device is 251 bytes.

If it is determined that the maximum payload amount supported by the peer device is 27 bytes, the wearable device sends a notification message to an application program on the peer device, where the notification message includes the maximum payload amount supported by the peer device, so that the application program can package target data to be sent based on the maximum payload amount.

If it is determined that the maximum payload amount supported by the peer device is 251 bytes, considering whether the peer device supports 251 bytes or not, the payload amount is usually set to 27 bytes by default, and therefore the wearable device needs to send a change request to an operating system of the peer device: the wearable device needs to send a data length change Request with an operation code of Exchange MTU Request to an operating system of the opposite-end device, the operating system of the opposite-end device adjusts the setting of a protocol data unit based on the data length change Request, and returns a Response message with a Response code of Exchange MTU Response to the wearable device; further, the wearable device needs to send a data LENGTH change request with an operation code of LL _ LENGTH _ REQ to an operating system of the peer device, where the operating system of the peer device adjusts the data LENGTH setting of a link layer based on the data LENGTH change request, and returns a response message with a response code of LL _ LENGTH _ RSP to the wearable device, and thus, the payload capacity of a protocol data unit between the peer device and the wearable device is changed from 27 bytes to 251 bytes; after determining the maximum payload amount supported by the peer device, the wearable device sends a notification message to an application program on the peer device, where the notification message includes the maximum payload amount supported by the peer device, so that the application program can package target data to be sent based on the maximum payload amount, which is beneficial to improving transmission efficiency.

After determining the maximum data length supported by the peer device, the application of the peer device may perform packet processing on target data to be transmitted based on the protocol data unit of the maximum data length, generate one or more data packets, and transmit the one or more data packets to the wearable device.

In consideration of the fact that the wearable device in the related art broadcasts relevant information of services (such as an aerobic heart rate service, a battery power service, an alarm service, and the like) provided by the wearable device, if the peer device wants to use a certain service of the wearable device, the peer device needs to scan and discover the service before using the service provided by the wearable device, and the operation is complex and a large time cost needs to be consumed; based on this, in the embodiment of the present disclosure, a service set is prestored on the peer device, where the service set includes all services that the wearable device can provide; as an implementation manner, the peer device may obtain the service set from a server of the wearable device; the peer device may determine one or more services that the wearable device should provide from the pre-stored set of services, and then encapsulate information related thereto in the data sub-package; as an implementation manner, the data sub-packet includes a control field, where the control field is used to describe one or more services to be provided by the wearable device this time; the embodiment directly encapsulates the information related to the service in the data sub-package, so that the wearable device can determine the service to be provided at this time by reading the control field in the data sub-package, the processes of scanning the end device and discovering the service are not needed, the service scanning time is reduced, and the communication efficiency is favorably improved.

Further, a target feature field is included in the control field, and the target feature field is used for describing one or more target features corresponding to one or more services that are originally provided by the wearable device; it should be understood that, in all data sub-packets corresponding to the target data, the target feature fields are the same to ensure accuracy of data transmission and operability of the target data, so that the wearable device can process the target data based on the service pointed by the target feature without scanning and discovering the service process of the peer device, thereby reducing the time of scanning the service, avoiding tedious work caused by understanding a plurality of target features after the peer device obtains the plurality of target features in the scanning service, and being beneficial to improving the communication efficiency.

Considering that when the wearable device is required to provide multiple services, the target feature field correspondingly includes multiple target features, which may generate a large amount of data, thereby affecting the transmission efficiency of the target data, therefore, an enumerated value may be set for each target feature, and the target feature field may include the enumerated value of the target feature, thereby effectively reducing the amount of data related to the target features that needs to be transmitted, and improving the transmission efficiency of the target data.

In an embodiment, when the data amount of the target data exceeds the maximum data length supported by the protocol data unit, the peer device cannot finish sending the target data at one time, and needs to perform packetization on the target data to generate a plurality of data packets and send the data packets to the wearable device, but thus the wearable device may not determine from which received data packet the target data starts or ends, and thus cannot provide a service to the peer device. Based on this, the control field may further include a transmission status flag field, where the transmission status flag field is used to describe a data transmission status of the data sub-packet, so that the wearable device may be made clear whether to start receiving the target data or whether to finish receiving the target data based on the transmission status flag field. In one example, the data transfer state includes: the data transmission is started, the data transmission is in the process, the data transmission is finished, and the target data only has one data packet, so that the ordered transmission of the data packets is ensured.

In an embodiment, when the data amount of the target data exceeds the maximum data length supported by the protocol data unit, the peer device cannot finish sending the target data at one time, and needs to perform packetization on the target data to generate a plurality of data packets, and send the data packets to the wearable device, based on which, the data packets include a sequence field for describing an arrangement order of the data packets, so that the wearable device can, after receiving the one or more data packets sent by the peer device, reassemble the data packets based on the arrangement order pointed by the sequence field to obtain the target data, and further process the target data based on the service pointed by the control field.

Wherein the target data is used to describe a read operation, a write operation, a change operation, an inquiry operation, or the like of a determined service, and the target data may be specifically determined based on actual conditions, for example, the wearable device provides a battery level service, after a peer device establishes a bluetooth connection with the wearable device, if a user wants to inquire the battery level of the wearable device, an application program of the peer device may generate corresponding target data based on a requirement of the user, and then the application program packetizes the target data based on the protocol data unit with the maximum data length and the service corresponding to the target data, generates one or more data packets including a control field and a sequence field and transmits the data packets to the wearable device, and the wearable device may receive the one or more data packets transmitted by the peer device, and recombining the data sub-packets based on the arrangement sequence pointed by the sequence field to obtain the target data, and further processing the target data based on the service pointed by the control field.

In an embodiment, the peer device may divide the designated byte as the control field and the sequence field based on a maximum data length supported by the protocol data unit, and in an example, the maximum data length (maximum payload) of the protocol data unit is 251 bytes, where a maximum transmission unit of the application layer is 244 bytes: 1 byte can be divided into 244 bytes as a control field, 1 byte is a sequence field, the sequence field can be a number from 0 to 255, which represents the number of the data packet, such as counting from 0 to 255 at maximum, and when exceeding 255, the data packet can be counted from 0 again.

Wherein the control field includes a transmission status flag field, and the transmission status flag field is used to describe the data transmission status of the data packets, so as to ensure the ordered transmission of the data packets, in an example, the control field is 1 byte for an exemplary illustration: 2bits can be divided as the transmission status flag field, and the data transmission status can be, for example, 0 for data transmission start, 1 for data transmission in progress, 2 for data transmission end, and 3 for the target data having only one data packet.

Moreover, the service provided by the wearable device may be embodied by its corresponding target feature, the operation on the service is embodied as an operation process on the target feature, the application program on the peer device may have a service set prestored, the service set includes a correspondence between the service and the target feature, the control field further includes a target feature field, and the target feature field is used to describe one or more target features corresponding to one or more services that the wearable device is to provide at this time; and the target characteristic fields in all the data sub-packets corresponding to the target data are the same to ensure the accuracy of data transmission and the operability of the target data, because one or more services corresponding to the target data are determined.

To further reduce the amount of data transmission, the service set may include a correspondence of a service, a target feature and an enumerated value thereof, and the target feature field may be an enumerated value corresponding to the target feature, in one example, such as the service stores a correspondence of "oxygen heart rate lower limit (service) -org.blue. characteristic _ rate _ lower _ limit (target feature) -0x2A7E (enumerated value)", "age (service) -org.blue. characteristic. age (target feature) -0x2a80 (enumerated value)", and if the oxygen heart rate lower limit service is required to be used, the target feature field may be "0 x2 A7E", in one example, the control field is 1 byte for illustration: 6bits may be divided as the target characteristic field.

It should be noted that, if the data transmission state of the data packet is data transmission end or the target data has only one data packet, the data packet further includes a check field for checking the target data, so as to implement checking of the target field and ensure correctness of data transmission; in one example, the maximum data length (maximum payload) of the protocol data unit is 251 bytes, where the maximum transmission unit of the application layer is 244 bytes: 1 byte may be divided among 244 bytes as a check field.

As an example, the maximum data length (maximum payload) of the protocol data unit is 251 bytes, where the maximum transmission unit of the application layer is 244 bytes: in 244 bytes, 1 byte is used as a control field (2bits is used as a transmission status flag field, 6bits is used as a target characteristic field), 1 byte is used as a sequence field, if the data transmission status of the data packet is data transmission end or the target data has only one data packet, 1 byte is also used as a check field, assuming that the data length of the target data is 1024 bytes, the target characteristic field is 2, and the target data needs to be divided into 5(1024/(244-2) ═ 4.231) data packets:

1 st data subpackage: the transmission status flag field is data transmission start, the target characteristic field is 2, the sequence field is 0, and the remaining 222(224-2) bytes are target data;

and (2) data subpackaging: the transmission status flag field is data transmission, the target characteristic field is 2, the sequence field is 1, and the rest 222(224-2) bytes are target data;

and 3, data subpackaging: the transmission status flag field is in data transmission, the target characteristic field is 2, the sequence field is 2, and the remaining 222(224-2) bytes are target data;

and 4, data subpackaging: the transmission status flag field is data transmission, the target characteristic field is 2, the sequence field is 3, and the rest 222(224-2) bytes are target data;

and 5, data subpackaging: the transmission status flag field is data transmission end, the target characteristic field is 2, the sequence field is 4, 1 byte after the sequence field is a check field (CRC calculated based on 1024 bytes of target data), and the remaining 56(1024 + 242 × 4 ═ 56) bytes are target data.

As another example, assuming that the data length of the target data is 200 bytes and the target feature field is 3, the target data needs to be divided into 1(200/(244-2) ═ 0.826) data packets:

1 st data subpackage: the transmission status flag field is that the target data only has one data packet, the target characteristic field is 3, the sequence field is 0, 1 byte behind the sequence field is a check field (CRC), and the remaining 200 bytes are the target data.

And after receiving the one or more data sub-packets, the wearable device reassembles the data sub-packets based on the sequence field and processes the target data according to the service pointed by the control field.

In an embodiment, if a transmission status flag field in a data packet received by a peer device is data transmission start, the peer device records a target feature field and a sequence field in the data packet, in an example, if the sequence field is set to 0 to 255, if the sequence field in the data packet is not 0, indicating that the data packet is erroneous, the wearable device needs to send a retransmission request to the peer device to request the peer device to retransmit a correct data packet.

In an embodiment, if a transmission status flag field in a data packet received by an opposite terminal device is in data transmission, it is determined whether a target feature field in the data packet is consistent with a target feature field in a data packet in which the transmission status flag field is started for data transmission, if so, it indicates that the data packet is correct, and if not, it indicates that the data packet is incorrect, and the wearable device needs to send a retransmission request to the opposite terminal device to request the opposite terminal device to retransmit the correct data packet.

And the peer device may arrange based on the sequence field in the data sub-packet, and if the serial number of the sequence number field is found to be discontinuous, it is considered that the data is lost, and the wearable device needs to send a retransmission request to the peer device to request the peer device to retransmit the correct data sub-packet.

In an embodiment, if a transmission status flag field in a data sub-packet received by an opposite terminal device is data end, determining whether a target feature field in the data sub-packet is consistent with a target feature field in a data sub-packet with a transmission status flag field as data transmission start, if not, indicating that the data sub-packet is wrong, the wearable device needs to send a retransmission request to the opposite terminal device to request the opposite terminal device to retransmit a correct data sub-packet; if the data packets are consistent, the data packets are correct, then the wearable device compares a check field (CRC) calculated according to the actual length of the received target data with a check field (CRC) in the data packets, and if the data packets are matched with the CRC, the wearable device processes the recombined target data according to the service (namely the characteristic value of the service) pointed by the control field; if not, the data CRC is considered to be abnormal, and the wearable device needs to perform abnormal analysis processing, for example, send a retransmission request to the peer device to request the peer device to retransmit a correct data sub-packet.

In an embodiment, if a transmission status flag field in a data packet received by a peer device is that there is only one data packet for the target data, and a sequence field in the data packet is number 0 (in a case that the sequence field is set to 0 to 255), the peer device compares a check field (CRC) calculated according to an actual length of the received target data with a check field (CRC) in the data packet, and if the check field (CRC) matches the check field (CRC), the wearable device parses the reassembled target data according to a service (i.e., a feature value of the service) pointed by the control field; if not, the data CRC is considered to be abnormal, and the wearable device needs to perform abnormal analysis processing, for example, send a retransmission request to the peer device to request the peer device to retransmit a correct data sub-packet.

Correspondingly, please refer to fig. 4, an embodiment of the present disclosure further provides a communication device based on BLE, which is applied to a wearable device, including:

a length determining module 401, configured to determine a protocol data unit with a maximum data length supported by a protocol data unit of an opposite end device, so that the opposite end device performs packet processing on target data to be sent based on the protocol data unit with the maximum data length, and generates one or more data packets.

A data packet receiving module 402, configured to receive the one or more data packets sent by the peer device.

And a target data processing module 403, configured to recombine based on the data sub-packets to obtain the target data, and process the target data.

Optionally, the length determining module comprises:

and the query request sending submodule is used for sending a link layer characteristic query request to the opposite terminal equipment.

A response obtaining submodule, configured to obtain a link layer feature response returned by the peer device in response to the link layer feature query request; the link layer feature is responsive to a protocol data unit describing a maximum data length supported by a protocol data unit of the peer device.

Optionally, after the response obtaining sub-module, the method further includes: a change request sending submodule, configured to send a data length change request to the peer device if the maximum data length is a first length; the data length change request is used for triggering the opposite terminal equipment to change the data length applied by the protocol data unit from a second length to the first length; the second length is less than the first length.

Optionally, the data packets include a control field; the control field is used for describing one or more services to be provided by the wearable device.

The target data processing module includes: and processing the target data according to the service pointed by the control field.

Optionally, the service pointed to by the control field is determined by the peer device from a pre-stored service set; the set of services includes all services that the wearable device is capable of providing.

Optionally, the control field includes a transmission status flag field and a target characteristic field.

The transmission status flag field is used for describing the data transmission status of the data sub-package.

The target feature field is used for describing one or more target features corresponding to one or more services which are provided by the wearable device.

Optionally, the target feature field includes an enumerated value for describing the target feature.

Optionally, the data sub-packets comprise a sequence field.

The sequence field is used for describing the arrangement sequence of the data sub-packets.

The target data processing module further comprises: and recombining the data sub-packets based on the arrangement sequence pointed by the sequence field to obtain the target data.

The implementation process of the functions and actions of each module in the device is specifically described in the implementation process of the method, and is not described herein again.

The above-described embodiments of the apparatus are merely illustrative, wherein the modules described as separate parts may or may not be physically separate, and the parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed solution. One of ordinary skill in the art can understand and implement it without inventive effort.

Correspondingly, the present disclosure also provides a wearable device, comprising:

a processor;

a memory for storing the processor-executable instructions;

wherein the content of the first and second substances,

the processor is configured to perform the operations of the method as described above when the executable instructions are invoked.

Figure 5 is a schematic structural diagram of a wearable device for BLE-based communication device application according to an example embodiment.

As shown in fig. 5, according to an exemplary embodiment, a wearable device 500 is shown, and the wearable device 500 may be a watch, a bracelet, an arm band, or a control device with bluetooth function such as a ring, a foot ring, etc.

Referring to fig. 5, the wearable device 500 may include one or more of the following components: processing component 501, memory 502, power component 503, multimedia component 504, audio component 505, interface to input/output (I/O) 506, sensor component 507, and communication component 508.

The processing component 501 generally controls the overall operation of the wearable device 500, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 501 may include one or more processors 509 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 501 may include one or more modules that facilitate interaction between the processing component 501 and other components. For example, the processing component 501 may include a multimedia module to facilitate interaction between the multimedia component 504 and the processing component 501.

The memory 502 is configured to store various types of data to support operation at the wearable device 500. Examples of such data include instructions for any application or method operating on wearable device 500, contact data, phone book data, messages, pictures, videos, and so forth. The memory 502 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.

The power supply component 503 provides power to the various components of the wearable device 500. The power components 503 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the wearable device 500.

The multimedia component 504 includes a screen that provides an output interface between the wearable device 500 and the user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 504 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the wearable device 500 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

The audio component 505 is configured to output and/or input audio signals. For example, the audio component 505 includes a Microphone (MIC) configured to receive external audio signals when the wearable device 500 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in the memory 502 or transmitted via the 55 communication component 508. In some embodiments, audio component 505 further comprises a speaker for outputting audio signals.

The I/O interface 506 provides an interface between the processing component 501 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.

The sensor assembly 507 includes one or more sensors for providing various aspects of status assessment for the wearable device 500. For example, the sensor component 507 may detect an open/closed state of the wearable device 500, the relative positioning of components, such as a display and keypad of the wearable device 500, the sensor component 507 may also detect a change in position of the wearable device 500 or a component of the wearable device 500, the presence or absence of user contact with the wearable device 500, orientation or acceleration/deceleration of the wearable device 500, and a change in temperature of the wearable device 500. The sensor assembly 507 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 507 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 507 may further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, a heart rate signal sensor, an electrocardiogram sensor, a fingerprint sensor, or a temperature sensor.

The communication component 508 is configured to facilitate wired or wireless communication between the wearable device 500 and other devices. The wearable device 500 may access a wireless network based on a communication standard, such as WiFi, 3G or 4G, or a combination thereof. In an exemplary embodiment, the communication component 508 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the 55 communication component 508 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, Bluetooth Low Energy (BLE) technology, and other technologies.

In an exemplary embodiment, the wearable device 500 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors, or other electronic components for performing the above-described methods.

In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 502 comprising instructions, executable by the processor 509 of the wearable device 500 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.

Wherein the instructions in the storage medium, when executed by the processor 509, enable the wearable device 500 to perform the aforementioned method.

A computer readable storage medium having stored thereon a computer program which, when executed by one or more processors, causes the processors to perform the above-described method.

Correspondingly, referring to fig. 6, the present disclosure also provides a communication system including the wearable device 500 and the peer device 600.

The wearable device 500 is configured to determine a maximum data length supported by a protocol data unit of the peer device 600 and feed back the maximum data length to an application program on the peer device 600.

The application program on the peer device 600 is configured to perform packet processing on the target data to be sent based on the protocol data unit with the maximum data length, and generate one or more data packets to be sent to the wearable device 500.

The wearable device 500 is further configured to recombine the data sub-packets to obtain the target data, and process the target data.

The implementation process of the system is specifically described in the implementation process of the method, and is not described herein again.

Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

The above description is only exemplary of the present disclosure and should not be taken as limiting the disclosure, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present disclosure should be included in the scope of the present disclosure.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:内存流量控制方法、装置、存储介质及电子设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!