Problems with custom characteristics (PSoc - Android)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello, I have a similar problem. I have a service with two characteristics ( temperature and humidity) and I created an android application to receive data from the characteristics, but I can not get one of them .

   

This is the characteristic that if it works (temperature):

   

cbtemp.setOnClickListener(new View.OnClickListener() { //CheckBox temperature

   

@Override

   

public void onClick(View view) {

   

boolean isChecked = ((CheckBox) view).isChecked();

   

if (isChecked) {

   

  BluetoothGattService mCustomService=mBluetoothLeService.getServices();

   

  BluetoothGattCharacteristic mCustomCharacteristic = mCustomService.getCharacteristic(UUID.fromString("00000002-0000-1000-   8000- 00805f9b34fb"));   //UUID characteristic temperature

   

  final int charaProp = mCustomCharacteristic.getProperties();

   

  if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {

   

    if (mNotifyCharacteristic != null) {

   

      mBluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, false);

   

      mNotifyCharacteristic = null;

   

      }

   

mBluetoothLeService.readCharacteristic(mCustomCharacteristic); }

   

if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {

   

    mNotifyCharacteristic = mCustomCharacteristic;

   

    mBluetoothLeService.setCharacteristicNotification(mCustomCharacteristic, true); }

   

}

   

});

   

where getservices() function is :

   

public BluetoothGattService getServices(){

   

return mBluetoothGatt.getService(UUID.fromString("00000001-0000-1000-8000-00805f9b34fb"));  //UUID Service

   

}

   

For the characteristic humidity I do the same procedure but using the corresponding UUID (00000003-0000-1000-   8000-00805f9b34fb) but by clicking on the checkbox to activate it tells me :

   

java.lang.NullPointerException : Attempt to invoke virtual method ' int android.bluetooth.BluetoothGattCharacteristic.getProperties () ' on a null object reference

   

I'm really lost and not to do more . Thank you

0 Likes
1 Solution
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I checked this on a bluetooth dongle and I can see both the Temp and Humidity items. As I said before your program is working as far as the cypress end of it .  If you are having issue with the Android program I am not going to be of help as this is a Cypress site and you need to have an Android programmer to help you. 

View solution in original post

0 Likes
6 Replies
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable


Here I leave the project:
 

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Jesus here is your project and it is working with two devices.  I don't have your hardware but it s giving two responses in the Gatt data base.  I also am running  PSoC Creator  3.3 SP2 (3.3.0.9604) So it has been updated to that revision.
 

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi , sorry but I do not understand what you mean , the project that has happened to me is configured notifications alert mode with different features that I want. What I know is that I can not access the feature humidity as the temperature . This is my android project .

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received
        I don't understand what you are trying to do? Are you wanting to access your humidity as temperature?   
0 Likes
Anonymous
Not applicable


Hello, I want to access humidity just as I access the temperature to send me notifications. When I access the temperature if I send data from the PSoC ( for now I send keystrokes CapSense as proof ) , but access to humidity gives me the error:

   

java.lang.NullPointerException : Attempt to invoke virtual method ' int android.bluetooth.BluetoothGattCharacteristic.getProperties () ' on a null object reference .

   

Not because I fail if I 'm doing the same in both cases . Not if the descriptor must be enabled to notify . Thank you
 

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I checked this on a bluetooth dongle and I can see both the Temp and Humidity items. As I said before your program is working as far as the cypress end of it .  If you are having issue with the Android program I am not going to be of help as this is a Cypress site and you need to have an Android programmer to help you. 

0 Likes