BLE device adapter system and methods and SDK system based on the system

By using a BLE device adapter system and a cross-platform adaptation system, the incompatibility issues of BLE solutions were resolved, enabling unified development and testing, reducing costs and improving efficiency.

CN123075397APending Publication Date: 2026-11-10ANHUI SHENGYUN INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611567682.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-10
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

The incompatibility issues of existing BLE solutions require application developers to implement a complete set of logic, including scanning and matching, service discovery, command encapsulation, and data parsing, resulting in a large amount of redundant development, long access cycles, inconsistent behavior across multiple devices, and high testing and maintenance costs.

Method used

The design of the BLE device adapter system includes a hardware data interface, an adaptation management module, a data conversion module, and a unified data interface. Through the adaptation protocol mapping rules and the data conversion module, the differences in logic between different BLE solutions are converged into an independent adaptation layer, providing a cross-platform adaptation system and SDK system.

Benefits of technology

It enables unified development and testing of different BLE solutions, reduces application development and maintenance costs, shortens the work cycle, and improves development efficiency and system flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123075397A_ABST
    Figure CN123075397A_ABST
Patent Text Reader

Abstract

This disclosure relates to the field of Bluetooth Low Energy (BLE) communication technology, specifically a BLE device adapter system and a method, SDK system, and computer program product based on the system. The BLE device adapter system is positioned between target hardware and an application program. The system includes: a hardware data interface for acquiring target hardware information, including first BLE chip information; an adaptation management module for matching a BLE adaptation protocol from a preset protocol library based on the first BLE chip information to obtain a target adaptation protocol; a data conversion module for bidirectional conversion between first data and second data according to the target adaptation protocol; and a unified data interface for receiving or sending the second data. The hardware data interface is also used to receive or send the first data. Using this BLE device adapter system, developers no longer need to develop separate programs for different BLE chip manufacturers or even different BLE chip models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of Bluetooth Low Energy communication technology, and in particular to a BLE device adapter system and a method, SDK system and computer program product based on the system. Background Technology

[0002] This section is intended to provide background or context for the embodiments disclosed herein. The description herein is not intended to imply that it is prior art simply because it is included in this section.

[0003] Bluetooth Low Energy (BLE) technology is widely used in terminal hardware such as voice recorders, recording cards, and wearable recording devices for functions such as device control, audio transmission, file management, and OTA upgrades. Currently, recording hardware on the market uses BLE solutions from various manufacturers, each defining its own proprietary GATT service UUIDs, characteristic UUIDs, command encoding formats, data packet rules, verification algorithms, and event reporting mechanisms. This results in completely different command codes, parameter structures, and transmission methods for the same function across different BLE solutions. Even within the same manufacturer, incompatible proprietary BLE solutions may be used for different projects and product models.

[0004] The incompatibility issues of existing BLE solutions mean that application developers (Apps) need to implement a complete set of logic, including scanning and matching, service discovery, instruction encapsulation, data parsing, and timeout retransmission, when connecting to hardware from different manufacturers. This requires preparing a separate set of code for each hardware, resulting in a large amount of redundant development, long integration cycles, inconsistent behavior across multiple devices, and high testing and maintenance costs. Summary of the Invention

[0005] Therefore, it is necessary to address the aforementioned technical problems by providing a BLE device adapter system that can converge the different logic of different BLE schemes into an independent adapter layer, as well as a method, SDK system, and computer program product based on the system.

[0006] In a first aspect, this disclosure provides a BLE device adapter system disposed between target hardware and an application, the system comprising:

[0007] A hardware data interface is used to acquire target hardware information; the target hardware information includes first BLE chip information.

[0008] The adaptation management module is used to match BLE adaptation protocols from a preset protocol library based on the first BLE chip information to obtain a target adaptation protocol. The target adaptation protocol includes mapping rules between the target hardware BLE protocol and the standard BLE protocol. The mapping rules include service UUID mapping rules, feature UUID mapping rules, and mapping rules for the following parameters: MTU parameters, write method, notification method, fragmentation rules, and verification algorithm.

[0009] The data conversion module is used to perform bidirectional conversion between first data and second data according to the target adaptation protocol; the first data conforms to the target hardware BLE protocol, and the second data conforms to the standard BLE protocol;

[0010] A unified data interface is used to receive or send the second data; the hardware data interface is also used to receive or send the first data.

[0011] Optionally, the standard BLE protocol includes a standard frame structure, which includes [magic number 0x5A], [serial number SEQ], [CRC-16 / XMODEM checksum 2 bytes, little endian], [length LEN 2 bytes, little endian], and [data], wherein the data DATA includes TYPE, CMD, and PARAMS.

[0012] Optionally, the target adaptation protocol further includes data transmission timeout and retransmission count, and the bidirectional conversion includes uplink conversion and downlink conversion;

[0013] The uplink conversion includes: verifying, fragmenting, reassembling, and parsing the first data to obtain the event type and data content; and encapsulating the event type and the data content into second data.

[0014] The downlink conversion includes: parsing the second data to obtain a standard instruction code and a parameter field; re-encoding the standard instruction code and the parameter field, then filling in the vendor command header and vendor instruction code, calculating the check value, and generating the first data.

[0015] Optionally, the data conversion module includes multiple data conversion plugins, each of which is used to perform data conversion corresponding to a BLE adaptation protocol in the preset protocol library.

[0016] Optionally, the standard BLE protocol includes the following standard command and semantic correspondence: CMD=1 indicates obtaining device information, CMD=2 indicates obtaining battery level or capacity, CMD=3 indicates recording status event, CMD=4 indicates recording file list, CMD=5 indicates segmented transmission by filename and offset / end, CMD=6 indicates synchronization time, CMD=7 indicates device parameter query, CMD=8 indicates device button event, CMD=9 indicates querying recording status, CMD=10 indicates querying recording duration, CMD=11 indicates... The following parameters are displayed: CMD=12 indicates the current recording file name, CMD=13 indicates the Wi-Fi status, CMD=14 indicates the gain, CMD=15 indicates the deletion of a file or all records, CMD=16 indicates the indicator light, CMD=17 indicates different extended parameters, CMD=18 indicates entering OTA upgrade mode, CMD=19 indicates checking the upgrade environment, CMD=20 indicates sending upgrade metadata, CMD=21 indicates querying upgrade results, CMD=22 indicates querying low-power recording mode, and CMD=23 indicates setting low-power recording mode.

[0017] Secondly, this disclosure also provides a method for using a BLE device adapter system, the method being based on the aforementioned BLE device adapter system to achieve bidirectional conversion between first data and second data.

[0018] Thirdly, this disclosure also provides an SDK system for adapting to BLE devices, including a cross-platform adaptation system and the aforementioned BLE device adapter system;

[0019] The cross-platform adaptation system is connected to the unified data interface and operates based on the standard BLE protocol. The cross-platform adaptation system provides function call entry points and event callbacks to the outside world. The cross-platform adaptation system is an independent logical layer that is platform-independent and vendor-independent.

[0020] Optionally, the cross-platform adaptation system includes a data splitting module and a data distribution module;

[0021] The data splitting module is used to divide the second data into business types to obtain business classification data; the business classification data is divided into device information data, real-time recording frame data and recording file segment data according to business type.

[0022] The data distribution module is also used to map the business classification data to each platform as type-safe callbacks according to business type.

[0023] Optionally, device information, battery capacity, button events, Wi-Fi status, and OTA results are all included in the device information data; the real-time recording frame data is fixed at a 16kHz sampling rate, mono, Opus encoding, and 40 bytes / frame format; the file name, total length, current offset, segment number, and verification information are all included in the recording file segment data.

[0024] Optionally, the cross-platform adaptation system further includes a protocol frame processing module and a request-response management module;

[0025] The protocol frame processing module is used to perform standard frame instruction encoding, CRC check, and fragment reassembly.

[0026] The request and response management module is used to assign a unique sequence number to the platform instructions received through the function call entry, maintain the request queue, establish a mapping relationship between requests and device responses through the unique sequence number, and perform timeout control, exponential backoff retries, and out-of-order deduplication.

[0027] Optionally, the cross-platform adaptation system includes a business state machine engine; the finite state machines built into the business state machine engine include a lifecycle state machine, a recording state machine, a file transfer state machine, a Wi-Fi switching state machine, and an OTA upgrade state machine.

[0028] A lifecycle state machine is used to manage the connection process, and timeouts and fallbacks are set for each stage; the connection process includes disconnection, scanning, connection, service discovery, MTU negotiation, time synchronization, capability reading, and readiness;

[0029] The recording state machine is used to manage the first state transition, which involves states such as idle, recording, paused, or saved. For state changes triggered by device buttons, the recording state machine is also used to ensure that the state change has been confirmed by the upper-layer application through the function call entry point; otherwise, it will not be executed.

[0030] The file transfer state machine is used to manage the file flow, record the received offset, and resume the transmission from the last confirmed offset after the link is interrupted and recovered. The file flow includes list acquisition, interval request, fragment reception, verification merging and completion.

[0031] A Wi-Fi state machine is used to manage second state transitions, the second state transitions involving Wi-Fi states including off, hotspot on, device connected, or connected and ready;

[0032] The OTA state machine is used to manage the upgrade process only when Wi-Fi is ready and the battery level meets the first power threshold. During the upgrade process, it monitors the link status and retains the upgrade context in case of an anomaly. The upgrade process includes entering upgrade mode, environment check, metadata distribution, firmware transmission, and result verification.

[0033] Fourthly, this disclosure also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the aforementioned SDK system.

[0034] The aforementioned BLE device adapter system, along with the method, SDK system, and computer program products based on it, designs a BLE device adapter system between the target hardware and the application application. Leveraging the designed BLE adaptation protocol and the standard BLE protocol, it adapts to the proprietary BLE protocols of different BLE chips, achieving unified data conversion for various proprietary BLE protocols. This allows the different logic of different BLE solutions to be converged at an independent adaptation layer. Therefore, in the development and testing of applications containing BLE solutions, using the BLE device adapter system in this embodiment, developers only need to develop and test code uniformly for the standard BLE protocol, eliminating the need to handle different BLE chip manufacturers or even BLE chip models separately. This helps reduce application development and maintenance costs, workload, and shorten the work cycle. Attached Figure Description

[0035] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.

[0036] Figure 1 This is a block diagram of a BLE device adapter system in one embodiment. Detailed Implementation

[0037] To make the objectives, technical solutions, and advantages of this disclosure clearer, the following detailed description, in conjunction with the accompanying drawings and embodiments, provides a more comprehensive understanding of this disclosure. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this disclosure. In the following detailed description of this application, certain specific details are described in detail. Those skilled in the art can fully understand this application even without these detailed descriptions. To avoid obscuring the essence of this application, well-known methods, processes, flows, elements, and circuits are not described in detail.

[0038] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0039] The BLE device adapter system provided in this disclosure can be applied to various application environments, such as scenarios where a single system is needed to connect BLE devices from different manufacturers, or scenarios where a single system is needed to connect different models of BLE devices from the same manufacturer.

[0040] In one embodiment, such as Figure 1 As shown, a BLE device adapter system is provided, which is set between the target hardware and the application. The system includes a hardware data interface 10, an adapter management module 20, a data conversion module 30, and a unified data interface 40.

[0041] Hardware data interface 10 is used to acquire target hardware information; the target hardware information includes first BLE chip information;

[0042] The adaptation management module 20 is used to match the BLE adaptation protocol from the preset protocol library according to the first BLE chip information to obtain the target adaptation protocol; the target adaptation protocol includes the mapping rules between the target hardware BLE protocol and the standard BLE protocol; the mapping rules include the service UUID mapping rules, the feature UUID mapping rules and the mapping rules of the following parameters: MTU parameters, write method, notification method, fragmentation rules and verification algorithm;

[0043] The data conversion module 30 is used to perform bidirectional conversion between first data and second data according to the target adaptation protocol; the first data conforms to the target hardware BLE protocol, and the second data conforms to the standard BLE protocol;

[0044] A unified data interface 40 is used to receive or send the second data; the hardware data interface is also used to receive or send the first data.

[0045] The target hardware can refer to the hardware device that needs to communicate with the BLE device adapter system of this application via BLE. The preset protocol library can refer to a pre-set database containing various BLE adaptation protocols. The standard BLE protocol is the unified upper-layer service protocol of this disclosure, belonging to the solution-defined service specification, and is different from the BLE underlying protocol defined by the Bluetooth SIG. The standard BLE protocol can refer to custom setting rules including standard frames, CMD (CMD is short for Command), message notification mechanisms, etc., and is called the standard BLE protocol because it undertakes the function of unifying various private BLE protocols. The standard BLE protocol needs to be able to easily adapt to the private BLE protocols of different hardware. The first BLE chip information can refer to information including the manufacturer and model of the BLE chip of the target hardware. The BLE adaptation protocol can refer to the rules for mapping and converting between the hardware's private BLE protocol and the standard BLE protocol. UUID stands for Universally Unique Identifier, which is a standard identifier constructed by software in the prior art. The English name for service UUID is Service UUID. The English name for a characteristic UUID is Characteristic UUID. A service UUID mapping rule refers to the mapping rule between service UUIDs in the standard BLE protocol and service UUIDs in the target hardware BLE protocol. Similarly, a characteristic UUID mapping rule refers to the mapping rule between characteristic UUIDs in the standard BLE protocol and characteristic UUIDs in the target hardware BLE protocol.

[0046] Specifically, the BLE device adapter system is positioned between the target hardware and the application, acting as a Bluetooth middleware layer. Normally, the target hardware communicates directly with the application via its proprietary BLE protocol, the target hardware BLE protocol. In this embodiment, the target hardware communicates indirectly with the application through the BLE device adapter system. The BLE device adapter system includes a hardware data interface and a unified data interface. The hardware data interface is used for communication with the target hardware, while the unified data interface is used for communication with the application or other modules connected to the application. When the BLE device adapter system is working, it can obtain target hardware information, including first BLE chip information, through the hardware data interface. Then, through the adaptation management module, based on the first BLE chip information, it matches the BLE adaptation protocol corresponding to the target hardware BLE chip from a preset protocol library. The matched BLE adaptation protocol is called the target adaptation protocol. The target adaptation protocol needs to be written based on the specific content of the target hardware BLE protocol and the standard BLE protocol. Technical personnel can write it according to the actual situation; this embodiment does not limit the specific content of the target adaptation protocol, as long as it meets the usage requirements. Since each BLE chip has its own proprietary BLE protocol, a BLE adaptation protocol needs to be set for each BLE chip even when the standard BLE protocol is determined. The preset protocol library can include multiple BLE adaptation protocols corresponding one-to-one with each BLE chip. Technicians can adjust the BLE adaptation protocols in the preset protocol library as needed. For example, when adapting to a target hardware equipped with a new model of BLE chip, the corresponding BLE adaptation protocol is added to the preset protocol library. Using the target adaptation protocol, the data conversion module can perform bidirectional conversion between first data and second data. The first data refers to data conforming to the target hardware's BLE protocol and does not distinguish the data transmission direction; it can be data to be sent to the target hardware or data to be sent to the application. The second data refers to data conforming to the standard BLE protocol and does not distinguish the data transmission direction; it can be data to be sent to the target hardware or data to be sent to the application. During the process of the target hardware sending data to the application, or during the data uplink process, the data conversion module converts the first data into the second data. During the process of the application sending data to the target hardware, or in other words, during the downlink data transmission, the data conversion module converts the second data into the first data. MTU (MTU is short for Maximum Transmission Unit, which refers to the maximum data packet size that a network interface can send at one time) parameters, writing methods, notification methods, fragmentation rules, and verification algorithms are all common parameters in BLE communication.Write methods generally include two types: Write With Response and Write No Response. Notification methods generally include Notify and Indicate. Notify indicates a notification method that does not require a response, while Indicate indicates a notification method that requires a response. Fragmentation rules can refer to the packet segmentation and reassembly logic during data transmission and reception. Verification algorithms can refer to algorithms that verify the integrity of data transmission, such as the CRC (Cyclic Redundancy Check) algorithm. By defining the mapping rules in the target adaptation protocol, it is helpful to ensure the standardization of the target adaptation protocol, thereby guaranteeing the data conversion effect.

[0047] In this embodiment, a BLE device adapter system is designed between the target hardware and the application. Leveraging the designed BLE adaptation protocol and the standard BLE protocol, it adapts to the proprietary BLE protocols of different BLE chips, achieving unified data conversion for various proprietary BLE protocols. This allows the different logic of different BLE solutions to be converged within an independent adaptation layer. Therefore, in the development and testing of applications containing BLE solutions, using the BLE device adapter system in this embodiment, developers only need to develop and test code uniformly for the standard BLE protocol, eliminating the need to handle different BLE chip manufacturers or even individual BLE chip models separately. This reduces application development and maintenance costs, decreases workload, and shortens the work cycle.

[0048] In one embodiment, the standard BLE protocol includes a standard frame structure, which includes [magic number] [serial number] [CRC-16 / XMODEM checksum 2 bytes, little-endian] [length LEN 2 bytes, little-endian] [data], wherein the data DATA includes TYPE, CMD and PARAMS.

[0049] The magic number is used to locate the start position of a frame in the data stream; for example, 0x5A can be used. The sequence number can refer to the SEQ (SEQ is short for Sequence) number. CRC-16 / XMODEM is a CRC algorithm in existing technology. "CRC-16 / XMODEM checksum 2 bytes, little-endian" means that the CRC calculation covers the original 2 bytes of LEN plus the entire DATA field, used to detect bit errors during transmission. "Length LEN 2 bytes, little-endian" means that the length of the DATA field following the LEN (LEN is short for Length) record is used to determine the total data length of this frame and define frame boundaries. TYPE indicates the type, CMD indicates the standard command number, and PARAMS indicates the variable parameter field. PARAMS is used to store command-carried parameters, which can be filenames, offsets, battery levels, gain, timestamps, etc. For standard frame data, the receiving end can first locate the frame using the magic number, buffer the complete frame using LEN, and then check the CRC. If the check fails, the frame is discarded and a retry is triggered. SEQ can be used for request-response association, deduplication, and out-of-order detection. LEN can support variable-length parameters and subsequent command extensions. LEN is a variable-length field, and CMD stores unused command numbers. This allows for the direct addition of new service functions (new hardware capabilities, new control commands) to CMDs without altering the overall frame header structure, enabling the protocol to be extended backward. Unknown CMDs directly return errors, preventing program crashes and link disconnections.

[0050] The substructures in the aforementioned standard frame structure are strictly ordered according to the dependencies of the parsing state machine, ensuring that the receiving end can make deterministic decisions at each stage. Key field parameters, such as magic number, checksum algorithm, and end order, are fixed as a protocol contract. Data is further divided into lengths and data, which are expanded according to length and processed in batches according to different content changes. The standard frame designed in this embodiment can serve as a unified business message carrier within the system. It is a standard frame data structure optimized for parsing state machines. It is a logical link design that fully considers data synchronization, semantic judgment, length reliability, header integrity verification, payload transmission, and payload integrity verification. It solves the problems of misalignment, incompleteness, bit errors, and out-of-order duplication in BLE wireless transmission through magic number, length, sequence number, and checksum; it achieves semantic unification of cross-vendor hardware messages through CMD / PARAMS; and it can provide a unified data foundation for fragment reassembly, request and response, breakpoint resumption, event model, and business state machine. Its main advantage lies in its combination of magic number synchronization, version negotiation, type routing, length trust, and header and payload double-layer verification, which helps to solve technical problems such as unreliable synchronization, error length avalanche, poor scalability, and low parsing efficiency, thus helping to provide highly reliable and low-latency communication.

[0051] In one embodiment, the target adaptation protocol further includes a data transmission timeout and a number of retransmissions, and the bidirectional conversion includes uplink conversion and downlink conversion;

[0052] The uplink conversion includes: verifying, fragmenting, reassembling, and parsing the first data to obtain the event type and data content; and encapsulating the event type and the data content into second data.

[0053] The downlink conversion includes: parsing the second data to obtain a standard instruction code and a parameter field; re-encoding the standard instruction code and the parameter field, then filling in the vendor command header and vendor instruction code, calculating the check value, and generating the first data.

[0054] Specifically, steps such as verification, fragment reassembly, parsing, and re-encoding are common practices in data transmission, so specific details will not be elaborated. This embodiment clarifies the specific steps of bidirectional conversion, and based on the aforementioned standard frame structure, by setting verification and retry mechanisms during bidirectional conversion, it helps to improve the reliability of command and audio transmission in weak signal environments.

[0055] In one embodiment, the data conversion module includes multiple data conversion plugins, each of which is used to perform data conversion corresponding to a BLE adaptation protocol in the preset protocol library.

[0056] Specifically, the data conversion module can be designed as a plugin, with a plugin for each BLE adaptation protocol. When data conversion is required based on a certain BLE adaptation protocol, the system can simply load the corresponding plugin, which can significantly improve the system's flexibility and engineering efficiency at the architectural level, and help improve the system's development and maintenance efficiency.

[0057] In one embodiment, the standard BLE protocol includes the following standard command and semantic correspondence: CMD=1 indicates obtaining device information, CMD=2 indicates obtaining battery level or capacity, CMD=3 indicates recording status event, CMD=4 indicates recording file list, CMD=5 indicates segmented transmission by filename and offset / end, CMD=6 indicates synchronization time, CMD=7 indicates device parameter query, CMD=8 indicates device button event, CMD=9 indicates querying recording status, CMD=10 indicates querying recording duration, CMD=1 CMD=1 indicates querying the current recording file name; CMD=12 indicates Wi-Fi status; CMD=13 indicates gain; CMD=14 indicates deleting a file or deleting all; CMD=15 indicates an indicator light; CMD=16 and CMD=17 indicate different extended parameters; CMD=18 indicates entering OTA upgrade mode; CMD=19 indicates checking the upgrade environment; CMD=20 indicates sending upgrade metadata; CMD=21 indicates querying upgrade results; CMD=22 indicates querying low-power recording mode; and CMD=23 indicates setting low-power recording mode. In the aforementioned design, all business interactions are converged into a single set of CMD numbers and parameter formats, facilitating testing, debugging, and problem localization. Decomposing complex business processes into fine-grained atomic instructions helps improve fault tolerance in weak signal environments. Furthermore, unused CMD numbers are retained; subsequent additions of new functions, such as new hardware parameters or new control capabilities, can be directly assigned new CMDs without modifying the overall standard frame structure. This means reserving expansion space and ensuring good forward / backward protocol compatibility. In this embodiment, by clearly defining the instruction rules in the standard BLE protocol, it helps to shield the business differences between different hardware manufacturers and different firmware from the same manufacturer, realize a unified request-response contract, standardize interaction logic, and facilitate state machine-driven business processes. The standardization of parameter semantics helps support the output of unified business events by the event model.

[0058] Based on the same inventive concept, this disclosure also provides a method for using a BLE device adapter system. The solution provided by this method is similar to the implementation described in the above system; therefore, the specific limitations in one or more method embodiments provided below can be found in the limitations of the BLE device adapter system described above, and will not be repeated here.

[0059] In one embodiment, a method for using a BLE device adapter system is provided, the method realizing bidirectional conversion between first data and second data based on the BLE device adapter system described in any of the above embodiments.

[0060] In one embodiment, this disclosure also provides an SDK system for adapting BLE devices, including a cross-platform adaptation system and the BLE device adapter system described in any of the above embodiments;

[0061] The cross-platform adaptation system is connected to the unified data interface and operates based on the standard BLE protocol. The cross-platform adaptation system provides function call entry points and event callbacks to the outside world. The cross-platform adaptation system is an independent logical layer that is platform-independent and vendor-independent.

[0062] SDK stands for Software Development Kit. The function call entry point can refer to the interface exposed by the cross-platform adapted system to the upper-layer application. Event callback is an information feedback mechanism in existing technologies.

[0063] Specifically, function call entry points and event callbacks are two types of API (Application Programming Interface) interaction modes provided by the cross-platform adaptation system to the upper-layer App. Function call entry points are used by the upper-layer App to actively call the SDK system, while event callbacks are used by the SDK system to passively notify the upper-layer App. The cross-platform adaptation system is a platform-independent and vendor-independent independent logical layer. This means that the cross-platform adaptation system is not bound to any hardware-specific BLE protocols, nor to any operating system's Bluetooth APIs, permissions, or background mechanisms. As an independent logical layer, the cross-platform adaptation system only processes standard frames, standard commands, event models, and business state machines internally. All inputs and outputs use standardized data structures, and no vendor parameters or system APIs are hard-coded in the core logic. Adding new hardware or platforms only expands the peripheral adaptation modules without modifying the core business logic. The cross-platform adaptation system and the BLE device adapter system communicate through a unified data interface, forming a complete SDK system. Because the cross-platform adaptation system operates based on the standard BLE protocol, the standard BLE protocol is the universal protocol for the entire SDK system. The cross-platform adaptation system and the BLE device adapter system can interact and collaboratively process data under the same BLE protocol. When the entire SDK system is working, the cross-platform adaptation system can interface with the upper-layer APP to overcome cross-platform differences and achieve unified business semantics and transmission control; the BLE device adapter system can interface with BLE hardware to overcome cross-vendor differences and convert various vendor-specific data into a unified data format.

[0064] In this embodiment, the collaborative work between the cross-platform adaptation system and the BLE device adapter system enables the entire SDK system to be used across platforms and hardware vendors. Developers using the BLE solution can utilize the SDK system in this embodiment, eliminating the need to prepare a separate set of code for each hardware device, significantly reducing software development workload and helping to lower application testing and maintenance costs.

[0065] In one embodiment, the cross-platform adaptation system includes a data splitting module and a data distribution module;

[0066] The data splitting module is used to divide the second data into business types to obtain business classification data; the business classification data is divided into device information data, real-time recording frame data and recording file segment data according to business type.

[0067] The data distribution module is also used to map the business classification data to various platforms as type-safe callbacks.

[0068] Among these, device information data can refer to data related to the parameters and status of the BLE hardware device itself. Real-time recording frame data can refer to the real-time recording data of the BLE hardware device. Recording file fragment data can refer to data related to the transmission and storage of recording files. Type security can refer to different callback interfaces corresponding to different service types of service classification data, avoiding the use of a single general callback to receive all raw bytes.

[0069] Specifically, the service type of the second data can be determined by the specific content of "DATA" in the standard frame. For example, if CMD=5 and PARAMS is the filename in the standard frame of second data A, then the service type of second data A can be determined as recording file fragment data. Second data containing device information, battery capacity, button events, Wi-Fi status, or OTA results is classified as device information data (English name: DEVICE_DATA). Second data containing real-time recording content is classified as real-time recording frame data (English name: RECORD_DATA). Second data containing filename, total length, current offset, fragment number, or checksum information is classified as recording file fragment data (English name: FILE_DATA). The real-time recording frame data is fixed at a 16kHz sampling rate, mono, Opus encoding, and 40 bytes / frame format, a format suitable for the transmission of audio data from most recording devices. The data distribution module maps business-categorized data to type-safe callbacks on each platform according to business type. This means that different business types of data correspond to independent callback interfaces to avoid data type confusion caused by common callbacks. During this process, since the cross-platform adaptation system delivers pre-parsed structured business objects to the upper-layer App, it no longer exposes the original binary BLE messages to the App, thus ensuring that business semantics remain consistent across platforms.

[0070] In one embodiment, the cross-platform adaptation system further includes a protocol frame processing module and a request-response management module;

[0071] The protocol frame processing module is used to perform standard frame instruction encoding, CRC check, and fragment reassembly.

[0072] The request and response management module is used to assign a unique sequence number to the platform instructions received through the function call entry, maintain the request queue, establish a mapping relationship between requests and device responses through the unique sequence number, and perform timeout control, exponential backoff retries, and out-of-order deduplication.

[0073] The standard frame instruction can refer to an instruction that conforms to the standard frame structure.

[0074] Specifically, after the upper-layer App sends platform instructions to the cross-platform adaptation system through the function call entry, the protocol frame processing module encodes the platform instructions into standard frame instructions. It should be noted that the platform instructions are instruction data that has had its platform attributes stripped away. The upper-layer App can set up a platform adaptation layer to process the platform instructions into platform-independent general business parameters before sending them. The protocol frame processing module can also perform CRC checks and fragment reassembly of data during data interaction between the cross-platform adaptation system and the upper-layer App to ensure stable data transmission. A unique sequence number assigned by the request-response management module is written into the SEQ field of the standard frame, i.e., the SEQ number, to mark a request. Maintaining the request queue includes: queuing management when multiple concurrent requests occur; and removing the request from the queue when a response is received, the request times out, or is actively canceled. When the target device responds to a request, it sends a device response. Upon receiving a standard frame based on the device response, the request-response management module extracts the SEQ from the standard frame, searches the local request queue, finds the original request context corresponding to the same SEQ, and delivers the response result to the request, completing request-response matching and establishing a mapping relationship between requests and responses. Timeout control includes setting a timeout timer (e.g., 1 second) for each pending request in the queue. If no response for the corresponding SEQ is received within the timeout period, the request is considered to have failed. Exponential backoff retries include: after a timeout is triggered, retries are executed according to the configured maximum number of retries (e.g., 2 times); the standard frame is resent after a certain period of time using an exponential backoff strategy, and the retry count in the queue is updated simultaneously; if no response is received after reaching the maximum number of retries, the request is removed from the queue, and an error is called back to the upper layer. Out-of-order deduplication processing includes: upon receiving a completed SEQ response message, discarding it directly to avoid duplicate execution of business logic; when the SEQ response message does not match the current processing queue, distinguishing between out-of-order and expired messages, and discarding or buffering them accordingly; and combining the SEQ of standard frames to simultaneously serve selective retransmission logic for real-time audio and file transfers. When the request-response management module and the business state machine engine work together, the business state machine engine can first determine whether the current business state allows the request to be initiated, and only send the request to the request-response management module if it does.

[0075] In this embodiment, the functional modules of the cross-platform adaptation system are further defined, which helps to ensure the stable operation of the cross-platform adaptation system.

[0076] In one embodiment, the cross-platform adaptation system includes a business state machine engine; the finite state machines built into the business state machine engine include a lifecycle state machine, a recording state machine, a file transfer state machine, a Wi-Fi switching state machine, and an OTA upgrade state machine.

[0077] A lifecycle state machine is used to manage the connection process, and timeouts and fallbacks are set for each stage; the connection process includes disconnection, scanning, connection, service discovery, MTU negotiation, time synchronization, capability reading, and readiness;

[0078] The recording state machine is used to manage the first state transition, which involves states such as idle, recording, paused, or saved. For state changes triggered by device buttons, the recording state machine is also used to ensure that the state change has been confirmed by the upper-layer application through the function call entry point; otherwise, it will not be executed.

[0079] The file transfer state machine is used to manage the file flow, record the received offset, and resume the transmission from the last confirmed offset after the link is interrupted and recovered. The file flow includes list acquisition, interval request, fragment reception, verification merging and completion.

[0080] A Wi-Fi state machine is used to manage second state transitions, the second state transitions involving Wi-Fi states including off, hotspot on, device connected, or connected and ready;

[0081] The OTA state machine is used to manage the upgrade process only when Wi-Fi is ready and the battery level meets the first power threshold. During the upgrade process, it monitors the link status and retains the upgrade context in case of an anomaly. The upgrade process includes entering upgrade mode, environment check, metadata distribution, firmware transmission, and result verification.

[0082] The first power threshold can refer to the minimum power threshold at which the target hardware is allowed to enter the OTA (Over The Air) process. Technicians can set a specific value based on the battery capacity of the target hardware, such as 20% or 30%.

[0083] Specifically, there are two input sources that can trigger the business state machine engine: one is the standard instruction assembled by the cross-platform adaptation system after the App calls the aforementioned function call entry point; the other is the business classification data categorized by business type mentioned above. The business state machine engine uses multiple state machines in parallel to manage different businesses, avoiding mutual interference between processes. When the recording state machine is working, it only reports DEVICE_DATA for device button presses (CMD=8) and does not directly trigger a state transition. The recording state machine only performs state transitions after receiving standard control instructions from the function call entry connection module, i.e., the upper-layer App; otherwise, it does not execute them. This prevents direct actions from the hardware device side from causing state synchronization issues between the App and the hardware device.

[0084] In this embodiment, multiple independent sub-business state machines are set up to manage business processes such as device connection, recording, file download, Wi-Fi, and OTA upgrades. Using standard events and commands within the SDK as input and output, and configuring state transition rules, timeout retries, disconnection recovery, and precondition checks, it helps ensure business processes are maintained even in environments with weak signals, disconnections, or packet loss. Because the business state machine engine can isolate vendor and platform differences, unify business timing, and provide the same set of state machine logic for all platforms, it reduces the development complexity of upper-layer apps.

[0085] The cross-platform adaptation system adopts a cross-platform deployment method of pure logic kernel + platform thin encapsulation. The core protocol, state machine and data processing logic can all be compiled into native shared libraries. It can be set to implement only Bluetooth permissions, background keep-alive and file system path on Android, iOS and HarmonyOS platforms, so as to reuse the same set of core layer code.

[0086] In one embodiment, the mobile app and recording card are connected via the SDK system. During operation, the mobile app scans the broadcast name and calls the SDK to connect. The SDK discovers the service, negotiates the MTU, sends CMD=6 to synchronize the phone's time, and then sequentially reads CMD=1, CMD=2, and CMD=9 to obtain the model, battery level, and recording status. When the user clicks start, pause, continue, or save, the SDK sends recording control parameters respectively; when the device presses a button, it reports CMD=8, and the SDK sends a unified event callback to the app. After confirmation, the app sends the corresponding button response. Each request is answered with a SEQ match, and after a 1-second timeout, it retryes twice. If it still fails, the callback link is considered faulty. After the device enters recording mode, it generates 40-byte frames of audio data at 16kHz, mono, and Opus encoding, and sends them in segments via BLE notification. The SDK reassembles the data according to the frame header, length, and sequence number. After verification, it delivers the data via the corresponding interface. When a frame is lost, it only requests the missing sequence number to avoid retransmitting all audio. When an OTA upgrade is required, the SDK sequentially sends commands to open a hotspot, query hotspot connections, and query TCP / IP status. OTA is only permitted upon receiving a CMD=12 status. During the OTA process, CMD=18 indicates entering upgrade mode, CMD=19 indicates checking the environment, and CMD=20 indicates sending version and length metadata. After the device returns that it is ready for upgrade, the firmware is transmitted via Wi-Fi / TCP. The SDK listens for the CMD=21 result and stops the task if the connection is lost.

[0087] Each module of the aforementioned system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0088] In one embodiment, a computer program product is also provided, including a computer program that, when executed by a processor, implements the SDK system of any of the above embodiments.

[0089] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0090] The embodiments described above are merely illustrative of several implementations of this disclosure, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent disclosure. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this disclosure, and these all fall within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the appended claims.

Claims

1. A BLE device adapter system, characterized in that, The system, positioned between the target hardware and the application, includes: A hardware data interface is used to acquire target hardware information; the target hardware information includes first BLE chip information. The adaptation management module is used to match BLE adaptation protocols from a preset protocol library based on the first BLE chip information to obtain a target adaptation protocol. The target adaptation protocol includes mapping rules between the target hardware BLE protocol and the standard BLE protocol. The mapping rules include service UUID mapping rules, feature UUID mapping rules, and mapping rules for the following parameters: MTU parameters, write method, notification method, fragmentation rules, and verification algorithm. The data conversion module is used to perform bidirectional conversion between first data and second data according to the target adaptation protocol; the first data conforms to the target hardware BLE protocol, and the second data conforms to the standard BLE protocol; A unified data interface is used to receive or send the second data; the hardware data interface is also used to receive or send the first data.

2. The system according to claim 1, characterized in that, The standard BLE protocol includes a standard frame structure, which includes [magic number 0x5A], [serial number SEQ], [CRC-16 / XMODEM checksum 2 bytes, little endian], [length LEN 2 bytes, little endian], and [data DATA], where data DATA includes TYPE, CMD, and PARAMS.

3. The system according to claim 2, characterized in that, The target adaptation protocol also includes data transmission timeout and retransmission count, and the bidirectional conversion includes uplink conversion and downlink conversion; The uplink conversion includes: verifying, fragmenting, reassembling, and parsing the first data to obtain the event type and data content; and encapsulating the event type and the data content into second data. The downlink conversion includes: parsing the second data to obtain a standard instruction code and a parameter field; re-encoding the standard instruction code and the parameter field, then filling in the vendor command header and vendor instruction code, calculating the check value, and generating the first data.

4. The system according to claim 1, characterized in that, The data conversion module includes multiple data conversion plugins, each of which is used to perform data conversion corresponding to a BLE adaptation protocol in the preset protocol library.

5. The system according to claim 1, characterized in that, The standard BLE protocol includes the following standard command and semantic correspondence: CMD=1 indicates obtaining device information; CMD=2 indicates obtaining power or capacity; CMD=3 indicates recording status events; CMD=4 indicates a list of recording files; CMD=5 indicates segmented transmission by filename and offset / end; CMD=6 indicates synchronization time; CMD=7 indicates device parameter query; CMD=8 indicates device button events; CMD=9 indicates querying recording status; CMD=10 indicates querying recording duration; CMD=11 indicates querying the current recording filename; CMD=12 indicates Wi-Fi status; CMD=13 indicates gain; CMD=14 indicates deleting a file or deleting all; CMD=15 indicates an indicator light; CMD=16 and CMD=17 indicate different extended parameters; CMD=18 indicates entering OTA upgrade mode; CMD=19 indicates checking the upgrade environment; CMD=20 indicates sending upgrade metadata; CMD=21 indicates querying upgrade results; CMD=22 indicates querying low-power recording mode; CMD=23 indicates setting low-power recording mode.

6. A method of using a BLE device adapter system, characterized in that, The method is based on the BLE device adapter system according to any one of claims 1 to 5 to realize bidirectional conversion between first data and second data.

7. An SDK system adapted for BLE devices, characterized in that, Includes a cross-platform adaptation system and a BLE device adapter system as described in any one of claims 1 to 5; The cross-platform adaptation system is connected to the unified data interface and operates based on the standard BLE protocol. The cross-platform adaptation system provides function call entry points and event callbacks to the outside world. The cross-platform adaptation system is an independent logical layer that is platform-independent and vendor-independent.

8. The SDK system according to claim 7, characterized in that, The cross-platform adaptation system includes a data splitting module and a data distribution module; The data splitting module is used to divide the second data into business types to obtain business classification data; the business classification data is divided into device information data, real-time recording frame data and recording file segment data according to business type. The data distribution module is also used to map the business classification data to each platform as type-safe callbacks according to business type.

9. The SDK system according to claim 8, characterized in that, Device information, battery capacity, button events, Wi-Fi status, and OTA results are all included in the device information data; the real-time recording frame data is fixed at a 16kHz sampling rate, mono, Opus encoding, and 40 bytes / frame format; the file name, total length, current offset, segment number, and verification information are all included in the recording file segment data.

10. The SDK system according to claim 8, characterized in that, The cross-platform adaptation system also includes a protocol frame processing module and a request-response management module; The protocol frame processing module is used to perform standard frame instruction encoding, CRC check, and fragment reassembly. The request and response management module is used to assign a unique sequence number to the platform instructions received through the function call entry, maintain the request queue, establish a mapping relationship between requests and device responses through the unique sequence number, and perform timeout control, exponential backoff retries, and out-of-order deduplication.

11. The SDK system according to claim 10, characterized in that, The cross-platform adaptation system includes a business state machine engine; the finite state machines built into the business state machine engine include a lifecycle state machine, a recording state machine, a file transfer state machine, a Wi-Fi switching state machine, and an OTA upgrade state machine. A lifecycle state machine is used to manage the connection process, and timeouts and rollbacks are set for each stage; The connection process includes disconnection, scanning, connection, service discovery, MTU negotiation, time synchronization, capability reading, and readiness. The recording state machine is used to manage the first state transition, which involves states such as idle, recording, paused, or saved. For state changes triggered by device buttons, the recording state machine is also used to ensure that the state change has been confirmed by the upper-layer application through the function call entry point; otherwise, it will not be executed. The file transfer state machine is used to manage the file flow, record the received offset, and resume the transmission from the last confirmed offset after the link is interrupted and recovered. The file flow includes list acquisition, interval request, fragment reception, verification merging and completion. A Wi-Fi state machine is used to manage second state transitions, the second state transitions involving Wi-Fi states including off, hotspot on, device connected, or connected and ready; The OTA state machine is used to manage the upgrade process only when Wi-Fi is ready and the battery level meets the first power threshold. It monitors the link status during the upgrade process and retains the upgrade context when an exception occurs. The upgrade process includes entering upgrade mode, environment check, metadata distribution, firmware transmission, and result verification.

12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the SDK system as described in any one of claims 7 to 11.