This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Discover Characteristic by UUID

Hi.

I did not still figure out, how i can use this "discover characteristic" method in Android programming as shown in the picture below. I have to use this method to enable the accelerometer in KeyfobDemo project. Did anyone use this method, when programming an application?.

Thanks in advance

  • Hi,

    From the obtained characteristics UUID "0A 21 00 A1 FF" take "21 00" which corresponds to the characteristics value handle 0x0021.
    You can use it to obtain the notification handle value which is the value after it (0x0022).
    Enter the notification handle 0x0022 into the characteristics value handle box  (below in picture) and write value 01:00 (Hex) or 1 (Decimal) and this will enable the notification about any changes (motion change).

    Regarding android programming, you can check the following video "DevBytes: Bluetooth Low Energy API in Android 4.3" :http://www.youtube.com/watch?v=vUbFB1Qypg8., 

    But make sure that your phone supports BLE.

    Regards,

    Asiya

  • Thanks for the reply Asiya

    I just only need to use those functions in Eclipse (Java) as well. I can read the battery profile without any problem in the KeyFobDemo project, but i do not know how i can use the Attribute profile in Android. How do i define the characteristic value handle in Android ?.

  • Hello Osman,



    I'm not expert in Android programming and Java because my phone doesn't fully support BLE, sorry.

    But what command did you send to the keyfob to read the battery profile? I think you need to change the packet of data you did send.

    For example you send to read the battery or characteristics UUID you suppose to send the following command (assuming you did this):

    Dump(Tx):
    01 B4 FD 08 00 00 01 00 FF FF 19 2A

    And to Discover characteristics UUID:
    Dump(Tx):
    01 88 FD 08 00 00 01 00 FF FF 19 2A

    And enable notification char. value handle:
    Dump(Tx):
    01 92 FD 06 00 00 1E 00 01 00

    As long you did success in reading the battery profile, you suppose to read the others by sending different packets (commands) and you suppose to know how many packets are you going to receive in each case to extract the data from them.

    I don't know if this helps. 

    Regards,

    Asiya

     

  • Hi Asiya.

    When i read the barrery profile, i used the

    "BluetoothGatt.readCharacteristic" method in android, and i was able to read the battery level. This method is the same as "Read Characteristic" in BTOOL.

    When i use the same "Read Characteristic" in BTOOL and "BluetoothGatt.readCharacteristic" for the accelerometer profile, the kit returns a "0000000000" value, but when i use the "Discover Characteristic By UUID" method as shown on the picture, it returns some useful values, that i MUST use to get access. So i just want to know, how i can use this method in Android, because i cannot find it. 

  • Hi,

    Sorry I have not tried it in android programming, but I might need to know that in the future.

    Regards

  • Hi Osman,

    I am trying to read the batter profile as well, using the Android readCharacteristics method, but it is showing null. Here is the code I am using:

    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
                                // If there is an active notification on a characteristic, clear
                                // it first so it doesn't update the data field on the user interface.
                                if (mNotifyCharacteristic != null) {
                                    mBluetoothLeService.setCharacteristicNotification(
                                            mNotifyCharacteristic, false);
                                    mNotifyCharacteristic = null;
                                }
                                
                                //mBluetoothLeService.readCharacteristic(characteristic);
                                //boolean status = mBluetoothLeService.readCharacteristic(characteristic);
                                
                                characteristic.setWriteType(BluetoothGattCharacteristic.PERMISSION_READ);
                                if(!mBluetoothLeService.readCharacteristic(characteristic))
                                { 
                                    Log.w(TAG, "Couldn't read characteristic");
                                }else{
                                    Log.w(TAG, "read characteristic ok"+characteristic.getValue());
                                }
                                //showDialog("read value:"+byteValue);
                                Toast.makeText(getApplicationContext(), "Reading Charactaristic: "+characteristic.getUuid(), Toast.LENGTH_LONG).show();
                            }

    I am not sure why it is going wrong. Could you please help me or share those particular lines of your code?

    Thanks in advance.