Özel bir UUID ile bir BLE çevre birimine sahibim ve ona iyi bağlanabiliyorum.BLE özel profili işlemeye çalışırken, alma hatası Alma yayını alma hatası
if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
int flag = characteristic.getProperties();
int format = -1;
if ((flag & 0x01) != 0) {
format = BluetoothGattCharacteristic.FORMAT_UINT16;
Log.d(TAG, "Heart rate format UINT16.");
} else {
format = BluetoothGattCharacteristic.FORMAT_UINT8;
Log.d(TAG, "Heart rate format UINT8.");
}
final int heartRate = characteristic.getIntValue(format, 1);
Log.d(TAG, String.format("Received heart rate: %d", heartRate));
intent.putExtra(EXTRA_DATA, String.valueOf(heartRate));
}
else {
if(characteristic.getValue()!=null){
final int data2 = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT32, 0);
intent.putExtra("Right",String.valueOf(data2));}
}
sendBroadcast(intent);
}
Ama belirtmek istiyorsanız belli bir özelliğin ne yapacağını: Ben kullanarak özel karakteristik okuyabilir
public final static UUID chara = UUID.fromString("custom 128bit UUID");
private void broadcastUpdate(final String action,
final BluetoothGattCharacteristic characteristic) {
final Intent intent = new Intent(action);
if(chara.equals(characteristic.getUuid())){
if(characteristic.getValue()!=null){
final int data2 = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT32, 0);
intent.putExtra("Right",String.valueOf(data2));}
}
sendBroadcast(intent);
}
Ben Neden Olduğu yayın Niyet ..... alma hatası alıyorum: java.lang.NumberFormatException: Geçersiz int: "null"
Lütfen bana neyi yanlış yaptığımı söyler misiniz?
Aynı sorunu yaşıyorum. Herhangi bir çözüm buldunuz mu? – Nithinjith