- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
I would like to send a negative response to a write request, so I wrote:
case CYBLE_EVT_GATTS_WRITE_REQ: {
CYBLE_GATTS_WRITE_REQ_PARAM_T * wrReqParam = (CYBLE_GATTS_WRITE_REQ_PARAM_T *) eventParam ;
if (MY_PORT_CHAR_HANDLE == wrReqParam->handleValPair.attrHandle) {
CYBLE_GATTS_ERR_PARAM_T err = {
.attrHandle = wrReqParam->handleValPair.attrHandle,
.opcode = 1,
.errorCode = CYBLE_GATT_ERR_UNLIKELY_ERROR
} ;
CYBLE_API_RESULT_T x = CyBle_GattsErrorRsp(cyBle_connHandle, &err) ;
DBG_PRINTF("%d = CyBle_GattsErrorRsp\n", x) ;
}
}
break ;
the print result is 2 == CYBLE_ERROR_INVALID_OPERATION
I read this post Re: How to send an ATT Error response , but it has not an example
In the specification I found:
Can I send an error? How?
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like the issue is with the opcode used, the below code works for me to generate the error response
errrsp.attrHandle=CYBLE_CUSTOM_SERVICE_CUSTOM_CHARACTERISTIC_CHAR_HANDLE;//handle to which write was done
errrsp.opcode= (uint8)CYBLE_GATT_WRITE_REQ;//opcode for error response
errrsp.errorCode=CYBLE_GATT_ERR_INVALID_ATTRIBUTE_LEN ;//ATTr length error
apiresult = CyBle_GattsErrorRsp(cyBle_connHandle,&errrsp);
printf(" ERROR API RESULT %d \n",apiresult);
Thanks,
Ranjith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
If the Server already responded with an opcode which is done by the stack in most scenarios, this this operation could be invalid.
I believe this is what you are seeing in your case. Do you have airlogs for this scenario?
Thanks,
Ranjith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Ranjith,
I don't have airlogs.
I think that the stack does not respond because I must invoke:
If, inside CYBLE_EVT_GATTS_WRITE_REQ event, I don't call this function, the phone connected to me complains.
The doc says: This function has to be invoked in response to a valid Write Request, but, in some cases, I would like to send an error (the phone should retry later). How can I send an error?
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like the issue is with the opcode used, the below code works for me to generate the error response
errrsp.attrHandle=CYBLE_CUSTOM_SERVICE_CUSTOM_CHARACTERISTIC_CHAR_HANDLE;//handle to which write was done
errrsp.opcode= (uint8)CYBLE_GATT_WRITE_REQ;//opcode for error response
errrsp.errorCode=CYBLE_GATT_ERR_INVALID_ATTRIBUTE_LEN ;//ATTr length error
apiresult = CyBle_GattsErrorRsp(cyBle_connHandle,&errrsp);
printf(" ERROR API RESULT %d \n",apiresult);
Thanks,
Ranjith