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

Main loop in Asset Tracker application

Hello,

I was reading through the code of the asset tracker application and noticed that there is no while(1)/for(;;)-loop. I see this for the first time in a board application. All the other samples have a while(1)-loop. What happens after the last function call 'connect_to_cloud()'? 

Parents
  • Hi, Andrew!

    There is no particular need for main in NCS. In fact, some Zephyr samples doesn't have a main at all! There will still be various threads running, e.g. in the drivers and workqueues. While I don't remember all the details on how the asset_tracker does things, when the cloud responds to the connection request, a event handler will be called, which starts the next step, which triggers new events, etc.

    If you want to untangle it I suggest that you look for places where threads are started (sometimes before main) and items are put in workqueues. 

    Best regards,
    Carl Richard

Reply
  • Hi, Andrew!

    There is no particular need for main in NCS. In fact, some Zephyr samples doesn't have a main at all! There will still be various threads running, e.g. in the drivers and workqueues. While I don't remember all the details on how the asset_tracker does things, when the cloud responds to the connection request, a event handler will be called, which starts the next step, which triggers new events, etc.

    If you want to untangle it I suggest that you look for places where threads are started (sometimes before main) and items are put in workqueues. 

    Best regards,
    Carl Richard

Children
Related