- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you tell how to use the api : void leatt_sendErrResponse(INT32 errCode, INT32 reqOpcode, INT32 handleInError ) ( be defined
in the leatt.h)
I don't know errCode, reqOpcode, handleInError ? no any description in leatt.h.
I quess
errCode =
#define LEATT_ERR_CODE_INVALID_HANDLE 0x01
#define LEATT_ERR_CODE_READ_NOT_PERMITTED 0x02
...........
reqOpcode =
#define LEATT_OPCODE_ERR_RSP 0x1
#define LEATT_OPCODE_EXCHANGE_MTU_REQ 0x2
.........
but whis is handleInError ??????
In our production need a read gatt character call back function
and a error response.
xxx_create(void)
{
.....
lel2cap_regConnLessHandler(4, homedoor_l2cap_att_data_handler); /* home_door_l2cap_att_data_handler is l2cap att data access call back function */
...........
}
static void homedoor_l2cap_att_data_handler(UINT8 *l2capHdr)
{
uint8 opcode = (LEATT_PDU_HDR*) (l2capHdr + 4);
UINT16 *handle = (UINT16 *)(l2capHdr + 5);
UINT8 status = 0;
switch(opcode)
{
case LEATT_OPCODE_READ_REQ:
status = SystemUtilsReadAttrCB(handle); // is my private GATT sevice and character read call back function
break;
}
if (status == LEATT_ERR_CODE_NO_ERROR)
{
leatt_l2capHandler(l2capHdr); // continue to process GATT service
}
else
{ // status = LEATT_ERR_CODE_REQ_NOT_SUPPORTED
leatt_sendErrResponse(status , LEATT_OPCODE_READ_REQ, ??????); }
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The third parameter is the attribute handle. When you receive LEATT_OPCODE_READ_REQ you can do processing like
LEATT_PDU_READ_REQ_HDR *p_req = (LEATT_PDU_READ_REQ_HDR *)(l2capHdr +1);
The attribute that peer is trying to read is p_req->attrHandle. You need to match it against your database. And when you want to send error response you should use the same handle.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Tsung-Yu,
We checked with the developers on your request.
1. These are standard error responses - Please see the ATT specification LIST of Error codes, Page 374 of the Core_4.2 document: https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=286439
2. You must also use the appropriate error code.
3. Since you are overriding our responses, you must follow the spec.
4. Our ATT implementation is BQB listed as compliant.
5. We don't know what the implications of using our BQB but we will check with the developers
Thank you
JT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your response.
Our BLE productions are applied to the security Smart Home.
I hope when user want to read our private GATT service and character, he must have a security level.
So I have to have a call back function when user want to read service and character.
if he has a security level, the call back function will bypass to leatt_l2capHandler(l2capHdr) process, otherwise the call back function will return REQ_NOT_SUPPORTED response to client.
Please check with the developers.
I view the leatt.h
void leatt_sendErrResponse(INT32 errCode, INT32 reqOpcode, INT32 handleInError )
I cannot know the definition about the parameters : errCode, reqOpcode and handle.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The third parameter is the attribute handle. When you receive LEATT_OPCODE_READ_REQ you can do processing like
LEATT_PDU_READ_REQ_HDR *p_req = (LEATT_PDU_READ_REQ_HDR *)(l2capHdr +1);
The attribute that peer is trying to read is p_req->attrHandle. You need to match it against your database. And when you want to send error response you should use the same handle.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe it will be written :
LEATT_PDU_READ_REQ_HDR *p_req = (LEATT_PDU_READ_REQ_HDR *)(l2capHdr +4);
Because L2CAP HDR is like as below:
typedef PACKED struct
{
UINT16 length;
UINT16 cid;
} LEL2CAP_HDR;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your l2capHdr is UINT8 * then you are right. My snippet assumed that it is L2CAP_HDR *.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks