Skip to content

Instantly share code, notes, and snippets.

@Katharine
Created December 10, 2016 06:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Katharine/af69eff12b7ccff6990d25ba8b299d2b to your computer and use it in GitHub Desktop.
Save Katharine/af69eff12b7ccff6990d25ba8b299d2b 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment