4 Replies Latest reply on Sep 4, 2017 12:20 AM by denis.touillon_1826166

    Handle correcty the "busy state" of the ble stack


      Hello everyone,


      I would like how to handle correcty the "busy state" of the ble stack.


      I tried a basic test where  the same data is send constantly with notification :


      void SendDataOverStatesNotification(uint8 StatesData, uint8 len)
      /* 'StatesnotificationHandle' stores States notification data parameters */
      CYBLE_GATTS_HANDLE_VALUE_NTF_T StatesnotificationHandle;
      /* If stack is not busy, then send the notification */
      /* Update notification handle with CapSense slider data*/
      StatesnotificationHandle.attrHandle = CYBLE_SHUTBASSCV_STATES_CHAR_HANDLE;
      StatesnotificationHandle.value.val = &StatesData;
      StatesnotificationHandle.value.len = len;
      /* Wait until stack is free to send data*/
          while(busyStatus  != CYBLE_STACK_STATE_FREE) { CyBle_ProcessEvents(); }
      /* Send the updated handle as part of attribute for notifications */




      If i put a  CyDelay(5); before this function this work fine (at least during 10 minutes).
      Without the delay it's crashing after 5 sec.


      I would like to have something which is not crashing no matter the connection interval. 
      How i can just wait the BLE stack properly without a delay ?


      Should i use : 


      while(busyStatus  != CYBLE_STACK_STATE_FREE) { CyBle_ProcessEvents(); }




      if(busyStatus  == CYBLE_STACK_STATE_FREE) {my function code}


      I don't see why the stack is crashing if I wait unti it is not busy after each send..




      Thanks for your answers