Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

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

cross mob
JiWa_1379161
Level 3
Level 3
5 sign-ins 10 replies posted 5 replies posted

I am looking for an example or method to set up a central device to get a notification from a peripheral when a button is pressed. I looked through a variety of examples and non seem to address this application. I can already scan and connect to the peripheral device. Once the peripheral is connected, when the button is pressed it sends a notification with the value "B1". When the button is released, it sends the notification with value of "B0". I know this part works because I can connect the peripheral to an app called Light Blue. I can see the data change every time I press the button. I want to replicate this on the PSOC4-BLE module. Every example I have found is the central device writing to the peripheral, not the other way around. To reiterate, scanning and connecting is not the issue. I need to get the button status from the peripheral to the central device. Any help will be greatly appreciated.

Jim

0 Likes
1 Solution

Hello @JiWa_1379161 ,

In the peripheral device, if you add the notify property to a characteristic then the Client Characteristic Configuration descriptor will be added. The "Client Characteristic Configuration" descriptor contains information about whether notification or indication is enabled or disabled. A client “requests” a server to send indications or notifications by writing value to Client Characteristic Configuration Descriptor.

Please let me know if you are facing any issues.

Thanks,

P Yugandhar. 

View solution in original post

0 Likes
4 Replies
Yugandhar
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 1000 replies posted

Hello @JiWa_1379161 ,

Could you please refer to the Day020_BLE_UART and Day024_Throughput code examples from the GitHub. 

In your central project, check for the Button press continuously and send the write data to the peripheral device. Once the write data is received at the peripheral, then send values(B1 or B0) through notification to the central device.

Please let me know if the above code examples help.

Thanks,
P Yugandhar.

0 Likes
JiWa_1379161
Level 3
Level 3
5 sign-ins 10 replies posted 5 replies posted

I am not following. The button is on the peripheral device. It is a non Cypress device which outputs data when the button is pressed. It would be the same as making any kind of peripheral sensor module and using the Cypress module as the central device to collect the data from the sensor without polling the sensor. Whenever a change in the sensor, it would send a notification to the central device with a new value. In my application, the new data is just a button press or release.

0 Likes
JiWa_1379161
Level 3
Level 3
5 sign-ins 10 replies posted 5 replies posted

Here is a little extra information to help clarify things. I set up my Cypress circuit using the Day 20 BLE-UART as the central device. The peripheral device is a STM BlueNRG-2 board I built. The NRG device is a simple button where I want the central device to know when it is pressed or not. There is a single custom service and characteristic on the NRG device. The characteristic is configured to notify when a change to the characteristic occurs. I can test the NRG using a tablet with the LightBlue app. The board advertises, I connect, I select the service/characteristic and then hit subscribe in the app and I can see the data change with each button press.  What I am trying to do, is replace the tablet/app with the Cypress module.

I loaded the Day 20 example for the central device. I made a couple modifications to scan and select the NRG device by the advertising name. This all works great. The CYpress module finds the NRG board and displays on the terminal it is connected and the LED's on my board indicate the same. The problem is I cant detect any incoming message. I am not sure why. I modified the BLE.c with the proper UUID of the NRG service and characteristic. The handle for the service is 000C and the characteristic is 000D. In the Cypress application it wants to send a enable notification to a descriptor but I dont have that in the NRG nor does it seem I need it since app works. Any suggestions? This shouldnt be this complicated. The Cypress documentation for the example is lacking any explanation. I am open to any assistance.

0 Likes

Hello @JiWa_1379161 ,

In the peripheral device, if you add the notify property to a characteristic then the Client Characteristic Configuration descriptor will be added. The "Client Characteristic Configuration" descriptor contains information about whether notification or indication is enabled or disabled. A client “requests” a server to send indications or notifications by writing value to Client Characteristic Configuration Descriptor.

Please let me know if you are facing any issues.

Thanks,

P Yugandhar. 

0 Likes