0

I develop a Android app to send data to BLE device. When i connecto to BLE device, i discovered services and characteristics and get this

onGetService() - Device=D8:80:39:F0:03:6E UUID=00001800-0000-1000-8000-00805f9b34fb
onGetService() - Device=D8:80:39:F0:03:6E UUID=0000180a-0000-1000-8000-00805f9b34fb
onGetService() - Device=D8:80:39:F0:03:6E UUID=49535343-fe7d-4ae5-8fa9-9fafd205e455
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a00-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a01-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a04-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a29-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a24-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a25-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a27-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a26-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a28-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a23-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=00002a2a-0000-1000-8000-00805f9b34fb
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=49535343-6daa-4d02-abf6-19569aca69fe
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=49535343-aca3-481c-91ec-d85e28a60318
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=49535343-1e4d-4bd9-ba61-23c647249616
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=49535343-8841-43f4-a8d4-ecbe34729bb3
onGetCharacteristic() - Device=D8:80:39:F0:03:6E UUID=49535343-026e-3a9b-954c-97daef17e26e
onGetDescriptor() - Device=D8:80:39:F0:03:6E UUID=00002902-0000-1000-8000-00805f9b34fb
onGetDescriptor() - Device=D8:80:39:F0:03:6E UUID=00002902-0000-1000-8000-00805f9b34fb
onGetDescriptor() - Device=D8:80:39:F0:03:6E UUID=00002902-0000-1000-8000-00805f9b34fb
onSearchComplete() = Device=D8:80:39:F0:03:6E Status=0

so i think that my device have 3 services and 16 characteristics (each service have diferents characteristics), the problem is when i must send a char, i use this code

 public void writeCustomCharacteristic(int value) {
    if (mBluetoothAdapter == null || mBluetoothGatt == null) {
        Log.w(TAG, "BluetoothAdapter not initialized");
        return;
    }
    /*check if the service is available on the device*/
    BluetoothGattService mCustomService = mBluetoothGatt.getService(UUID.fromString("00001800-0000-1000-8000-00805f9b34fb"));
    if(mCustomService == null){
        Log.w(TAG, "Custom BLE Service not found");
        return;
    }
    /*get the read characteristic from the service*/
    BluetoothGattCharacteristic mWriteCharacteristic = mCustomService.getCharacteristic(UUID.fromString("00002a04-0000-1000-8000-00805f9b34fb"));
    mWriteCharacteristic.setValue(value,android.bluetooth.BluetoothGattCharacteristic.FORMAT_UINT8,0);
    if(mBluetoothGatt.writeCharacteristic(mWriteCharacteristic) == false){
        Log.w(TAG, "Failed to write characteristic");
    }
}

so the question is, what service and characteristic must use? i sopuse that which I have discovered. I want to send a simple char to BLE device and recive from UART-type interface.

  • The spec for the device you mare talking to should specify what characteristic and service to work with. – Ifor Jul 07 '16 at 08:37

1 Answers1

4

I think that you should use the service :

49535343-fe7d-4ae5-8fa9-9fafd205e455

that is used for data exchange with the characteristics :

49535343-8841-43f4-a8d4-ecbe34729bb3

that is used to write data

Aznhar
  • 610
  • 1
  • 10
  • 30