Android BLE 101 Capsense notify not working

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello,

I followed the available tutorial and used the PSoC BLE and Android code available at GitHub - cypresssemiconductorco/bleapp.

In the BLE100 app, I'm able to turn on/off the red LED, but the Capsense is not working. When I enable "Notify" the "Capsense value" becomes "No Touch", but the app doesn't show values when I slide the finger in the sensor. However, the Capsense works with the Cysmart app.

The only changes I made were in the PSoCCapSenseLedService.java file, to be able to search for devices and discover services and characteristics.

What can be the problem?

0 Likes
1 Solution
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Hello Jose,

I checked by running the Github Source code and by changing the UUIDs as provided by PSoC Creator. Yes, what you said is true, the LED works, but the Capsense Values aren't getting updated. I checked the code and here is the solution. Change the following function in PSoCCapSenseLedService.java file:

@Override
  public void onCharacteristicChanged(BluetoothGatt gatt,

  BluetoothGattCharacteristic characteristic) {

  String uuid = characteristic.getUuid().toString();

  System.out.println(uuid);

// In this case, the only notification the apps gets is the CapSense value.
  // If the application had additional notifications we could
  // use a switch statement here to operate on each one separately.

if(uuid.equalsIgnoreCase(capsenseCharacteristicUUID)) {
mCapSenseValue = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16,0).toString();
}


  // Notify the main activity that new data is available
  broadcastUpdate(ACTION_DATA_RECEIVED);

  }

So the UUID stored on GATT Database is converted to lower case and the one you provide in the java code if it is in upper case, the .equals() function returns false and hence it doesn't enter the if condition and update the capsense value. Just change .equals() to .equalsIgnoreCase() as highlighted in bold and it will work.

Regards,

Dheeraj

View solution in original post

0 Likes
5 Replies
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello Jose,

                  UUID values of service and characteristics should not be changed. Because this will effect while discovering the services and characteristics in the BLE101 app when device is connected. Please refer the below image where the service and characteristics UUID values are changed in Java file.

pastedImage_0.png

Thanks,

PSYU.

0 Likes
Anonymous
Not applicable

Dear psyu,

I had to change the UUIDs in the Java code for them to be the same values given by PSoC Creator. Before I made the change the app could not discover the services and characteristics.

My problem occurs after the services and characteristics are discovered, since I can write the red LED. The problem is that I cannot receive the Capsense notifications.

0 Likes
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Hello Jose,

I checked by running the Github Source code and by changing the UUIDs as provided by PSoC Creator. Yes, what you said is true, the LED works, but the Capsense Values aren't getting updated. I checked the code and here is the solution. Change the following function in PSoCCapSenseLedService.java file:

@Override
  public void onCharacteristicChanged(BluetoothGatt gatt,

  BluetoothGattCharacteristic characteristic) {

  String uuid = characteristic.getUuid().toString();

  System.out.println(uuid);

// In this case, the only notification the apps gets is the CapSense value.
  // If the application had additional notifications we could
  // use a switch statement here to operate on each one separately.

if(uuid.equalsIgnoreCase(capsenseCharacteristicUUID)) {
mCapSenseValue = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16,0).toString();
}


  // Notify the main activity that new data is available
  broadcastUpdate(ACTION_DATA_RECEIVED);

  }

So the UUID stored on GATT Database is converted to lower case and the one you provide in the java code if it is in upper case, the .equals() function returns false and hence it doesn't enter the if condition and update the capsense value. Just change .equals() to .equalsIgnoreCase() as highlighted in bold and it will work.

Regards,

Dheeraj

0 Likes
Anonymous
Not applicable

Hello Dheeraj,

Thanks for you answer. The app is working now.

I used the UUID in upper case in the Java code because it was the format provided by PSoC Creator. It is good to know that the GATT database converts it to lower case.

Best regards,

José Afonso

0 Likes

Yes, PSoC Creator gives it in an uppercase format, no fault of yours, I understand. The catch is with the format it is stored in the GATT Database, which results in mismatch. Glad to know it is working now.

Regards,

Dheeraj

0 Likes