Skip to content

Commit

Permalink
examples/PeriodicUdpSender.py update
Browse files Browse the repository at this point in the history
  • Loading branch information
przemobe committed Dec 30, 2023
1 parent 907b00d commit d1b159a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/PeriodicUdpSender.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit d1b159a

Please sign in to comment.