Does XBee3 device need to be in REPL (AP=4) mode to transmit / receive stuffs

ok. thank you.

I have a

while xbee.atcmd(“AI”) != 0:
time.sleep(0.1)

at the top of the firmware file already…

ok… so
I upload the firmware code in ATAP=4. Consistently, when I press reset on the device… it auto-runs, sends to coordinator into python, I see what I expect. it works!

then I go in xctu, switch it to ATAP=1 (API mode). press reset on the device. nothing… no new NI, no python print outs. nothing.

then I go back into xctu, set back to REPL (ATAP=4). press reset on the device. works great again (I see whati want in the python print outs and the NI gets reassigned).

here is the code (micropython sample import… almost no changes) again, works in clearly does what I want it to in ATAP=4, then doesn’t cooperate once I switch ATAP=1… then back to working when I set ATAP back to 4.

code:


import sys
import xbee
import time

TODO: replace with the node identifier of your target device.

TARGET_NODE_ID = “COORD”
filler = “don’t mind me”

while xbee.atcmd(“AI”) != 0:
time.sleep(0.1)

def find_device(node_id):
“”"
Finds the XBee device with the given node identifier in the network and
returns it.

:param node_id: Node identifier of the XBee device to find.

:return: The XBee device with the given node identifier or ``None`` if it
    could not be found.
"""
for dev in xbee.discover():
    if dev['node_id'] == node_id:
        return dev
return None

Find the device with the configure node identifier.

device = find_device(TARGET_NODE_ID)
if not device:
print(“Could not find the device with node identifier ‘%s’” % TARGET_NODE_ID)
sys.exit(-1)

addr16 = device[‘sender_nwk’]
addr64 = device[‘sender_eui64’]

print(“Sending data to %s” % TARGET_NODE_ID)

micropython.mem_info([verbose])… SUPPOSE TO PRINT OUT how much memory is being used or something?

try:
# Some protocols do not have 16-bit address. In those cases, use the 64-bit one.
xbee.transmit(addr16 if addr16 else addr64, filler)
print(“Data sent successfully”)
except Exception as e:
print(“Transmit failure: %s” % str(e))


when you said “Also note that you could enable “join notifications” on the coordinator,” … the join notification sends a broadcast notification when from a node that just powered on / joined… so if I set that on the coordinator… maybe you meant to set that on the routers instead, yeah?

I want the router, once plugged in, to somehow get its MAC address to the coordinator/python program so that that router may be assigned a particular NI, depending on where you plugged it in physically.

but anyways, one problem at a time lol. as long as this router, in API mode, sends a message to the coordinator upon start-up… big success there. Again, works in ATAP=4, doesn’t work when change to ATAP=1, change back to ATAP=4 - works.

yeah I’ve sat here for the last 30 minutes…
python/micropython IDE(s) open, xctu open… start in ATAP=4 - press reset, message sends as confirmed in python console. click in xctu, ATAP set to = 1 - press reset on device… nothing… reset ATAP=4 - press reset on device, confirms to work as seen in python console… over back to xctu ATAP=4, then again ATAP=1, over and over for 30 minutes. doesn’t seem to work in ATAP=1 lol

but also I believe you so what am I doing wrong lol

so in xctu in the info drop down of the AP setting it says:

“The API mode setting. RF Packets received can be formatted into API frames to be sent out the serial port. When API is enabled the serial data must be formatted as API frames as transparent mode is disabled.”

could this be the problem?.. that the micropython code that I posted in a previous comment maybe doesn’t send the data in proper format (as API frames)?

hmm

hey mvut, I finally found in the micropython documentation where it mentions what modes micropython will run in. just wanted to update you on the matter.

from the micropython programming guide PDF:

“When you are done coding, exit MicroPython by closing the MicroPython terminal. Any code that has been executed will continue to run, even if the XBee device is set to Transparent or API mode.”

file:///C:/Users/edunn/Desktop/MicroPython_Guide.pdf

page 15

First commment is very helpful.