English
Language : 

AN91162 Datasheet, PDF (40/43 Pages) Ramtron International Corporation – Creating a BLE Custom Profile
Creating a BLE Custom Profile
if(CYBLE_CUSTOM_CLIENT_CHARACTERISTIC_CONFIGURATION_DESC_HANDLE ==
wrReqParam->handleValPair.attrHandle)
{
/* Only the first and second lowest significant bit can be
* set when writing on CCCD. If any other bit is set, then
* send error code */
if(FALSE ==
(wrReqParam->handleValPair.value.val
[CYBLE_CUSTOM_CLIENT_CHARACTERISTIC_CONFIGURATION_DESC_INDEX] &
(~CCCD_VALID_BIT_MASK)))
{
/* Set flag for application to know status of notifications.
* Only one byte is read as it contains the set value. */
startNotification =
wrReqParam->handleValPair.value.val
[CYBLE_CUSTOM_CLIENT_CHARACTERISTIC_CONFIGURATION_DESC_INDEX];
}
else
{
/* Update GATT DB with latest CCCD value */
CyBle_GattsWriteAttributeValue(&wrReqParam->handleValPair,
FALSE,
&cyBle_connHandle,
CYBLE_GATT_DB_LOCALLY_INITIATED);
/* Send error response for Invalid PDU against Write
* request */
CYBLE_GATTS_ERR_PARAM_T err_param;
err_param.opcode = CYBLE_GATT_WRITE_REQ;
err_param.attrHandle = wrReqParam->handleValPair.attrHandle;
err_param.errorCode = ERR_INVALID_PDU;
/* Send Error Response */
(void)CyBle_GattsErrorRsp(cyBle_connHandle, &err_param);
/* Return to main loop */
return;
}
}
/* Send response to the Write request */
CyBle_GattsWriteRsp(connectionHandle);
break;
The error code ‘ERR_INVALID_PDU’ has a value of 0x04, as per BLE Core specification, Vol 3, Part F, section 3.4.1.
Define following in your application code.
/*****************GATT Error code*******************/
#define ERR_INVALID_PDU
0x04
#define CCCD_VALID_BIT_MASK
0x03
#define NOTIFY_BIT_MASK
0x01
www.cypress.com
Document No. 001-91162 Rev. *A
40