przemobe / micropy-ENC28J60

ENC28J60 Ethernet chip driver for MicroPython (RP2)
GNU General Public License v3.0
22 stars 7 forks source link

How to get time from NTP at regular intervals using ENC.... #4

Closed ph1lj-6321 closed 11 months ago

ph1lj-6321 commented 1 year ago

Hi Using your SntpClient.py, I'm trying top sample the time at a regular time interval (say every second) - not as easy as I thought. It only graps the data once - regardless of how long a delay I use, before looping

Any thoughts ?

ph1lj

przemobe commented 1 year ago

Please provide sample code. I will try to solve the issue.

My first thought is to check if: 1) line 88 should be commented:

def proc_response(self, pkt):
...
    # Deregister callback for response
    # self.ntw.registerUdp4Callback(self.client_port, None) <<< comment this

2) After delay/timeout reset client state: sntp_cli.state = 0

3) How is delay implemented? I recommend not adding delay() into main loop - so packets could be received. Add timing mechanism similar to SntpClient.init_time variable and ctime = time.time().

Best Regards