Heart Rate BLE Server Get Characteristic descriptor problem

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

cross mob
michalzoldak
Level 1
Level 1
10 sign-ins 5 replies posted 5 sign-ins

Hello everyone, I am trying to send heart rate measurements from MAX30101 sensor to CySmart app using psoc-062 ble pioneer kit. I am using CE217639 code example. I managed to connect with mobile and enable notifications:

michalzoldak_0-1628519997541.png

Terminal output:

michalzoldak_1-1628520016891.png

Notifications are enabled when Heart Rate measurement tab is opened in an app.

After that programm is simulating HeartRate and sending notification with: HrssSendHeartRateNtf(connhandle) function.

In which following statement (cccd == CY_BLE_CCCD_NOTIFICATION) is never true and measurements cannot be send via BLE:

michalzoldak_2-1628520276872.png

cccd = 0 every time.

I also tried with sending just sensor location changing Cy_BLE_HRS_HRM to Cy_BLE_HRS_BSL, but that also didn't help.
Am I missing something in configuration of ble connection?

I would appreciate any kind of help. Example is working fine

Michal

 

0 Likes
1 Solution

Hello,


CY_BLE_ERROR_INVALID_PARAMETER will occurs due to invalid input parameter. Inside the Cy_BLE_HRSS_SendNotification function, if charIndex >= CY_BLE_HRS_CHAR_COUNT then it will send CY_BLE_ERROR_INVALID_PARAMETER error as shown below. For Cy_BLE_GATTS_Notification api, if the parameter 'ntfReqParam' is NULL, 'connHandle' is invalid or if 'ntfReqParam->handleValPair.value.len' value is greater than (Effective GATT MTU-3) then CY_BLE_ERROR_INVALID_PARAMETER error will occurs.

Please check the 'CE217639_BLE_Heart_Rate_Server' code example from the PSoC Creator for reference.

******************************************************************************************************
cy_en_ble_api_result_t Cy_BLE_HRSS_SendNotification(cy_stc_ble_conn_handle_t connHandle,
cy_en_ble_hrs_char_index_t charIndex,
uint8_t attrSize,
uint8_t *attrValue)
{
cy_en_ble_api_result_t apiResult;

/* Send Notification if it is enabled and connected */
if(Cy_BLE_GetConnectionState(connHandle) < CY_BLE_CONN_STATE_CONNECTED)
{
apiResult = CY_BLE_ERROR_INVALID_STATE;
}
else if(charIndex >= CY_BLE_HRS_CHAR_COUNT)
{
apiResult = CY_BLE_ERROR_INVALID_PARAMETER;
}
else if((cy_ble_hrsConfigPtr->hrss->hrmCccdHandle == CY_BLE_GATT_INVALID_ATTR_HANDLE_VALUE)
|| (!CY_BLE_IS_NOTIFICATION_ENABLED(connHandle.attId, cy_ble_hrsConfigPtr->hrss->hrmCccdHandle)))
{
apiResult = CY_BLE_ERROR_NTF_DISABLED;
}
else
{
/* Fill all fields of write request structure ... */
cy_stc_ble_gatts_handle_value_ntf_t ntfReqParam =
{
.handleValPair.attrHandle = cy_ble_hrsConfigPtr->hrss->charHandle[charIndex],
.handleValPair.value.val = attrValue,
.handleValPair.value.len = attrSize,
.connHandle = connHandle
};
/* Send notification to client using previously filled structure */
apiResult = Cy_BLE_GATTS_Notification(&ntfReqParam);
}

return(apiResult);
}
******************************************************************************************************

Thanks,
P Yugandhar.

View solution in original post

0 Likes
4 Replies
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello, 

At my end, I'm able to see the cccd value enabled. 

Could you please share your project so that we can check ?

Thanks,

P Yugandhar.

0 Likes
lock attach
Attachments are accessible only for community members.

CySmart application response is:

michalzoldak_0-1628806687704.png

 

Does it mean client haven't received response, or received some unexpected event after enabling notifications?

0 Likes

The problem was with Uart Debug. I changed debug function to DBG_PRINTF function and communication now works properly.

However when I want to send measurements error occurs:

michalzoldak_0-1629728633451.png

For now I am trying to send value = 60.

michalzoldak_1-1629728740644.png

The notification function:

michalzoldak_2-1629730454457.pngmichalzoldak_3-1629730489528.png

attrSize is correct? 2 should be fine since pdu is [2] - first byte is flag = 0 and second is value  = 60.

Anyone knows what its wrong?

0 Likes

Hello,


CY_BLE_ERROR_INVALID_PARAMETER will occurs due to invalid input parameter. Inside the Cy_BLE_HRSS_SendNotification function, if charIndex >= CY_BLE_HRS_CHAR_COUNT then it will send CY_BLE_ERROR_INVALID_PARAMETER error as shown below. For Cy_BLE_GATTS_Notification api, if the parameter 'ntfReqParam' is NULL, 'connHandle' is invalid or if 'ntfReqParam->handleValPair.value.len' value is greater than (Effective GATT MTU-3) then CY_BLE_ERROR_INVALID_PARAMETER error will occurs.

Please check the 'CE217639_BLE_Heart_Rate_Server' code example from the PSoC Creator for reference.

******************************************************************************************************
cy_en_ble_api_result_t Cy_BLE_HRSS_SendNotification(cy_stc_ble_conn_handle_t connHandle,
cy_en_ble_hrs_char_index_t charIndex,
uint8_t attrSize,
uint8_t *attrValue)
{
cy_en_ble_api_result_t apiResult;

/* Send Notification if it is enabled and connected */
if(Cy_BLE_GetConnectionState(connHandle) < CY_BLE_CONN_STATE_CONNECTED)
{
apiResult = CY_BLE_ERROR_INVALID_STATE;
}
else if(charIndex >= CY_BLE_HRS_CHAR_COUNT)
{
apiResult = CY_BLE_ERROR_INVALID_PARAMETER;
}
else if((cy_ble_hrsConfigPtr->hrss->hrmCccdHandle == CY_BLE_GATT_INVALID_ATTR_HANDLE_VALUE)
|| (!CY_BLE_IS_NOTIFICATION_ENABLED(connHandle.attId, cy_ble_hrsConfigPtr->hrss->hrmCccdHandle)))
{
apiResult = CY_BLE_ERROR_NTF_DISABLED;
}
else
{
/* Fill all fields of write request structure ... */
cy_stc_ble_gatts_handle_value_ntf_t ntfReqParam =
{
.handleValPair.attrHandle = cy_ble_hrsConfigPtr->hrss->charHandle[charIndex],
.handleValPair.value.val = attrValue,
.handleValPair.value.len = attrSize,
.connHandle = connHandle
};
/* Send notification to client using previously filled structure */
apiResult = Cy_BLE_GATTS_Notification(&ntfReqParam);
}

return(apiResult);
}
******************************************************************************************************

Thanks,
P Yugandhar.

0 Likes