From d1b159aee77ab3f19adda432e9a22ed555519df0 Mon Sep 17 00:00:00 2001 From: przemobe Date: Sat, 30 Dec 2023 22:38:44 +0100 Subject: [PATCH] examples/PeriodicUdpSender.py update --- examples/PeriodicUdpSender.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/PeriodicUdpSender.py b/examples/PeriodicUdpSender.py index a21b60b..4ac5e06 100644 --- a/examples/PeriodicUdpSender.py +++ b/examples/PeriodicUdpSender.py @@ -17,7 +17,7 @@ def __init__(self, ntw, tgt_addr, tgt_port, period_sec): self.period_sec = period_sec # Define states: 0 - idle, 1 - connecting, 2 - connected self.state = 0 - self.init_time = time.time() + self.init_time = 0 def loop(self): ctime = time.time() @@ -45,7 +45,7 @@ def loop(self): else: # 2 == self.state if ctime - self.init_time > self.period_sec: self.send_data() - self.init_time += self.period_sec + self.init_time = ctime + self.period_sec def send_data(self): n = self.ntw.sendUdp4(self.tgt_addr, self.tgt_port, '<134>I am alive!'.encode())