BLE Peripheral Client Reading Data from Android Server

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

cross mob
Anonymous
Not applicable

Hello,

   

 

   

I am using a PSoC 4 kit to output current using an IDAC and BLE to communicate with an Android device. I am operating the PSOC BLE as a GAP Peripheral and a GATT Client. I am attempting to use numerical values that are sent from the Android device in my PSoC Code to output varying current levels. 

   

I am wondering how to properly read the incoming data from the Android device. I understand that in order to write it into the Gatt database, I use CyBle_GattsWriteAttributeValue(), but I'm not sure how to read an incoming value from the Gatt Server. Ideally, this function would constantly be reading the value, and would write a new value using CyBle_GattsWriteAttributeValue() whenever that incoming value changes.

   

Let me know if there is any material online that covers this already. I have searched pretty extensively and have mainly seen how to write into the Gatt Database, and not how to read the value from a Client.

   

Thanks,

   

Davis

0 Likes
1 Solution
Anonymous
Not applicable

To read with the client, you have to connect to the device, initiate discovery (either all services and characteristics, or just the ones you are looking for), and then either read or write using the handles associated with the attributes/characteristics that you "discovered".

   

Check out the API documentation include with the BLE component (go to "TopDesign.cysch", right click the BLE component, choose Open_API_Documentation)

   

The functions of interest should be:

   

CyBle_GattcReadCharacteristicValue()

   

CyBle_GattcWriteCharacteristicValue()

   

CyBle_GattsReadAttributeValue()

   

CyBle_GattsNotification()

   

CyBle_GattsIndication()

   

It sounds like what you are wanting, is to call a function on the PSoC device every time the write attribute function is called? Or are you looking to send the data to the android device?

   

Is the android device setup as a client, a server, or both? 

   

Are you sending data from the android device to the PSoC device using CyBle_Gattcwritecharacteristic()? Or are you wanting to send data from the PSoC chip to the android device using CyBle_GattsNotification()?

   

If you could clarify what you are trying to do, that would be helpful.

View solution in original post

0 Likes
9 Replies