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