cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

New Contributor

Good day

I am writing to ask you for help in carrying out a project using psoc BLE 4, I am relatively new using this microcontroller, however it has interested me and I see it very useful.

My project tries to send data from an ADC through the Bluetooth module of the PSoC 4 Ble. for that I have based on the example of "Simple GAP Peripheral / GATT Server" of digikey, using the CySmart of Psoc, but I can not send the data yet, I used my output variable of the ADC data and I equated it with the variable of the value of "notificationHandle", I understand that they use a structure to assign the values to notify, however I could not read any data, could you please help me?

I attach the file where I have been basing my work, waiting for your reply, thanks!

0 Likes
Reply
1 Solution
Moderator
Moderator

Hello,

In order the enable the notification, we have to write 01:00 value in the client characteristic configuration handle as shown in attached notify.PNG image. In the BLE component configuration, the first value will define the notification enabled or disabled and second value will give information on indications enabled or disabled in that Characteristic handle as shown in attached image.

In order to update the notification enabled value we have to update in the Gatt database using CyBle_GattsWriteAttributeValue() API. Please refer the attached modified project in which I'm updating the notification enabled value in the Gatt db.

Note: CyBle_ProcessEvents() must be called at least once every connection interval or advertisement interval, whichever is smaller, if the device is in GAP Peripheral mode of operation. So it is not recommended to use more delay for processing the events.

Please let me know if you have any questions. I'm glad to assist you.

Thanks,

P Yugandhar.

View solution in original post

0 Likes
Reply
10 Replies
Moderator
Moderator

Hello,

Please refer the attached modified project. The Client Characteristic Configuration handle value val[0] will give information of Notification enabled or disabled.

Thanks,

P Yugandhar.

0 Likes
Reply
New Contributor

Thank you very much for your reply! I observed your modification and used it, but I did not get the value of the output variable of my ADC in my notification when i used the Cysmart, what I did now was to equal the value of my notification enabled with the output of my ADC "temp "But still I can not get that value when I activate the notifications, do you know what could be my mistake?

I attach the file with the modification that I made and the image of the CySmart when I tried to get my adc data value.

0 Likes
Reply
Moderator
Moderator

Hello,

We have to update the ADC value temp to the notification value which we are sending as shown below. 

number_notify=temp;

Thanks,

P Yugandhar.

New Contributor

Hello, I made the necessary corrections and it works now, I had to return to the previous values ​​in the cases, and I hadto increase the delay of sending the data a little more, thank you very much for your help!

0 Likes
Reply
Moderator
Moderator

Hello,

Adding more delay using "CyDelay()" is not recommended to use in infinite loop because we have to call the CyBle_ProcessEvents() function continuously without much delay. We can use WDT timer (with required timeout value) and call the function CyBle_GattsNotification() in it.

Q1. I had to return to the previous values in the cases.

Ans: Please let us know what does this means.

Q2. I had to increase the delay of sending the data a little more.

Ans: Please let us know the delay time required for sending the data.

Thanks,

P Yugandhar.

0 Likes
Reply
New Contributor

Hello

Q1, You said to me: "The Client Characteristic Configuration handle value val [0] will give information of Notification enabled or disabled." I had to return to the original values, that is, to compare them with "CYBLE_NUMBER_NUMBER_NOTIFY_CLIENT_CHARACTERISTIC_CONFIGURATION_DESC_INDEX]" because this way I could not receive any value in the Cysmart

Q2: I went back to the value of the Delay I had before, thanks for the data, I did not know.

Being honest now I'm not sure if what I get in the Cysmart is OK, in the program code, I declared a variable of type int16 named voltaje that I equaled to "number_notify" for get data, however in the Cysmart I only receive a 1 byte number, due to that I entered the configurations of the bluetooth module in the part of the profiles(I attached the image), I changed the data type in the custom descriptor of the notification to uint16 to cover a better data reading value of the adc variable, but I do not see a change in the data I'm reading from the Cymart.

I'm sorry, maybe my questions are a little basic, but really this has been new for me and that's why I've had many doubts, thanks.

0 Likes
Reply
Moderator
Moderator

Hello,

Please refer the modified project in which after enabling the notification I'm sending 2 bytes of voltage value to the client.
In order to increase the data length size we have to declare in custom characteristic handle as shown in attached image.
As I said in order to increase the delay of sending data we can use WDT where we can call the CyBle_GattsNotification() in it. To understand the basic operation of WDT please refer the code examples(Watchdog_PSoC4_Example, WDT_P4_Example projects) in the PSoC Creator.

Please let me know if you have any questions I'm glad to help.


Thanks,
P Yugandhar.

0 Likes
Reply
New Contributor

Thank you very much for your help!

In this case I watched how you sent the 2 bytes, however, do you recommend adding a small delay between the shift of each byte in the array?

Well now I have another small problem, now I do not receive any value from reading my variable in the Cysmart, only the status, before I received the read byte of my variable voltage, now nothing (I attached image), do you think it should be to the delay when receiving the variable? I'm a bit stuck :/.

0 Likes
Reply
Moderator
Moderator

Hello,

In order the enable the notification, we have to write 01:00 value in the client characteristic configuration handle as shown in attached notify.PNG image. In the BLE component configuration, the first value will define the notification enabled or disabled and second value will give information on indications enabled or disabled in that Characteristic handle as shown in attached image.

In order to update the notification enabled value we have to update in the Gatt database using CyBle_GattsWriteAttributeValue() API. Please refer the attached modified project in which I'm updating the notification enabled value in the Gatt db.

Note: CyBle_ProcessEvents() must be called at least once every connection interval or advertisement interval, whichever is smaller, if the device is in GAP Peripheral mode of operation. So it is not recommended to use more delay for processing the events.

Please let me know if you have any questions. I'm glad to assist you.

Thanks,

P Yugandhar.

View solution in original post

0 Likes
Reply
New Contributor

Thank you very much for your help!!, I already get the data! Maybe my mistake was basic, I had read that the Cysmart was demanding with the format in which the data is sent, and I always wrote 00:01, like the example what I supported me, the format changed due to the size of bytes that are being sent now? I'm curious about something else, if I wanted to send more than one type of data, does cysmart accept data of type struct?

0 Likes
Reply