Read an array of ADC readings as a bluetooth characteristic: ANDROID

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.
JeCr_2235141
Level 2
Level 2
10 replies posted 5 replies posted 10 questions asked

Hello,

I have a question regarding PSOC4 BLE data transmission to Android App developed in Android Studio. 

I configure analog pin in PSOC Creator to connect with an ADC converter and then transmit this value to Android App.  For the initial single integer data, this works well, and I receive the data in the Android App and can plot very well.

The bandwidth is a bit low (~100Hz), so I increased the number of samples transmitted with each read request (increasing MTU to 512).  The analog in integer becomes an array, and I run a loop to fill up the array before updating the data transmission.  I have connected with Cypress CYSmart Dongle and I can see my data showing up on the console when I enable notifications.


After enabling notifications in Android, and trying to read the AnalogIn characteristic, the data is always displaying Null.  I try different offsets, but doesnt change.  I have read many forums on this, but I cannot seem to find the issue.

Enabling Bluetooth characteristic Notification in Android (Bluetooth Low Energy ) Not Working - Stac...

http://www.cypress.com/comment/340476

This is code in Android for enabling notifications to BLE.  The CAPSENSE in project still works, and seems to provide some data, however the array only returns null.

public boolean setCharacteristicNotification(BluetoothGattCharacteristic characteristic,boolean enable,BluetoothGattDescriptor descriptor)

{

   mBluetoothGatt.setCharacteristicNotification(characteristic, enable);

  descriptor.setValue(enable ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : new byte[]{0x00, 0x00});

   return mBluetoothGatt.writeDescriptor(descriptor); }//descriptor write operation successfully started?

Thanks for any help you can provide.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hello,

Please find the attached project in which I'm able to send 509 bytes of data continuously when notification was enabled at client side.

The API CyBle_GattcExchangeMtuReq() is used by the GATT Client to send Maximum Transmitted Unit (GATT MTU) supported by the GATT Client. Default GATT MTU size as per Bluetooth 4.1 core specification is 23 bytes. If the GATT Client supports a size greater than the default, it has to invoke this function with the desired GATT MTU size. This function should only be initiated once during a connection.

Please note that for Some of the mobiles( with having Bluetooth version 4.0 or lower) will not send the MTU request to the peripheral devices. So these devices accepts the default MTU size of length 23 bytes only. Can you please check with mobile phones with having Bluetooth v4.1 or higher and also check with Android CySmart App.

Please let me know if this helps.

Thanks,

P Yugandhar.

View solution in original post

0 Likes
10 Replies
This widget could not be displayed.