This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Acknowledge through GATT_Indication

Hi everyone! happy new year!

I've been studing how to send data with ack through Thermometer application

but i couldn't fully understand the sequence of ack. Somebody could help me?

In my app (based on SimpleBLEPeripheral) i did a sequence like this:

For example, to start to send data, i need to press the left boton...

+ in the simpleBLEPeripheral_HandleKeys function:

if ( keys & HAL_KEY_SW_1 ) {

     SK_Keys |= SK_KEY_LEFT;

sendData();

}

+ Then, in the sendData function:

static void performPeriodicTask( void ) {

  static uint16 cant = 0;
static uint8 k = 0;
uint8 j;
uint8 valor[14];
bStatus_t ret;
attHandleValueInd_t indication;
if(cant>500){
return;
}
for(j=0;j<14;j++){
valor[j]=k;
}
indication.handle = 0xABCD;
indication.len = 14;
VOID osal_memcpy( indication.value, valor, 14 ) ;
ret = GATT_Indication( 0x0000,&indication,FALSE,simpleBLEPeripheral_TaskID );
if(ret==SUCCESS){
k++;
cant++;
}
}
 + In the simpleBLEPeripheral_ProcessOSALMsg:
 static void simpleBLEPeripheral_ProcessOSALMsg( osal_event_hdr_t *pMsg ) {
switch ( pMsg->event ) {
case KEY_CHANGE:
simpleBLEPeripheral_HandleKeys( ((keyChange_t *)pMsg)->state, ((keyChange_t *)pMsg)->keys );
break;
case GATT_MSG_EVENT:
simpleBLEPeripheral_ProcessGattMsg( (gattMsgEvent_t *) pMsg );
break;
default:
// do nothing
break;
}
}
 + Then, in the simpleBLEPeripheral_ProcessGattMsg:
 static void simpleBLEPeripheral_ProcessGattMsg( gattMsgEvent_t *pMsg ) { 

//Measurement Indication Confirmation
if( pMsg->method ==ATT_HANDLE_VALUE_IND) {
ATT_HandleValueCfm( pMsg->connHandle ); <--- Here confirms the ack supposedly
sendData(); <--- And here calls sendData function again to send data again.
 }
}

When i run my app and press the left botton, only once the sendData function is called, so one data is sent only.
How is the correct sequence to send data and receive ack?

Thanks in advance!

Best Regards,
Martin Romero
  • Hello,

    The thermometer application show example of indication.  

    You should handle the confirmation in your app.

    pMsg->method ==ATT_HANDLE_VALUE_CFM

    Indications can be tricky

    - They will block subsequent indications  (and other gatt msgs) until the confirmation comes back or times out (30 sec I think)

    - Btool will not send back a confirmation automatically - so be sure the receiver of the indications is sending back the confirmation.

    Indications give the app some level of handshaking, but BLE in general will always re transmit packets until they are confirmed (lower level), or will timeout.

    BR,

    -Greg 

  • Thanks GregS!

    I'm going to study the application PC of the thermometer.  I'll publish the results later, thanks!

    Martin Romero