Bluetooth Smart Device Data Acquisition Platform Solution | JD Cloud Technical Team

technical background

With the improvement of people's living standards, the awareness of health concerns has also increased; in addition, the aging of the population structure, the increase in the incidence of chronic diseases, and the long-lasting and extensive impact of the new crown epidemic have further improved the public's awareness of early disease prevention and physical data. Regular self-test, continuous attention to chronic diseases and other levels of attention; typical, such as body temperature, blood oxygen, blood pressure, weight and other high-frequency, commonly used self-test parameters, can be independently operated in some medical devices and smart phone APPs Sexuality, real-time monitoring and convenience; wearable medical devices on the market are increasingly diverse and in different shapes. According to different functions, they can be divided into sports and fitness, life and entertainment, health care, remote control, smart switch, Information and multi-functional wearable medical devices.

In terms of technology, in recent years, with the development of wireless communication technology, sensors, flexible electronics, bio-telemetry, body area network and other technologies, wearable medical devices have long been not limited to smart bracelets, smart watches and other forms. China's State Drug Administration Medical-grade wearable devices approved for marketing include ECG signal measurement equipment, blood pressure measurement equipment, blood oxygen measurement equipment, blood glucose measurement equipment; more and more smartphone healthcare applications compatible with wearable devices, medical service providers The preference for wireless connections is becoming more and more obvious. Bluetooth Low Energy (BLE) is widely used in smart wearable terminals due to its low power consumption. Smart watches, smart bracelets, and other smart-related devices almost all rely on this technology to communicate with The mobile phone performs wireless connection and data interaction. In addition, Bluetooth low-power technology can achieve the lowest power consumption for short-distance communication, which also greatly prolongs the working time of wearable devices.

Compared with foreign countries, my country's wearable medical devices are relatively late. The current wearable medical devices on the market are mainly biased towards sports/sleep monitoring functions. They can be in contact with the human body for a long time. They are ideal monitoring devices and have broad market space. With the rapid development of my country's cloud computing, big data and 5G, wearable medical devices must be the general trend, and wearable medical devices will surely usher in good market opportunities.

However, because medical data has the characteristics of product diversification, platform differences, and high data density, it is necessary to effectively store, interact, transmit, and read data across platforms. Wearable medical devices and medical data cloud platforms Connected to achieve data intercommunication and sharing, and process the collected patient data through the cloud platform. Not only can the patients themselves understand the relevant diagnosis results and treatment plans through the cloud platform, but medical institutions can also use the data of the cloud platform to formulate treatment measures. Follow up and communicate with patients.

At present, almost all wearable devices are compatible with three platforms: Android APP, IOS APP, WeChat applet, and their respective synchronization implementation methods (as shown in Figure 1):

1. The Android app is built based on the Android platform JAVA as the development language. Bluetooth device data collection needs to realize the direct command and data interaction between the mobile phone and the peripheral device according to the Native BLE SDK provided by the system; the collected data obtained by the mobile phone needs to use JAVA language to realize the follow-up processing logic; Also need to take into account the 6 steps provided above.

2. The IOS APP is built based on the IOS platform ObjectC as the development language. Bluetooth device data collection needs to implement the 6 steps provided above based on the IOS Bluetooth development specification. The processing flow is the same as that of Android APP

3. The WeChat Mini Program is based on the JavaScript language. For Bluetooth device data collection, it is necessary to provide the Bluetooth API usage specification based on the WeChat applet to implement the 6 steps provided above, and the processing flow is the same as the above two;

Figure 1: Platform data acquisition flow chart

There are the following pain points:

1) The Bluetooth interactive program is built into the user APP

2) To adapt to more development platforms, it is necessary to repeat the above 6 steps, and the code does not have portability and cross-platform capabilities;

3) If there is a need to support new types of Bluetooth devices, only a new version of the APP can be released, prompting the user to upgrade and install. The code of the Bluetooth protocol is packaged in the APP, which is easy to be cracked by static code analysis tools; users need to download a huge APP even if they only use one Bluetooth device.

4) It is difficult to fix bugs (hot fixes), which can only be achieved through version updates (requiring user intervention), and frequent updates affect user experience. Especially for the Android platform, because a large number of enterprise Android systems are customized by themselves, there are also difficulties in compatibility between software systems;

Generally speaking, due to the differences in Android APP/IOS APP platform and development language, for the development end and the user end, there are different degrees of compatibility and adaptation of the system, the installation and update of external Bluetooth, and the transplantation between different platforms. restrict.

Features of the new technology

The bluetooth-based intelligent device data collection platform solution uses the same set of bluetooth device collection codes on the three platforms (Android APP/ IOS APP/WeChat applet), and should have the following characteristics:

1) The Bluetooth interaction and control program is decoupled from the user APP and controlled by the cloud

2) Portability and cross-platform: A bluetooth device synchronization program is developed and debugged on one of the platforms, and runs normally, and it can still run normally when transplanted to other platforms. It supports dynamic addition of new types of bluetooth devices, and immediately take effect. Instead of users frequently uninstalling and installing new versions of APP

3) With the hot repair capability of the Bluetooth function module: a place to repair APP defects quickly and at low cost

4) Solve the static packaging of the Bluetooth protocol in the APP to protect the intellectual property rights of smart device manufacturers

The overall structure of the program

After a lot of research and actual application of various types of Bluetooth device access codes, it was found that after the three platforms access the data read by the Bluetooth device, the subsequent data processing and algorithm logic are the same, but the differences in the Native BLE SDK part are relatively large. big. From this point of view, the Bluetooth synchronization function can be abstracted as: ① the interaction between the mobile phone and the Bluetooth device; ② the subsequent processing of obtaining Bluetooth data.

We introduce the design idea of ​​the middle layer: the main purpose is to shield the differences of the bottom layer and provide a consistent interface for the upper layer; If it is blocked, then the upper layer can focus on solving the business, and no longer need to spend energy to solve the differences.

The Bluetooth synchronization architecture solution has the following three layers (as shown in Figure 2):

Native layer : Native BLE SDK part: directly interacts with Bluetooth devices, different platform implementation methods, different development languages, and different implementation methods. The abstraction is roughly the same as Bluetooth communication capabilities (as shown in Table 1)

Middle layer : used to decouple the strong dependencies between the business layer and the native layer, shielding platform and language differences. Located between the native layer and the business layer, it provides a unified and consistent JS BLE API for the upper layer

Business layer : The processing of Bluetooth data operations can be considered as a business part of the APP function. Different types of Bluetooth devices have different data processing rules. However, the notify data format of the same type of Bluetooth devices on different platforms is the same, so the processing logic is different on different platforms. Shared. After the transformation, the unified business layer is developed using the JavaScript language and runs on the JavaScript engine

Table 1: APIs commonly used to implement Bluetooth (18)



Figure 2: Bluetooth synchronization architecture solution

Portable and cross-platform implementation

According to the object-oriented thinking, the Native BLE SDK part: directly interacts with the Bluetooth device, and the implementation methods of different platforms and development languages ​​may be different; considering that the Native BLE SDK is implemented on three different platforms, the Bluetooth implementation methods are as follows: Solution:

1) Add JavaScript engine to Android APP to realize the mutual calling of Java and JavaScript. And provide support for the Android platform. Through the JavaScript API interface, the native platform JAVA code is used to implement 18 Bluetooth APIs, and JavaScript BLE API is provided to the upper layer

2) Add JavaScriptCore engine to IOS APP. JavaScriptCore is the JavaScript engine of Safari. After iOS7, Apple opened the JavaScriptCore framework. Developers can use JavaScriptCore through the OC interface it provides. Through the JavaScriptCore interface, the native platform ObjectC is used to realize 18 Bluetooth APIs, and JavaScript BLE API is provided to the upper layer

3) WeChat Mini Program runtime environment JavaScript. Just encapsulate WeChat to provide the same JS BLE API as Android/IOS. Only enumerate the Bluetooth initialization process, as shown in Figure 3:

Figure 3 WeChat applet initialization Bluetooth process

Through the above three methods, the business codes of the three platforms can all run in their own JavaScript engines (as shown in Figure 11), and they can exchange commands and data with Bluetooth devices by calling the unified JS BLE API. Just write and debug on any platform, and then run on other platforms without any changes. One code (JavaScript) can be used universally, the content is:

-> Connect to specified device

-> After the connection is successful, send interactive commands

-> Sync and collect device notification data

-> Verify and analyze the Bluetooth data protocol

-> Data conversion business data, business data analysis, cleaning, merging and other processing

-> Data upload to cloud

Bluetooth platform workflow (as shown in Figure 4):

All supported Bluetooth device types and their corresponding Bluetooth synchronization programs are stored in the background server, when the user binds the corresponding type of Bluetooth device. Dynamically obtain the bluetooth device program; re-obtain a new bluetooth synchronization program after detecting that the version of the synchronization program has changed. The process of sending the synchronization program to the APP adopts compression, dynamic encryption, transmission encryption, and multiple verifications of client legitimacy to ensure the security of the Bluetooth protocol.

Figure 4 Bluetooth synchronization data flow

Expected return

Bluetooth-based smart device data acquisition platform solution:

a) Double the access efficiency of Bluetooth devices and high scalability of the platform

b) Clarify personnel responsibilities, data access personnel and APP development can be developed in parallel

c) Only one set of code needs to be maintained for multiple platforms, reducing maintenance costs in the later stages of development and improving program stability

d) The synchronization program is physically isolated between different types of devices. An error in one of them will not affect the normal use of other devices. Each device can freely configure log information, which is convenient for developers to quickly locate and solve problems

e) User perspective to improve user experience. You can access new devices and use new functions without updating the APP frequently

From the perspective of Bluetooth manufacturers: it protects the security of the Bluetooth protocol, its own intellectual property rights and interests;

epilogue

This bluetooth-based smart device data acquisition platform solution only needs a set of javascript code schemes to realize bluetooth synchronization, which is portable and universal; Bluetooth synchronization is strongly coupled with the platform to improve scalability. At the same time, it ensures the APP's ability to quickly adapt to new devices, as well as its hot repair capability. Support the background operation of Bluetooth in the APP, and solve the scenario of large data volume of devices such as ECG stickers;

It helps developers filter out concerns about platform differences and development language differences, and reduces the workload and cost of maintenance in later updates, bug fixes, etc.; in addition, the compatibility and stability of programs between different platforms can be better Improve the user experience; on the basis of reducing the energy investment of the development end and users, it can better help users realize functions and solve problems in different scenarios.

Author: JD Health Yu Zhenjiang

Source: JD Cloud Developer Community

It is infinitely faster than Protocol Buffers. After ten years of open source, Cap'n Proto 1.0 was finally released. The postdoctoral fellow of Huazhong University of Science and Technology reproduced the LK-99 magnetic levitation phenomenon. Loongson Zhongke successfully developed a new generation of processor Loongson 3A6000 miniblink version 108. The world's smallest Chromium core ChromeOS splits the browser and operating system into an independent 1TB solid-state drive on the Tesla China Mall, priced at 2,720 yuan Huawei officially released the security upgrade version of HarmonyOS 4, causing all Electron-based applications to freeze AWS will begin to support IPv4 public network addresses next year Official release of Nim v2.0, an imperative programming language
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4090830/blog/10092369