- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
Terminal output:
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:
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
Solved! Go to Solution.
- Labels:
-
PSoC 6 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
For now I am trying to send value = 60.
The notification function:
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.