cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 6 MCU

MiRo_263836
Contributor II

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

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

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

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
MiRo_263836
Contributor II

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
MiRo_263836
Contributor II

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
Top labels