I am trying to update a string (MESSAGE) with a variable that is updated each time a message is sent (msg_no)
I have poked around a bit and it looks like the msg_no variable is being updated the way I would like but the string (MESSAGE) is not being updated (it shows up as 0 each time). I'm not sure why, thanks for any help.
import xbee
import time
msg_no = 0
# TODO: replace with the 64-bit address of your target device.
TARGET_64BIT_ADDR = b'\x00\x13\xA2\x00\x41\xB7\x6C\x8C'
MESSAGE = "Hello from router (Msg No. %s)" % (msg_no)
print(" +---------------------------------------+")
print(" | XBee MicroPython Transmit Data Sample |")
print(" +---------------------------------------+\n")
print("Sending data to %s >> %s" % (''.join('{:02x}'.format(x).upper() for x in TARGET_64BIT_ADDR),
MESSAGE))
try:
msg_no += 1
xbee.transmit(TARGET_64BIT_ADDR, MESSAGE)
print("Data sent successfully")
except Exception as e:
print("Transmit failure: %s" % str(e))
time.sleep(5)
try:
msg_no += 1
MESSAGE = MESSAGE
xbee.transmit(TARGET_64BIT_ADDR, MESSAGE)
print("Data sent successfully")
except Exception as e:
print("Transmit failure: %s" % str(e))