http://my.csdn.net/lidec
background
Since Nordic’s official nrf master control panel only provides apk, many students have to explore Bluetooth reading and writing when they learn. The basic reading and writing methods of the BLE module and some commonly used UUIDs are organized in the project, and some Bluetooth operations are extracted. The process is convenient for the development of Android app code. I hope to help students who are learning BLE Bluetooth.
The previous article summarized the connection of the 51822 BLE Bluetooth module and some knowledge about the Bluetooth protocol. This article will integrate the foregoing content and refer to the official nrf master control panel to realize the search, connection, and related reading and writing of Android phones and Bluetooth modules. .
Project address: https://git.oschina.net/vonchenchen/BLE_Assitant.git
apk download: http://download.csdn.net/detail/lidec/9468739
Process
Activity communicates with Bluetooth service
Monitor the changes of the Bluetooth service and send a broadcast to BLEStatusChangeReceiver after the change
Get the data after Bluetooth changes through the callback function, so that you can flexibly display different types in different places. This is more convenient to imitate the official master's Bluetooth log function, while taking into account the display of data in other controls, enhancing the flexibility of the program.
When Bluetooth writing and reading and writing feature values and descriptor data or other data, corresponding methods need to be provided in BLEControlService, and the underlying implementation needs to call the methods provided in mBluetoothGatt. See the data provided by mBluetoothGatt for specific functions. Here we provide the following example methods
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
When we receive data, we will trigger the method in MyBluetoothGattCallback to get the received data.
Project effect
BLE device list
Data change list
BLE details read and write