As an alternative to built-in NTP sync implementation you may use this simple code:
NTP_QUERY = bytearray(48)
NTP_QUERY = 0x1b
addr = socket.getaddrinfo(<NTP_SERVER>, 123)[-1]
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
res = s.sendto(NTP_QUERY, addr)
msg = s.recv(48)
val = struct.unpack("!I", msg[40:44]) - 2208988800 # 70 years difference between NTP and Pycom epoch
tm = time.localtime(val)
Don't forget to implement handling of socket exceptions.
I'm getting the following error: TypeError('extra keyword arguments given). After some investigation it turns out that the error comes from the SSL socket wrapper: self.sock = ussl.wrap_socket(self.sock, **self.ssl_params).
How did you manage to make it connect?
I would like to implement persistent event logging into local file system. What approach to choose to achieve solution resilient to power outages? Using new LittleFS file system might help but I am a little bit concerned because there is also config file stored in the file system in case of our application. I was considering to move the config to RTC memory. Using NVS for persistent store of config is not an option as it currently supports only integers.
Normally when I edit a .py in Atom I don't even have to upload it to the gpy, I just click run and the newly edited version runs. But when I edit a .py file in the lib folder not only do I have to upload it to the gpy flash, I have to reset the gpy to get the newly edited version. I'm not making this up I've double checked. The edit is saved on the PC, it's there in Atom, it's in the gpy flash yet the unedited version persists till I do a gpy reset. Why don't .py files in the lib folder edit the same as .py files elsewhere?
@colateral I believe that the Pycom firmware uses one core for networking and the other to run the actual MicroPython code, or something similar. Not sure how easy it would be to disable one of the cores altogether.
There has been discussion about changing the frequency though, there must be a thread somewhere in the forum with instructions IIRC.