While nRF Cloud is connected, main keeps a periodic timer on a dedicated workqueue (CONFIG_APP_MAIN_SYNC_INTERVAL_SECONDS, default 600 seconds). Each synchronization runs through a sequence of substates, waiting for the current step to finish before starting the next:
- Sends a demo JSON device message on
cloud_chan(payload:{"appId":"SMHA","messageType":"DATA","data":"hello"}), then waits forCLOUD_MESSAGE_SENT. - Publishes
LOCATION_SEARCH_TRIGGERonlocation_chanwhen the application is built with the location overlay (CONFIG_APP_LOCATION), then waits forLOCATION_SEARCH_DONE. - Publishes
CLOUD_SHADOW_POLL_REQUESToncloud_chanto pick up any desired configuration from the device shadow, then waits forCLOUD_SHADOW_POLLED. - Publishes
FOTA_POLL_REQUESTonfota_chanto check for firmware updates, then waits forFOTA_ABORTEDor enters the FOTA download state onFOTA_STARTING. - Publishes
CLOUD_MEMFAULT_POST_REQUESToncloud_chanto post any pending Memfault data, then waits forCLOUD_MEMFAULT_POSTED.
An initial synchronization runs immediately on cloud connect. The timer is cancelled when the cloud disconnects. A new periodic trigger is only acted on while main is idle between synchronizations.
During the location step, the location module scans for Wi-Fi access points and publishes the result as LOCATION_CLOUD_REQUEST, which main forwards to the cloud module. The cloud module resolves it into a position with an nRF Cloud CoAP ground-fix request and logs the position together with a Google Maps URL. Main does not advance past the location step until LOCATION_SEARCH_DONE is published.