From 4777457a89b571f0b7aa3c109c70cb4a6863276a Mon Sep 17 00:00:00 2001 From: Martijn The Date: Tue, 26 Mar 2013 17:24:42 -0700 Subject: [PATCH 1/3] - Missing re import - 20 sec timout is too short when pairing - Fixed typo --- pebble/LightBlueSerial.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pebble/LightBlueSerial.py b/pebble/LightBlueSerial.py index 80d2231..8857bb9 100755 --- a/pebble/LightBlueSerial.py +++ b/pebble/LightBlueSerial.py @@ -2,8 +2,9 @@ import logging import multiprocessing import Queue -import time +import re import socket +import time from multiprocessing import Process from struct import pack, unpack @@ -20,7 +21,7 @@ def __str__(self): return "%s ID:(%s) on LightBlue API" % (self._message, self._id) class LightBlueSerial(object): - def __init__(self, id, should_pair, debug_protocol=True, connection_process_timeout=20): + def __init__(self, id, should_pair, debug_protocol=True, connection_process_timeout=60): self.mac_address = id self.debug_protocol = debug_protocol @@ -107,7 +108,7 @@ def autodetect(self): self.mac_address = autodetect(self) # create the bluetooth socket from the mac address - if self.should_pair and mac_address is not None: + if self.should_pair and self.mac_address is not None: pair(self.mac_address) try: self._bts = lb_socket() From 426a79a20a197da7baa1951e7eae7f9965c03fd9 Mon Sep 17 00:00:00 2001 From: Martijn The Date: Tue, 26 Mar 2013 17:25:17 -0700 Subject: [PATCH 2/3] non-editable dependency for lightblue in requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0b53c7f..7533b4a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ pyserial>=2.6 --e git://github.com/pebble/lightblue-0.4.git#egg=lightblue-0.4 +git+http://github.com/pebble/lightblue-0.4.git#egg=lightblue-0.4 From 34e939b9d2e73d5d1cd66559d828c78978c441ff Mon Sep 17 00:00:00 2001 From: Martijn The Date: Tue, 26 Mar 2013 18:41:46 -0700 Subject: [PATCH 3/3] Added "remove_app_by_uuid" function to libpebble / p.py --- p.py | 22 +++++++++++++++++----- pebble/pebble.py | 7 +++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/p.py b/p.py index 27fa70f..8ac879e 100755 --- a/p.py +++ b/p.py @@ -72,12 +72,24 @@ def cmd_list_apps(pebble, args): print '[{}] {}'.format(app['index'], app['name']) def cmd_rm_app(pebble, args): - for app in pebble.get_appbank_status()['apps']: - if app['index'] == args.app_index: - pebble.remove_app(app["id"], app["index"]) - + try: + uuid = args.app_index_or_hex_uuid.decode('hex') + if len(uuid) == 16: + pebble.remove_app_by_uuid(uuid) print 'removed app' return + except: + pass + try: + idx = int(args.app_index_or_hex_uuid) + for app in pebble.get_appbank_status()['apps']: + if app['index'] == idx: + pebble.remove_app(app["id"], app["index"]) + print 'removed app' + return + except: + print 'Invalid arguments. Use bank index or hex app UUID (16 bytes / 32 hex digits)' + pass def cmd_reset(pebble, args): pebble.reset() @@ -123,7 +135,7 @@ def main(): list_apps_parser.set_defaults(func=cmd_list_apps) rm_app_parser = subparsers.add_parser('rm', help='remove installed apps') - rm_app_parser.add_argument('app_index', metavar='IDX', type=int, help='the app index to delete') + rm_app_parser.add_argument('app_index_or_hex_uuid', metavar='IDX or UUID', type=str, help='the app index or UUID to delete') rm_app_parser.set_defaults(func=cmd_rm_app) reset_parser = subparsers.add_parser('reset', help='reset the watch remotely') diff --git a/pebble/pebble.py b/pebble/pebble.py index b64c6d3..e09ee47 100755 --- a/pebble/pebble.py +++ b/pebble/pebble.py @@ -312,6 +312,13 @@ def remove_app(self, appid, index): data = pack("!bII", 2, appid, index) self._send_message("APP_MANAGER", data) + def remove_app_by_uuid(self, uuid): + + """Remove an installed application by UUID.""" + + data = pack("b", 0x02) + uuid + self._send_message("APP_MANAGER", data) + def get_time(self, async = False): """Retrieve the time from the Pebble's RTC."""