I’m working on an app where I need all device-specific settings to be synchronized from the Golioth cloud before taking any sensor readings.
I don’t think the Golioth firmware SDK currently has any high-level method for the client to know when all settings have finished synchronizing from the cloud. This feels like a pretty common scenario, so I was just curious if there is a recommended way to detect this on the client.
I’m planning to just set a flag in the callback for each setting being registered, so that I can keep track which settings have been successfully registered and gate the sensor readings from starting (e.g., via semaphore) until all settings have been synchronized.
Is there a better way to do this with the SDK?
(Also not sure if the way settings are handled will change when Multiple callback triggers in 'settings' subsystem · Issue #662 · golioth/golioth-firmware-sdk · GitHub is addressed)
In this scenario, are you also taking advantage of Non-Volatile Storage (NVS)? Or is the assumption that all settings will be novel for each reading upon wakeup?
I think the semaphore approach is the right one. I don’t know of anything in the SDK that would gate the behavior otherwise.
Not novel for each reading, but different for each device. In this specific case (the water level sensor Jeremy is building), the length of the float arm may vary between individual devices, so there is no “default” value that can be hard coded into the firmware. Instead, these device-specific config settings are set via the Golioth console once the device is installed and the actual length of the arm is measured for that device. I suppose this setting could just be stored on in flash as part of an initial provisioning step, but there are some other device-specific settings that can be configured on the fly, so using the settings service for all of these seemed like the easiest option.