Other Parts Discussed in Thread: CC2541
Tool/software:
Hello
I´m developing an application based in the basic BLE project set as Central (in syscfg file) and I´m using the example available in the simplelink_lowpower_f3_sdk_8_10_01_02.
The implementations below were done and works as expected:
* Connection handling - OK
* Services discovery - OK
* Characteristics and their descriptors discovery - OK
* CCCD discovery - OK
* Menu module options and functions to enable/disable indications were created - OK
* Register the BLEAPPUTIL_ATT_HANDLE_VALUE_IND event - OK
The peripherals I need to connect have 2 characteristics set to Indicate and one set as Write. Everything until this point is working really good.
So, after connecting and discovering everything mentioned above, I proceed to manually turn ON indications for one of these 2 characteristics and the result is the central starts to receive ATT_HANDLE_VALUE_IND notifications as expected. I see the payload data received by central is perfect.
At first, central was receiving only the first notification and never a second one. Then I learned centrals need to send acknowledgment back after receiving Indication data so I added a call to function ATT_HandleValueCfm(gattMsg->connHandle);
After doing this, my central started to receive Indications constantly, always with updated data on it. But after a few seconds the Indication events stops and ATT_FLOW_CTRL_VIOLATED_EVENT happens.
This is the event code snippet that access the nofitication data and invokes the ATT_HandleValueCfm function.
case ATT_HANDLE_VALUE_IND:
{
MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE1, 0, "Indication length= %d",
gattMsg->msg.handleValueInd.len);
MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE2, 0, "DATA BYTES = 0x%02x, 0x%02x, 0x%02x",
gattMsg->msg.handleValueInd.pValue[0],
gattMsg->msg.handleValueInd.pValue[1],
gattMsg->msg.handleValueInd.pValue[2]);
pesoBruto=gattMsg->msg.handleValueInd.pValue[6]<<24;
pesoBruto|=gattMsg->msg.handleValueInd.pValue[5]<<16;
pesoBruto|=gattMsg->msg.handleValueInd.pValue[4]<<8;
pesoBruto|=gattMsg->msg.handleValueInd.pValue[3];
MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE3, 0, "PESO BRUTO = %ld", pesoBruto);
//ClockP_usleep(100000);
// vTaskDelay( 1000 );
ATT_HandleValueCfm(gattMsg->connHandle);
break;
}
I tried to add a variety of delays but I don´t know if this is right. When I uncomment one fo those 2 delay lines (ClockP_usleep(10000); or vTaskDelay( 100 ); ) the flow control violation does not happen anymore but the Indication event still stops happening after a few seconds.
So a few questions:
1) Is ATT_HandleValueCfm(gattMsg->connHandle); the correct way to acknowledge an Indication?
2) If yes, is this the correct place to call it? (inside the event handler right after dealing with the payload data)
3) Those delays are a good thing to use in that place? (inside the event handler right after dealing with the payload data)
Thank you in advance