Example: Update the XBee firmware synchronously using a Remote Manager Data File
To update the XBee firmware synchronously with Python 3.0, but using the device firmware image already uploaded to Remote Manager, upload the device's *.ebin firmware to Remote Manager:
- Download the updated firmware file for your device from Digi's support site. This is a zip file containing .ebin and .mxi files for import.
-
Unzip the file and locate the .ebin inside the unzipped directory.
-
Log in to Remote Manager.
- Click the Data Services tab.
- Click Data Files.
- Click Upload Files; browse and select the *.ebin firmware file to upload it.
- Send an HTTP SCI request to Remote manager with the path of the .ebin file; see the example below.
import base64
import requests
# Location of firmware image on Remote Manager
firmware_path = '~/XBXC.ebin'
# Remote Manager device ID of the device being updated
device_id = '00010000-00000000-03526130-70153378'
# Remote Manager username and password
username = "my_remote_manager_username"
password = "my_remote_manager_password"
url = 'https://remotemanager.digi.com/ws/sci'
# Form update_firmware request
data = """
<sci_request version="1.0">
<update_firmware filename="firmware.ebin">
<targets>
<device id="{}"/>
</targets>
<file>{}</file>
</update_firmware>
</sci_request>
""".format(device_id, firmware_path)
# Post request
r = requests.post(url, auth=(username, password), data=data)
if (r.status_code != 200) or ("error" in r.content.decode('utf-8')):
print("firmware update failed")
else:
print("firmware update success")