Skip to content

Commit

Permalink
Merge pull request Hexxeh#2 from aleksandyr/master
Browse files Browse the repository at this point in the history
Unblock fix for failed app installations and reading Pebble ID from the environment
  • Loading branch information
PaulMcInnis committed Apr 13, 2013
2 parents 542218b + e9fc712 commit 2f6cc12
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Interact with your Pebble from OSX, Ubuntu or Debian operating systems.

## Warning and Complications

* Supported OS's are `OSX 10.8`, `Ubuntu`, `Debian`
* OS's which can utilize a faster Bluetooth library, Lightblue-0.4, are `OSX 10.8` and `Ubuntu`
* Detailed Lightblue-0.4 installation instructions for earlier version of OSX (10.6) and other OS's can be found [here](http://lightblue.sourceforge.net/#downloads)
* Supported OSes are `OSX 10.8`, `Ubuntu`, `Debian`
* OSes which can utilize a faster Bluetooth library, Lightblue-0.4, are `OSX 10.8` and `Ubuntu`
* Detailed Lightblue-0.4 installation instructions for earlier version of OSX (10.6) and other OSes can be found [here](http://lightblue.sourceforge.net/#downloads)


##1. Install Dependencies

All supported OS's will require `python 2.7` to operate libpebble. It can be installed [here](http://www.python.org/download/releases/2.7/)
All supported OSes will require `python 2.7` to operate libpebble. It can be installed [here](http://www.python.org/download/releases/2.7/)
* `Pyserial`will also be required, is can be installed via [pip](https://pypi.python.org/pypi/pip)

###a. OSX Additional Dependencies
Expand Down Expand Up @@ -68,6 +68,10 @@ When using libpebble on OSX, it is recommended that `--lightblue` be utilized.
where `00:11:22:33:44:55:66` is the Pebble's MAC Address, viewable on the Pebble from `settings`-->`about`
* You can obtain your pebble's MAC address after a successful connection in the libpebble stdout debug logs
* The `--pebble_id` can also be the 4 letter friendly name of your pebble but this will require that the Pebble is broadcasting.
* It is also possible to set the PEBBLE_ID environment variable as well:

export PEBBLE_ID="00:11:22:33:44:55:66"
./p.py --lightblue get_time

#####Using libpebble without --lightblue on OSX (MAY CAUSE KERNEL PANICS)

Expand Down
5 changes: 4 additions & 1 deletion p.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ def main():
if attempts > MAX_ATTEMPTS:
raise 'Could not connect to Pebble'
try:
pebble = libpebble.Pebble(args.pebble_id, args.lightblue, args.pair)
pebble_id = args.pebble_id
if pebble_id is None and "PEBBLE_ID" in os.environ:
pebble_id = os.environ["PEBBLE_ID"]
pebble = libpebble.Pebble(pebble_id, args.lightblue, args.pair)
break
except:
time.sleep(5)
Expand Down
16 changes: 11 additions & 5 deletions pebble/pebble.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,17 @@ def _appbank_status_response(self, endpoint, data):
offset = 9
for i in xrange(apps_installed):
app = {}
app["id"], app["index"], app["name"], app["company"], app["flags"], app["version"] = \
unpack("!II32s32sIH", data[offset:offset+appinfo_size])
app["name"] = app["name"].replace("\x00", "")
app["company"] = app["company"].replace("\x00", "")
apps["apps"] += [app]
try:
app["id"], app["index"], app["name"], app["company"], app["flags"], app["version"] = \
unpack("!II32s32sIH", data[offset:offset+appinfo_size])
app["name"] = app["name"].replace("\x00", "")
app["company"] = app["company"].replace("\x00", "")
apps["apps"] += [app]
except:
if offset+appinfo_size > len(data):
log.warn("Couldn't load bank %d; remaining data = %s" % (i,repr(data[offset:])))
else:
raise
offset += appinfo_size

return apps
Expand Down

0 comments on commit 2f6cc12

Please sign in to comment.