Example: Update the XBee .gbl firmware synchronously with Python 3.0
import base64
import requests
firmware_path = 'XBXC.gbl'
device_id = '00010000-00000000-03526130-70153378'
username = "my_Remote_manager_username"
password = "my_remote_manager_password"
url = 'https://remotemanager.digi.com/ws/sci'
fw_file = open(firmware_path, 'rb')
fw_data = fw_file.read()
fw_data = base64.encodebytes(fw_data).decode('utf-8')
data = """
<sci_request version="1.0">
<update_firmware filename="firmware.gbl">
<targets>
<device id="{}"/>
</targets>
<data>{}</data>
</update_firmware>
</sci_request>
""".format(device_id, fw_data)
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")