4 Replies Latest reply on Apr 1, 2016 5:06 PM by userc_19497

    Scan and callback

      Few question about scan and call back:


      1) If I used the follow blecm_startScan to start scan, will it timeout based on the configuration blecen_cen_cfg.low_scan_duration ?


      blecm_startScan (








      2) if I use blecen_Scan(LOW_SCAN) to start the scan and use blecen_Scan(NO_SCAN) to stop it before timeout, will the call back function (BLEAPP_APP_TIMER_SCAN) be called?


      3) if I use blecm_setScanEnable to stop scanning, will the call back function (BLEAPP_APP_TIMER_SCAN) be called?


      blecm_setScanEnable(HCIULP_SCAN_MODE_OFF, blecen_cen_cfg.filter_duplicates);

        • 1. Re: Scan and callback

          I will ask userc_19497 to take a look at this when he returns to the office next week.

          • 2. Re: Scan and callback



            You probably don't want be using blecm_startScan unless you absolutely have to.

            blecm_startScan is called inside blecen_Scan function.

            In blecen_Scan, these things happen sequentially:

                 - it turns off the callback timer

                 - it turns off the scan

                 - resets the scan mode

                      - start the callback timer and scan if appropriate with the right scan_type


            To answer your questions:

            1. calling blecm_Scan will start the scan with the given parameters. However, the scanner callback will not be called.

            2. calling blecen_Scan will always stop the callback timer and the scan first. If the function is called with NO_SCAN argument, the callback will not be called again.

            3. calling blecm_setScanEnable will only stop the scan. It will not stop the callback timer. So the callback function will be called again.


            I suggest sticking to using blecen_Scan function as it gives you control over the callback timer.

            Please refer to hello_client application for example on how to use blecen_Scan.

            Thank you.



            1 of 1 people found this helpful
            • 3. Re: Scan and callback

              userc_19497 Thanks for replying.


              1. Will it be ok to set scan_duration less than scan_window?  For example:


              scan_duration  = 9 seconds

              scan_window = 10 seconds


              If so, will the scan stops at 9th second and call the callback function?


              2. Does blecen_Scan(HIGH_SCAN) have callback?


              3. Can I change scan parameters such as blecen_cen_cfg.low_scan_interval on the fly?

              • 4. Re: Scan and callback



                I'm sorry I haven't replied back earlier. I didn't have time to look at the source code.

                Here are answers to your question:

                1. Yes, it would be okay to set it like that (not sure why you would want to do that though).

                scan_duration is only used for the scan timer, which enables the scan callback. So changing the scan_duration will effect when the scan callback is called. Also notice that scan_window has units of slots where as in scan_duration is in seconds. Don't mix the numbers.

                I'm not sure if the scan is stopped when the callback is called...


                2. Whenever you start a scan, the timer will call whatever callback defined at variable blecen_usertimerCb. The default is NULL.


                3. Yes, you can change the intervals by setting a new value to blece_cen_cfg, but you must restart the scan by calling blecen_Scan function.


                Again, I'm sorry if this reply is really late.

                But I thought if I put the info, someone else might be able to benefit from it.

                Hope this info helps.



                Thank you.