2 Replies Latest reply on Nov 7, 2017 10:52 PM by DheerajDake

    Cyble 212019 scan stops after a while in Central and peripheral mode

    DheerajDake

      Hello all,

      I have my BLE configured as follows:

      1.PNG

      2.PNG

       

      My code is as follows

      /******************************S T A R T ********* M A I N . C ******************************/

      void monitorCybleState();

       

      int main(){

         CyBle_Start(StackEventHandler);

       

         for(;;){

             monitorCybleState();

         }

         return 0;

      }

       

      void monitorCybleState()

      {

          switch(CyBle_GetState()){

              case CYBLE_STATE_STOPPED:

                  break;

       

              case CYBLE_STATE_INITIALIZING:

                  break;

             

              case CYBLE_STATE_CONNECTED:

                  break;

             

              case CYBLE_STATE_ADVERTISING:

                  break;

             

              case CYBLE_STATE_SCANNING:

                  break;

             

              case CYBLE_STATE_CONNECTING:

                  break;

             

              case CYBLE_STATE_DISCONNECTED:

                  CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

                  CyBle_GapcStartScan(CYBLE_SCANNING_FAST);

                  break;

       

              default:

                  break;

          }

      }

      /******************************E N D ********* M A I N . C ******************************/

       

      /**********************S T A R T *********** E V E N T . C **********************/

      void StackEventHandler(uint32 event, void* eventParam){

          switch(event){

                 case CYBLE_EVT_STACK_ON:

                        break;

       

                case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

                       printf(".");

                       break;

       

                case  CYBLE_EVT_GAPC_SCAN_START_STOP:

                        printf("CYBLE_EVT_GAPC_SCAN_START_STOP\r\n");

                        break;

       

                 default:

                       break;

         }

      }

      /**********************E N D **************** E V E N T . C ***********************/

       

      /**********************OBSERVATIONS******************/

       

      I see that advertisement and scanning are started. I can see my BLE advertising with the payload I configured. Also,the scanning is active as I can see the dots on my console. After a while I don't see any dots which means there are no scan events. This implies that scanning has stopped because there are active BLE devices emitting beacons all the time. I printed the value of CyBle_GetState() and it shows 4.

       

      4 corresponds to CYBLE_STATE_SCANNING.

       

      This implies that Cyble is still in scanning state but it is not scanning anymore. I am not sure why. I added debug messages to see if somehow CyBle_GapcStopScan() is being called. I didn't see my debug messages on console. So no. I am not sure why scan is stopping after a while. It stops at random times. However, advertisement is functioning well.

       

      As of now the only way to fix this is using stack restart which is CyBle_Stop() and Cyble_Start() which starts the advertisement and scan again. Any suggestions on how to fix this without stack restart?

       

      Thanks

      Dheeraj