Skip to content

Latest commit

 

History

History
81 lines (57 loc) · 3.35 KB

transports.rst

File metadata and controls

81 lines (57 loc) · 3.35 KB

Transports

A transport represents a channel over which libpebble2 can communicate with a Pebble. Transports can also support sending and receiving messages not destined for the Pebble — for instance, the WebSocket transport can install a JavaScript app in the phone app. Two transports are currently provided, but it would be easy to add more.

Transports are usually only accessed directly by .PebbleConnection, but it can be useful to use them directly to interact with the transport instead of a Pebble. The transport can be accessed using the transport attribute of the .PebbleConnection.

The origin or destination of a message is indicated using a "message target". Messages to or from the watch use MessageTargetWatch; other transports may define additional targets of their own, which they can use to route messages elsewhere.

BaseTransport

.BaseTransport defines the functionality expected of any transport. All transports should inherit from .BaseTransport.

libpebble2.communication.transports.BaseTransport

libpebble2.communication.transports.MessageTargetWatch

libpebble2.communication.transports.MessageTarget

WebSocket transport

The WebSocket transport connects to a phone running the Pebble mobile app using the "Developer Connection", which exposes a WebSocket server on the phone. By default it runs on port 9000. :

>>> pebble = PebbleConnection(WebsocketTransport("ws://192.168.204:9000/"))

libpebble2.communication.transports.websocket.WebsocketTransport

libpebble2.communication.transports.websocket.MessageTargetPhone

QEMU transport

The QEMU transport connects to an instance of Pebble QEMU via Pebble QEMU Protocol. Note that, due to how QEMU is implemented, the watch will not necessarily notice connections or disconnections over this transport.

Messages directed at the emulator itself, rather than the firmware running on it, can be sent using .MessageTargetQemu. :

>>> pebble = PebbleConnection(QemuTransport("localhost", 12344))

libpebble2.communication.transports.qemu.QemuTransport

libpebble2.communication.transports.qemu.MessageTargetQemu

Serial transport

It is possible to connect directly to the Pebble using .SerialTransport. This transport uses the operating system's built-in Bluetooth serial support to communicate with the watch using pyserial. Using this transport requires the Pebble to already be paired with the computer. Recall that the Pebble may only connect to one device at a time; disconnect any connected phones (e.g. by disabling Bluetooth) before attempting to pair with your computer or use this transport.

Since this transport connects directly to the watch, it does not define any other message targets.

libpebble2.communication.transports.serial.SerialTransport