How to communicate with Bluetooth devices in Android development

Recently, I have studied how to connect a Bluetooth device to an Android application, for example, how does an Android application connect to a wristband, and how to click a button in the application to modify the settings of the wristband?

The overall development process is roughly:

  1. Search the list of Bluetooth devices
  2. Select the Bluetooth address to connect and wait for the connection to succeed
  3. Search the Services list of Bluetooth devices
  4. Search for the Characteristics of a Service
  5. Subscribe to Characteristics
  6. Receive message/write message

As for how to develop, you need to have a certain foundation of native Android development. How to access it in Unity is similar in essence, that is, to output aar through Android Studio, and then put it into Unity for calling. I have written about this part in our other articles.

I won’t go into details about the code part. You can check the original Android project on github to know the general principle. Or modify the package.

https://github.com/zh2x/SpO2-BLE-for-Android

Guess you like

Origin blog.csdn.net/egostudio/article/details/124644558