Accessing the Transparent UART Service using Android™ BLE
In the MCHP Transparent UART Android™ app, after a successful connection has been established Bluetooth® Low Energy (BLE) Services Discovery returns with a BLEService.ACTION_GATT_SERVICES_DISCOVERED event in the PeripheralControlActivity, the returned services list is queried for the Microchip Transparent UART service. If the Microchip Transparent UART service is available, then the notification is enabled for the Microchip Transparent UART TX characteristic, and the BluetoothGattCharacteristic objects for Microchip Transparent UART TX and Microchip Transparent UART RX characteristics are saved for access operation as highlighted in the accompanying screenshot.
Once the app discovers the Microchip Transparent UART service and its characteristics, it can then perform access operations on the characteristics as needed.
The app can send the data to the BM70/RN4870 by performing a BluetoothGatt.writeCharacteristic() through the BLEService.writeCharacteristic() to the Microchip Transparent UART RX characteristic.
The data is received from BM70/RN4870 as a notification event for the Microchip Transparent UART RX characteristic from the BluetoothGattCallback.onCharcateristicChanged() callback through the BLEService broadcast.
In the PeripheralControlActivity view, once the data is entered in the input text field and the Send button is clicked, the entered data is written using BLEService.writeCharacteristic() and transferred over the BLE link and seen on the UART output of the BM70/RN4870 module.
Any data that is entered on the UART input of the BM70/RN4870 module is notified to the Android app. The PeripheralControlActivity view receives a notification callback from the BLEService with the received data. The received data is populated in the receive text view.