-
Notifications
You must be signed in to change notification settings - Fork 94
Description
Hello,
I am using an XBee3 radio (FW: 1014) as a coordinator to communicate with some sleepy end-devices. The coordinator code is shown below.
The issue I am having only occurs when I send a command to an end device that is asleep... I feel like there is something simple I am missing here, but when I send the AT command to the sleepy device, the radio fails to respond to anything else for a period of 90 seconds. After that time, it goes back to working normally.
In the logs below, I wake my sleepy end-device up at 12:00:15 and let it fall asleep at 12:01:15.
As you can see, the AT command sent at 12:01:31 is sent async. It is my expectation that this does not receive a response.
However, all my subsequent requests sent to the coordinator for the next 90 seconds time out...
Logs
2025-11-06 12:00:06 INFO [test.main]: Opening XBee connection...
2025-11-06 12:00:06 INFO [devices.open]: XBeeSerialPort 'COM11' port opened
2025-11-06 12:00:06 INFO [test.main]: Successfully connected to XBee
2025-11-06 12:00:06 INFO [test.main]: Sync Ops Timeout: 4
2025-11-06 12:00:06 INFO [test.main]: ////////////////////////////////////////////////////////////
2025-11-06 12:00:06 INFO [test.main]: Scanning Network...
2025-11-06 12:00:06 INFO [devices.start_discovery_process]: Start network discovery for '0013A20041E041C8 - EDGE RA' (1 scans)
2025-11-06 12:00:13 INFO [devices.__discover_devices_and_notify_callbacks]: End network discovery for '0013A20041E041C8 - EDGE RA'
2025-11-06 12:00:13 INFO [test.main]: -----------------------------
2025-11-06 12:00:13 INFO [test.main]: Looping for approximately 30 seconds before scanning again...
2025-11-06 12:00:43 INFO [test.main]: ////////////////////////////////////////////////////////////
2025-11-06 12:00:43 INFO [test.main]: Scanning Network...
2025-11-06 12:00:43 INFO [devices.start_discovery_process]: Start network discovery for '0013A20041E041C8 - EDGE RA' (1 scans)
2025-11-06 12:00:49 INFO [devices.__discover_devices_and_notify_callbacks]: End network discovery for '0013A20041E041C8 - EDGE RA'
2025-11-06 12:00:50 INFO [test.get_active_device_list]: >>> Device Found: 0013A200420BA653 - MYDEV
2025-11-06 12:00:50 INFO [test.get_active_device_list]: Sending AT command to read radio version...
2025-11-06 12:00:50 INFO [test.main]: -----------------------------
2025-11-06 12:00:50 INFO [test.main]: Looping for approximately 30 seconds before scanning again...
2025-11-06 12:01:20 INFO [test.main]: ////////////////////////////////////////////////////////////
2025-11-06 12:01:20 INFO [test.main]: Scanning Network...
2025-11-06 12:01:20 INFO [devices.start_discovery_process]: Start network discovery for '0013A20041E041C8 - EDGE RA' (1 scans)
2025-11-06 12:01:30 INFO [devices.__discover_devices_and_notify_callbacks]: End network discovery for '0013A20041E041C8 - EDGE RA'
2025-11-06 12:01:31 INFO [test.get_active_device_list]: >>> Device Found: 0013A200420BA653 - MYDEV
2025-11-06 12:01:31 INFO [test.get_active_device_list]: Sending AT command to read radio version...
2025-11-06 12:01:31 INFO [test.main]: -----------------------------
2025-11-06 12:01:31 INFO [test.main]: Looping for approximately 30 seconds before scanning again...
2025-11-06 12:01:35 INFO [test.main]: XBee is not responsive: Response not received in the configured timeout.
2025-11-06 12:03:01 INFO [test.main]: XBee is responsive again!
2025-11-06 12:03:13 INFO [test.main]: ////////////////////////////////////////////////////////////
Code
import time
import binascii
from collections import OrderedDict
from typing import List
from digi.xbee.devices import XBeeDevice, RemoteZigBeeDevice
from digi.xbee.packets.common import RemoteATCommandPacket
import logging
PORT = "COM11"
XBEE = XBeeDevice(port=PORT, baud_rate=115200)
logger = logging.getLogger(__name__)
# Configure console logging
if not logging.getLogger().handlers:
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)8s [%(module)s.%(funcName)s]: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
def get_capacity() -> int:
capacity = XBEE.get_parameter(parameter='NC')
dec_cap = int.from_bytes(capacity, 'big')
return dec_cap
def get_active_device_list() -> List[dict[str, str | bool | None]]:
global XBEE
response = []
try:
network = XBEE.get_network()
network.start_discovery_process(deep=True, n_deep_scans=1)
while network.is_discovery_running():
time.sleep(0.5)
xbee_devices: List[RemoteZigBeeDevice] = network.get_devices()
for device in xbee_devices:
logger.info(" >>> Device Found: %s" % device)
try:
logger.info(" Sending AT command to read radio version...")
at_command = RemoteATCommandPacket(1, device.get_64bit_addr(), device.get_16bit_addr(),2, "VR")
XBEE.send_packet(at_command, sync=False)
except Exception as err:
logger.info(" Failed to send AT command to device [%s]. Details: %s" % (device,err))
radio_version = device.get_firmware_version()
if radio_version is not None:
radio_version = str(binascii.hexlify(radio_version).decode('utf-8'))
else:
radio_version = "UNKNOWN"
device_object: OrderedDict[str, str | bool | None] = OrderedDict([
("node_id", str(device.get_node_id())),
("network_address", str(device.get_16bit_addr())),
("extended_address", str(device.get_64bit_addr())),
("type", str(device.get_role()).replace("Role.", "")),
("radio_version", radio_version)
])
response.append(device_object)
except Exception as err:
logger.info("Failed to get device list: %s" % err)
return response
def main():
try:
logger.info("Opening XBee connection...")
XBEE.open()
except Exception as e:
logger.info("Failed to connect... " + str(e))
if XBEE.is_open():
logger.info("Successfully connected to XBee")
logger.info("Sync Ops Timeout: %s" % XBEE.get_sync_ops_timeout())
system_responsive = True
while True:
try:
logger.info("////////////////////////////////////////////////////////////")
logger.info("Scanning Network...")
get_active_device_list()
except Exception as e:
logger.info("Failure occurred in network scan. Details: " + str(e))
logger.info("-----------------------------")
logger.info("Looping for approximately 30 seconds before scanning again...")
for i in range(30):
try:
get_capacity()
if not system_responsive:
logger.info("XBee is responsive again!")
system_responsive = True
except Exception as e:
if system_responsive:
logger.info("XBee is not responsive: %s" %e)
system_responsive = False
time.sleep(1)
if __name__ == "__main__":
main()