About Bluetooth adapter in WeChat applet

The previous article is still the old rules. If you have any questions, you can reply in the comment area. Of course, if there is something wrong, you can also raise it and send it to the WeChat api guide link portal: https://mp.weixin.qq.com/debug/wxadoc/dev /api/bluetooth.html don't thank me

 

Let's take a look at the previous process of the Bluetooth adapter (I will not reiterate some of the instructions already mentioned by WeChat. If you don't understand, you can find the corresponding description yourself through the link I gave).

The front is relatively simple, the deviceId inside is obtained through getBluetoothDevices , and each Bluetooth device will return with this value. When the device is successfully connected, call getBLEDeviceServices to get the Bluetooth service, and pay attention to the need to call a companion method

Another problem that must not be involved here is the type of Bluetooth. In a properties object in getBLEDeviceCharacteristics, we see that there are 4 kinds of characteristic information, so you better understand that your Bluetooth is suitable for the kind of back-and-forth value judgment. If you are not sure, you can consult the manufacturer of the Bluetooth device. Since I have low power consumption here, I need to call

to get the information finally through

To monitor and get the changed value of the Bluetooth device, did you find that one of these two supports notify and the other supports read. So here you must know the support of your Bluetooth device. If not, WeChat has another method for me I won't post it here, it's almost the same. Finally, there is one thing not to be missed.

Here's ab2hex, which is used to decrypt the device characteristics returned by Bluetooth. I neglected it when I read the article, and I went to Baidu for a while. The general process is like this.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324938544&siteId=291194637