My BLE android app can currently connect to my BLE hardware and connect to the GATT server. I can also enable notifications and read the characteristic. However the characteristic advertised is of HEX format. On my Service I tried receiving the data on String or Byte Array format, tried a couple of conversion procedures but still i get nonsensical data (ie. ??x etc)
Any ideas on how to receive/convert the hex data? Service:
private void broadcastUpdate(final String action,
final BluetoothGattCharacteristic characteristic) {
final Intent intent = new Intent(action);
if (UUID_BLE_SHIELD_RX.equals(characteristic.getUuid())) {
//final byte[] rx = characteristic.getValue();
final String rx=characteristic.getStringValue(0);
//final char rx=raw(char.value)
intent.putExtra(EXTRA_DATA, rx);
}
Main Activity:
private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (Service.ACTION_GATT_DISCONNECTED.equals(action)) {
} else if (Service.ACTION_GATT_SERVICES_DISCOVERED
.equals(action)) {
getGattService(mBluetoothLeService.getSupportedGattService());
} else if (Service.ACTION_DATA_AVAILABLE.equals(action)) {
displayData(intent.getExtras().getString(Service.EXTRA_DATA));
}
Data from BLE module as seen in NRF connect: (0x)04-01-19-00-BE