This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

What is the point of app_scheduler.h in the ble eddystone example?

The ble_app_eddystone example that comes with the SDK uses the scheduler, but I have failed to see where any handlers are registered to the scheduler (and grep-ing the eddystone library itself shows it uses the scheduler only in the flash-memory related logic).

I feel silly asking, but where in main.c is the scheduler told to do anything related to ble? What needs to be changed so that the eddystone example can run without the scheduler library?

  • The scheduler is used (as you state) for performing the garbage collection. The app_timer library also uses the scheduler (see the APP_TIMER_CONFIG_USE_SCHEDULER config). No BLE activity is directly controlled by the scheduler.

    If you want to remove the scheduler dependency, implement some check in main-context whether or not garbage collection should be done, and change the config of app_timer to not use the scheduler.

  • Hi Krastanov. The app_scheduler's primary function is to move any processing out of the interrupt handlers and into the main loop. The advantages of this are short interrupt handlers & all interrupts are dealth with ASAP (see link). In the main() function in the main.c file, the scheduler is initialized first. Afterwards, the function app_sched_execute() is run. This function executes all events scheduled since the last time it was called.

    Regarding your question: "is the scheduler told to do anything related to ble?": It is true that no BLE activity is directly controlled by the scheduler. But in the eddystone example, the APP_TIMER_CONFIG_USE_SCHEDULER enables scheduling of app_timer to the app_scheduler. So essentially you use the scheduler to cycle through the different eddystone adversting frames. Therefore, you could say that the app_scheduler is indirectly used for BLE advertising.

    It might also be useful to take a look at the Nordic Infocenter & this scheduler library link. This devzone case could also be useful, as well as taking a look at the scheduler tutorial.

Related