4 Replies Latest reply on Jul 28, 2017 1:36 AM by BoonT_56

    Init Scan Timer_1s Stop

    male_2159431

      Hello everyone.

      I have the following problem.

      When I put in the code blecen_Scan the timer 1s stopped working.

      Has anyone ever had a similar problem?

        • 1. Re: Init Scan Timer_1s Stop
          BoonT_56

          Are you referring to the SW 1s application_timeout? And where did you put blecen_Scan?

           

          In any case, I assumed that you are working on a client application and I would like to refer to the hello_client application.

          If P0 is pressed for 6s, then the client_app will deemed it as an interrupt and proceed to call the handler, subsequently entering

          a high duty scanning state:

          {

              ble_trace0("Stop adverts and start high scan");

              bleprofile_Discoverable(NO_DISCOVERABLE, NULL);

              blecen_Scan(HIGH_SCAN);

          }

           

          Do refer to the hello_client app on how to deploy blecen_Scan.

          1 of 2 people found this helpful
          • 2. Re: Init Scan Timer_1s Stop
            BoonT_56

            Did you perform the kill_timer function first before you start it?

             

            // change timer callback function.  because we are running ROM app, need to

            // stop timer first.

                bleprofile_KillTimer();

                bleprofile_regTimerCb(hello_client_app_fine_timer, hello_client_app_timer);

                bleprofile_StartTimer();

            1 of 2 people found this helpful
            • 3. Re: Init Scan Timer_1s Stop
              male_2159431

              Yes, 1s application_timeout. I put blecen_Scan in the "create" function.

               

              I do not use the killtimer function, but using her did not work.

               

              The timer will worl if the blecen_scan function is commented on.

               

              My app need scan beacons advertisements and send data via UART. Blecen_scan is the better way to do 20737 scan beacons?

              • 4. Re: Init Scan Timer_1s Stop
                BoonT_56

                Ok, perhaps now I understand the question. If you initiate the blecen_scan in the create function, it will enter this state of scanning until it is interrupted. You will have to implement the blecen_scan(No scan) some where to interrupt/break it, then those timers will continue to work and count. Alternatively, don't start the scan in the create function, put it in an interrupt handler.

                 

                For example:

                 

                void app_create(void)

                {

                    bleprofile_Init(bleprofile_p_cfg);

                    bleprofile_GPIOInit(bleprofile_gpio_p_cfg);

                 

                    // Enable Button Interrupt

                  

                    // register to process peripheral advertisements, notifications and indications

                    blecm_RegleAdvReportCb((BLECM_FUNC_WITH_PARAM) advertisement_handler);

                    blecen_Scan(NO_SCAN);

                 

                    bleprofile_regTimerCb(app_fine_timer, app_timer);

                    bleprofile_StartTimer();

                }

                void app_fine_timer(UINT32 arg){}  //do nothing

                void app_timer(UINT32 arg){

                     ble_trace0("1s has elapsed");

                }

                 

                The above will allow the timer to run, and if I apply an interrupt, the state will change to that of scanning. You may also want to implement a

                callback when the scanning process ends, then the device will return to counting again. Insert some traces to show the executions.