Accessing Device Characteristics

Last modified by Microchip on 2023/11/09 08:53

The BluetoothGattCharacteristic class provides additional methods to retrieve properties and descriptors.

The Characteristic value in the remote Generic ATTribute Profile Server, or GATT Server, can be read and/or written to, depending on the access property of the characteristic by the GATT Client Android app, using the readCharacteristic() or writeCharacteristic() methods in the BluetoothGatt class.

The Characteristic notification or indication can be enabled or disabled by calling BluetoothGatt.writeDescriptor(), and by setting appropriate notification/indication enable/disable value set for the descriptor using BluetoothGattDescriptor.setValue().

The getValue() and setValue() methods can be used to get or set local values when the Android app is used as a GATT Server to host a Service. Get the stored value for this characteristic.

Update the locally stored value of this characteristic.

The Bluetooth Low Energy Service, or BLEService, provides readCharacteristic() and writeChatracteristic() wrapper methods to perform the read and write access operations on the characteristics.

readCharacteristic() examplewriteChatracteristic() example

The BLEService also provides setCharacteristicNotification() and setChracteristicIndication() wrapper methods to enable or disable the notification or indication for the characteristics.

setCharacteristicNotification() wrapper methodsetChracteristicIndication() wrapper method

The accompanying screenshot shows the PeripheralControlActivity view of the MCHP Transparent UART Android app. This view is used for access operations of the Microchip Transparent UART Service. The view shows the connection status, the send text field to enter data to be sent from the Android app to the BM70/RN4870 BLE module, and the receive text view to show the received data from BM70/RN4870 BLE module to the Android app. Access of the Microchip Transparent UART Service using the MCHP Transparent UART Android app is discussed in the following sections.

PeripheralControlActivity view of the MCHP Transparent UART Android app

Back to Top