Question
For the BLE_DataThroughput example, in dts.c, when receiving an event of EVT_BLUE_GATT_ATTRIBUTE_MODIFIED and trying to find out which characteristic is the one being modified, why do the handles have an integer added to them prior to the comparison?
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;