PSOC6 BLE - Sending data to app - Notifications not enabled

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

cross mob
MiRo_263836
Level 5
Level 5
100 replies posted 50 likes received 50 replies posted

I used CE218137 - BLE Proximity as an example of sending data to an app.  I am connect and start Nofity and I get data.

I have tried this in my own project and after I set the Notify on the App, I get to the write request but when I check if Notifications are enabled, it says no.  I have the notify box checked in the characteristics of the service. This drops through to Notifications not enabled.

                       /* Check if the ADC service notifications are enabled */

                    adcNotificationEnabled = Cy_BLE_GATTS_IsNotificationEnabled(

                                &connectionHandle,

                                CY_BLE_ADC_DATA_ADC_CHARACTERISTIC_CHAR_HANDLE);

                   

                if ( adcNotificationEnabled)

                {

                    SendBleNotification(CY_BLE_ADC_DATA_ADC_CHARACTERISTIC_CHAR_HANDLE, &ADC_data);

                    ADC_data++;

                     printf("'Send Notificatons value: %d \r\n", sendNotifications);

                }

                else

                {

                    printf("'Notifications not enabled");

                }   

When and where does the Notifications Enabled get set?  Shouldn't it be set when I start Nofity in the CySmart app?

Thanks,

Mike Roberts

0 Likes
1 Solution
VaisakhK_66
Employee
Employee
10 replies posted 5 replies posted First question asked

Hi Mike,

When you enable the notification from the Client App, you will get a GATT Server write request event (CY_BLE_EVT_GATTS_WRITE_REQ).

Upon receiving this event, you need to update the local GATT DB using the Cy_BLE_GATTS_WriteAttributeValuePeer().

For example,

case CY_BLE_EVT_GATTS_WRITE_REQ:

/* Read the write request parameter */

        writeReqParameter = (cy_stc_ble_gatts_write_cmd_req_param_t*)eventParam;

    Cy_BLE_GATTS_WriteAttributeValuePeer(&connectionHandle,&writeRequest->handleValPair);

    /* Send the response to the write request received */

    bleApiResult = Cy_BLE_GATTS_WriteRsp(connectionHandle);

adcNotificationEnabled = Cy_BLE_GATTS_IsNotificationEnabled(&connectionHandle, CY_BLE_ADC_DATA_ADC_CHARACTERISTIC_CHAR_HANDLE);

if ( adcNotificationEnabled)

{

            SendBleNotification(CY_BLE_ADC_DATA_ADC_CHARACTERISTIC_CHAR_HANDLE, &ADC_data);

            ADC_data++;

            printf("'Send Notificatons value: %d \r\n", sendNotifications);

}

else

{

printf("'Notifications not enabled");

}

break;

Let me know if this helps.

Thanks,

Vaisakh

View solution in original post

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

If you have defined a characteristic with notify option checked, the characteristic will have the provision for notifications.  But it will be set whenever you click notify in the Cysmart app. Please share your project and android source code so that we can have a look at what's going wrong.

Regards,
Dheeraj

0 Likes
VaisakhK_66
Employee
Employee
10 replies posted 5 replies posted First question asked

Hi Mike,

When you enable the notification from the Client App, you will get a GATT Server write request event (CY_BLE_EVT_GATTS_WRITE_REQ).

Upon receiving this event, you need to update the local GATT DB using the Cy_BLE_GATTS_WriteAttributeValuePeer().

For example,

case CY_BLE_EVT_GATTS_WRITE_REQ:

/* Read the write request parameter */

        writeReqParameter = (cy_stc_ble_gatts_write_cmd_req_param_t*)eventParam;

    Cy_BLE_GATTS_WriteAttributeValuePeer(&connectionHandle,&writeRequest->handleValPair);

    /* Send the response to the write request received */

    bleApiResult = Cy_BLE_GATTS_WriteRsp(connectionHandle);

adcNotificationEnabled = Cy_BLE_GATTS_IsNotificationEnabled(&connectionHandle, CY_BLE_ADC_DATA_ADC_CHARACTERISTIC_CHAR_HANDLE);

if ( adcNotificationEnabled)

{

            SendBleNotification(CY_BLE_ADC_DATA_ADC_CHARACTERISTIC_CHAR_HANDLE, &ADC_data);

            ADC_data++;

            printf("'Send Notificatons value: %d \r\n", sendNotifications);

}

else

{

printf("'Notifications not enabled");

}

break;

Let me know if this helps.

Thanks,

Vaisakh

0 Likes

I think that is it.  I noticed that in the Proximity example and I didn’t do that in my project. I will try it and let you know.

0 Likes

I finally got back on this project. That didn't work but I think that it is the right track.  I am going copy the exact way that the prox example does it and let you know.

0 Likes