Skip to content

Instantly share code, notes, and snippets.

@jwise
Forked from Katharine/_install_firmware.py
Last active January 15, 2017 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwise/724472cfe80f4bfed4072ca024a4ef12 to your computer and use it in GitHub Desktop.
Save jwise/724472cfe80f4bfed4072ca024a4ef12 to your computer and use it in GitHub Desktop.
from libpebble2.protocol.system import SystemMessage
from libpebble2.services.putbytes import PutBytes, PutBytesType
from libpebble2.util.bundle import PebbleBundle
def _install_firmware(pebble, pbz_path):
pebble.send_and_read(SystemMessage(message_type=SystemMessage.Type.FirmwareUpdateStart), SystemMessage)
bundle = PebbleBundle(pbz_path)
firmware_bytes = bundle.zip.read(bundle.get_firmware_info()["name"])
pb = PutBytes(pebble, PutBytesType.Firmware, firmware_bytes, bank=0)
pb.send()
resource_bytes = bundle.zip.read(bundle.get_resource_path())
pb = PutBytes(pebble, PutBytesType.SystemResources, resource_bytes, bank=0)
pb.send()
pebble.send_packet(SystemMessage(message_type=SystemMessage.Type.FirmwareUpdateComplete))
def installmini(pebble, fw):
pebble.send_and_read(SystemMessage(message_type=SystemMessage.Type.FirmwareUpdateStart), SystemMessage)
bytes = open(fw, 'rb').read()
pb = PutBytes(pebble, PutBytesType.Firmware, bytes, bank=0)
pb.send()
bytes = open('system_resources.minipbpack', 'rb').read()
pb = PutBytes(pebble, PutBytesType.SystemResources, bytes, bank=0)
pb.send()
pebble.send_packet(SystemMessage(message_type=SystemMessage.Type.FirmwareUpdateComplete))
def installmini(pebble, fw):
pebble.send_and_read(SystemMessage(message_type=SystemMessage.Type.FirmwareUpdateStart), SystemMessage)
bytes = open(fw, 'rb').read()
pb = PutBytes(pebble, PutBytesType.Firmware, bytes, bank=0)
pb.send()
bytes = open('system_resources.minipbpack', 'rb').read()
pb = PutBytes(pebble, PutBytesType.SystemResources, bytes, bank=0)
pb.send()
pebble.send_packet(SystemMessage(message_type=SystemMessage.Type.FirmwareUpdateComplete))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment