digidotcom / xbee-python

Python library to interact with Digi International's XBee radio frequency modules.
Mozilla Public License 2.0
185 stars 93 forks source link

Remote firmware update throws could not read device hardware version. #216

Closed csstudent321 closed 2 years ago

csstudent321 commented 3 years ago

When i tried firmware update to RemoteXBeeDevice throws could not read device hardware version.

and i cannot get a response from returns none remote_xbee.get_firmware_version() remote_xbee.get_hardware_version()

my code looks like:

SERIAL_PORT = "COM10"
BAUDRATE = 9600

TARGET_XBEE = "0013A20041C63024"

XML_FIRMWARE_FILE = "ota-firmware/XB3-24Z_100B-th.xml"
OTA_FIRMWARE_FILE = "ota-firmware/XB3-24Z_100B-th.ota"
OTB_FIRMWARE_FILE = "ota-firmware/XB3-24Z_100B-th.otb"

def main():
    local_xbee = XBeeDevice(SERIAL_PORT, BAUDRATE)
    try:
        local_xbee.open(force_settings=True)
        # Obtain the remote XBee device from the XBee network.
        remote_xbee = RemoteXBeeDevice(local_xbee, XBee64BitAddress.from_hex_string(TARGET_XBEE))
        print(remote_xbee.get_protocol())
        print(remote_xbee.get_firmware_version())
        # remote_xbee = xbee_network.discover_device(REMOTE_NODE_ID)
        if remote_xbee is None:
            print("Could not find the remote device")
            exit(1)

        print("Starting firmware update process...")
        remote_xbee.update_firmware(
                                    XML_FIRMWARE_FILE,
                                    xbee_firmware_file=OTA_FIRMWARE_FILE,
                                    bootloader_firmware_file=OTB_FIRMWARE_FILE,
                                    progress_callback=progress_callback)
        # update_remote_firmware(remote_xbee,
        #                        XML_FIRMWARE_FILE,
        #                        ota_firmware_file=OTA_FIRMWARE_FILE,
        #                        otb_firmware_file=OTB_FIRMWARE_FILE,
        #                        progress_callback=progress_callback)
        print("Firmware updated successfully!")
    except (XBeeException, FirmwareUpdateException, OperationNotSupportedException) as e:
        print("ERROR: %s" % str(e))
        exit(1)
    finally:
        if local_xbee is not None and local_xbee.is_open():
            local_xbee.close()

def progress_callback(str_calback, percent_calback):
    print(str_calback + " %" + str(percent_calback))

if __name__ == '__main__':
    main()

my output is :

raise ATCommandException(cmd_status=response.status)
digi.xbee.exception.ATCommandException: There was a problem sending the AT command packet.
ERROR: Could not read device hardware version
ERROR: Could not read device hardware version
tatianaleon commented 3 years ago

Hi @csstudent321 ,

We could update a remote node using your code above without problems. The instruction print(remote_xbee.get_firmware_version()) prints None since the remote is not initialized. See below.

Before running, ensure the remote node:

  1. is in the same network as the local one
  2. is not sleeping
# python test_216.py
XBeeProtocol.ZIGBEE
None
Starting firmware update process...
Preparing for update %0
Preparing for update %33
Preparing for update %66
Preparing for update %100
Updating remote XBee firmware %0
Updating remote XBee firmware %1
Updating remote XBee firmware %2
Updating remote XBee firmware %3
Updating remote XBee firmware %4
Updating remote XBee firmware %5
[...]
Updating remote XBee firmware %95
Updating remote XBee firmware %96
Updating remote XBee firmware %97
Updating remote XBee firmware %98
Updating remote XBee firmware %99
Updating remote XBee firmware %100
Restoring after update %0
Restoring after update %50
Restoring after update %100
Firmware updated successfully!

# 

Best Regards