/_install_firmware.py Secret
Last active
January 15, 2017 07:23
-
-
Save jwise/724472cfe80f4bfed4072ca024a4ef12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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