2021-02-02 08:00 AM
The code in question is below. You can see that each of the characteristic handles have an integer added to them prior to the comparison (i.e., + 2, + 5, +1). Why?
case EVT_BLUE_GATT_ATTRIBUTE_MODIFIED:
{
attribute_modified = (aci_gatt_attribute_modified_event_rp0*) blue_evt->data;
if (attribute_modified->Attr_Handle == (aDataTransferContext.DataTransferTxCharHdle + 2))
{
/**
* Notify to application to start measurement
*/
if (attribute_modified->Attr_Data[0] & DTS_STM_NOTIFICATION_MASK)
{
APP_DBG_MSG("notification enabled\n");
Notification.Evt_Opcode = DTS_STM__NOTIFICATION_ENABLED;
DTS_Notification(&Notification);
}
else
{
APP_DBG_MSG("notification disabled\n");
Notification.Evt_Opcode = DTS_STM_NOTIFICATION_DISABLED;
DTS_Notification(&Notification);
}
}
//if (attribute_modified->Attr_Handle == (aDataTransferContext.DataTransferTxChar3Hdle + 2))
if (attribute_modified->Attr_Handle == (aDataTransferContext.DataTransferTxChar3Hdle + 5))
{
/**
* Notify to application to start measurement
*/
if (attribute_modified->Attr_Data[0] & DTS_STM_NOTIFICATION_MASK)
{
APP_DBG_MSG("notification enabled\n");
Notification.Evt_Opcode = DTC_NOTIFICATION_ENABLED;
DTS_Notification(&Notification);
}
else
{
APP_DBG_MSG("notification disabled\n");
Notification.Evt_Opcode = DTC_NOTIFICATION_DISABLED;
DTS_Notification(&Notification);
}
}
if(attribute_modified->Attr_Handle == (aDataTransferContext.DataTransferRxCharHdle + 1))
{
return_value = SVCCTL_EvtAckFlowEnable;
Notification.Evt_Opcode = DTS_STM_DATA_RECEIVED;
Notification.DataTransfered.Length=attribute_modified->Attr_Data_Length;
DTS_Notification(&Notification);
}
}
break;
case EVT_BLUE_GATT_TX_POOL_AVAILABLE:
Resume_Notification();
break;
case EVT_BLUE_GATT_WRITE_PERMIT_REQ:
APP_DBG_MSG("write permit req\r\n");
write_permit_req = (aci_gatt_write_permit_req_event_rp0 *) blue_evt->data;
aci_gatt_write_resp( write_permit_req->Connection_Handle, write_permit_req->Attribute_Handle, 0, 0, write_permit_req->Data_Length, write_permit_req->Data);
break;
2021-08-06 07:51 AM
Hi Patrick,
I actually have the same question that you raised. So why is a value added to the handle before the comparision? Did you receive an answer?
Best Regards
Markus
2021-08-06 11:25 AM
Unfortunately, I have not-- I still don't understand why that's done.
2023-01-16 12:16 AM
Hi @Patrick Chwalek and @Community member,
Have either of you managed to find an answer yet? Or any reference to what integers need to be added in any documentation?
Best Regards,
Targo
2023-01-17 08:07 AM
Hi @Targo , I have not found an answer. My solution to this is a bit brute force.
2023-01-18 10:27 PM
Hi @Patrick Chwalek , thank you. I guess I will have to do the same.
In the latest version of "ble_gatt_aci.h" above the function "aci_gatt_add_char" I did see this:
"
The command returns the handle of the declaration attribute. The attribute
* that holds the Characteristic Value is always allocated at the next handle
* (Char_Handle + 1). The Characteristic Value is immediately followed, in
* order, by:
* - the Server Characteristic Configuration descriptor if CHAR_PROP_BROADCAST
* is selected;
* - the Client Characteristic Configuration descriptor if CHAR_PROP_NOTIFY or
* CHAR_PROP_INDICATE properties is selected;
* - the Characteristic Extended Properties descriptor if CHAR_PROP_EXT is
* selected.
* For instance, if CHAR_PROP_NOTIFY is selected but not CHAR_PROP_BROADCAST
* nor CHAR_PROP_EXT, then the Client Characteristic Configuration attribute
* handle is Char_Handle + 2.
"
Although I don't fully understand it.
2023-01-19 08:20 AM
So the thought here is that the offset depends on the attribute with which the characteristic is set? I have yet to try modifying the attributes and checking the offset.