|
PebbleOS
|
Pebble Protocol sessions with the phone. More...
Modules | |
| App session capability cache | |
| Per-app cache of app session capabilities, persisted in a settings file. | |
| Default kernel sender | |
| Kernel-heap send buffers behind the session send buffer API. | |
| Meta endpoint | |
| Protocol error responses sent on the meta endpoint (ID 0). | |
| Pebble Protocol framing | |
| Pebble Protocol message header and size limits. | |
| Session analytics | |
| Connectivity analytics hooks for session open and close. | |
| Session internals | |
| Session state, for the session module and its transports. | |
| Receive router | |
| Inbound message parsing and dispatch to endpoint handlers. | |
| Remote OS | |
| Phone operating system reported in the platform bitfield. | |
| Remote version | |
| Phone version and capabilities exchange. | |
| Send buffers | |
| Build an outbound message piecemeal in a kernel-heap buffer. | |
| Send queue | |
| Per-session queue of outbound jobs, each holding complete messages. | |
| Transport interface | |
| Interface between sessions and the transports that carry them. | |
Macros | |
| #define | COMM_SESSION_DEFAULT_TIMEOUT (4000) |
| Default send timeout in milliseconds. | |
Functions | |
| bool | comm_session_has_capability (CommSession *session, CommSessionCapability capability) |
| Check whether a session supports a capability. | |
| CommSessionCapability | comm_session_get_capabilities (CommSession *session) |
| Get the capabilities of a session. | |
| CommSession * | comm_session_get_system_session (void) |
| Get the system (Pebble mobile app) session. | |
| CommSession * | comm_session_get_current_app_session (void) |
| Get the session serving the currently running watch app. | |
| void | comm_session_sanitize_app_session (CommSession **session_in_out) |
| Restrict a session to the one the current app is permitted to use. | |
| CommSessionType | comm_session_get_type (const CommSession *session) |
| Get the kind of a session. | |
| CommSession * | comm_session_get_by_type (CommSessionType type) |
| Get a session by kind. | |
| const Uuid * | comm_session_get_uuid (const CommSession *session) |
| Get the UUID of the app a session is connected to. | |
| bool | comm_session_is_system (CommSession *session) |
| Check whether a session is the system session. | |
| void | comm_session_reset (CommSession *session) |
| Reset a session by asking its transport to close and reopen it. | |
| bool | comm_session_send_data (CommSession *session, uint16_t endpoint_id, const uint8_t *data, size_t length, uint32_t timeout_ms) |
| Send a complete Pebble Protocol message. | |
| void | comm_session_set_responsiveness (CommSession *session, enum pbl_bt_consumer consumer, enum pbl_bt_response_time_state state, uint16_t max_period_secs) |
| Request a connection response time for a session. | |
| void | comm_session_set_responsiveness_ext (CommSession *session, enum pbl_bt_consumer consumer, enum pbl_bt_response_time_state state, uint16_t max_period_secs, pbl_bt_responsiveness_granted_cb_t granted_handler) |
| Request a connection response time for a session, with a granted callback. | |
| void | comm_session_init (void) |
| Initialize the session module. | |
Pebble Protocol sessions with the phone.
A session carries Pebble Protocol messages over a transport (iAP for iOS, plain SPP for Android, PPoGATT over BLE, QEMU, PULSE) and hides the differences between them.
There are two kinds of sessions:
Sessions may disconnect at any time: a CommSession pointer is only a handle, validated by every call. Outbound messages are queued per session and drained by the transport.
| #define COMM_SESSION_DEFAULT_TIMEOUT (4000) |
Default send timeout in milliseconds.
Protocol capabilities announced by the phone.
Bit positions match the fields of PebbleProtocolCapabilities.
| enum CommSessionType |
| CommSession * comm_session_get_by_type | ( | CommSessionType | type | ) |
Get a session by kind.
| type | Session type. CommSessionTypeApp returns the session of the currently running app. |
| CommSessionCapability comm_session_get_capabilities | ( | CommSession * | session | ) |
Get the capabilities of a session.
| session | Session to query. |
session is not valid. | CommSession * comm_session_get_current_app_session | ( | void | ) |
Get the session serving the currently running watch app.
For apps that use PebbleKit JS this is the system session. The session may disconnect at any time after this returns.
| CommSession * comm_session_get_system_session | ( | void | ) |
Get the system (Pebble mobile app) session.
The session may disconnect at any time after this returns.
| CommSessionType comm_session_get_type | ( | const CommSession * | session | ) |
Get the kind of a session.
| session | Session to query. |
session is not valid. | const Uuid * comm_session_get_uuid | ( | const CommSession * | session | ) |
Get the UUID of the app a session is connected to.
The caller must hold bt_lock() and stop using the pointer once it is released.
| session | Session to query. |
| bool comm_session_has_capability | ( | CommSession * | session, |
| CommSessionCapability | capability | ||
| ) |
Check whether a session supports a capability.
| session | Session to check. |
| capability | Capability to look for. |
session is valid and supports capability. | void comm_session_init | ( | void | ) |
Initialize the session module.
Called when Bluetooth is enabled; no session may exist yet.
| bool comm_session_is_system | ( | CommSession * | session | ) |
Check whether a session is the system session.
| session | Session to check. |
session is a valid system session. | void comm_session_reset | ( | CommSession * | session | ) |
Reset a session by asking its transport to close and reopen it.
With iAP this closes every session on the transport, since a single iAP session cannot be closed on its own.
| session | Session to reset. |
| void comm_session_sanitize_app_session | ( | CommSession ** | session_in_out | ) |
Restrict a session to the one the current app is permitted to use.
A NULL session selects the current app session. A non-NULL one is kept only if it is the current app session.
| [in,out] | session_in_out | Session to sanitize; set to NULL if not permitted or if no session is available. |
| bool comm_session_send_data | ( | CommSession * | session, |
| uint16_t | endpoint_id, | ||
| const uint8_t * | data, | ||
| size_t | length, | ||
| uint32_t | timeout_ms | ||
| ) |
Send a complete Pebble Protocol message.
Wraps comm_session_send_buffer_begin_write(), comm_session_send_buffer_write() and comm_session_send_buffer_end_write(), so the message is copied to the kernel heap. Use comm_session_send_queue_add_job() to avoid the copy, or the send buffer functions to build a message piecemeal. bt_lock() must not be held.
| session | Destination session. |
| endpoint_id | Pebble Protocol endpoint ID. |
| data | Message payload. |
| length | Length of data in bytes. |
| timeout_ms | Maximum time to block waiting for room in the send buffer. |
| void comm_session_set_responsiveness | ( | CommSession * | session, |
| enum pbl_bt_consumer | consumer, | ||
| enum pbl_bt_response_time_state | state, | ||
| uint16_t | max_period_secs | ||
| ) |
Request a connection response time for a session.
Same as comm_session_set_responsiveness_ext() without a granted callback.
| session | Session whose connection to adjust; ignored if not valid. |
| consumer | Consumer making the request. |
| state | Requested response time state. |
| max_period_secs | Maximum time to stay in state before falling back to the slowest response time. |
| void comm_session_set_responsiveness_ext | ( | CommSession * | session, |
| enum pbl_bt_consumer | consumer, | ||
| enum pbl_bt_response_time_state | state, | ||
| uint16_t | max_period_secs, | ||
| pbl_bt_responsiveness_granted_cb_t | granted_handler | ||
| ) |
Request a connection response time for a session, with a granted callback.
Forwarded to the transport, which applies it through the Bluetooth connection manager.
| session | Session whose connection to adjust; ignored if not valid. |
| consumer | Consumer making the request. |
| state | Requested response time state. |
| max_period_secs | Maximum time to stay in state before falling back to the slowest response time. |
| granted_handler | Called on KernelMain once a state at least as responsive as state is entered. May be NULL. |