Accessing operations on the Characteristics

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().

boolean writeDescriptor(BluetoothGattDescriptor descriptor)

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.

readchar.pngwritechar.png

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

notifychar.pngindicatechar.png

The below 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.

controlview.png
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.