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
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
Synchronously connect to the Pebble. Once this method returns, libpebble2 should be able to safely send messages to the connected Pebble.
Ordinarily, this method should only be called by
Trueif the transport is currently connected; otherwise
Trueif libpebble2 is responsible for negotiating the connection; otherwise
Synchronously read a message. This message could be from the Pebble(in which case it will be a
PebblePacket), or it could be from the transport, in which case the result is transport-defined. The origin of the result is indicated by the returned
Send a message. This message could be to the Pebble (in which case it must be a
PebblePacket), or to the transport (in which case the message type is transport-defined).
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/"))
Represents a connection via WebSocket to a phone running the Pebble mobile app, which is in turn connected to a Pebble over Bluetooth.
Parameters: url – The WebSocket URL to connect to, in standard format (e.g.
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
>>> pebble = PebbleConnection(QemuTransport("localhost", 12344))
Represents a connection to a Pebble QEMU instance.
Number of bytes read from the socket at a time.
Indicates that a message is directed at QEMU, rather than the firmware running on it. If
True, the message should be a binary message (without framing), with QEMU protocol indicated by
protocol. Otherwise, the message should be a
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.
Represents a direct connection to a physical Pebble paired to the computer via Bluetooth serial. This transport expects to be given a device file over which it can communicate with the watch via Bluetooth.
Using this transport may cause occasional kernel panics on some versions of OS X.
Parameters: device (str) – The path to the device file (on OS X, often of the form