This has the added benefit of no longer needing to check the network since NTP will fail to synchronize until the network connection has been established. However, after some further research, I found another great add-on for Nerves: Nerves Time. This package will handle the nitty-gritty of managing NTP and will actually make sure your device time is closely estimated until is able to synchronize with NTP. So I have one more adjustment to make to my code:
defp check_time do if !Nerves.Time.synchronized?() do Process.sleep(1000) check_time() end end
Great! Now for a final flash and test:
Thanks for reading and I hope that this post helps you avoid some early pitfalls of Nerves development. If you have any comments or suggestions or angry rants please feel free to leave feedback on Heartbeat.