|
| file | src/c/pebble/io/appmessage/appmessage.c |
| | AppMessage transport: weather requests out, settings + readings in. Decodes the wire format and hands results to the app through handlers, so it never reaches into the UI itself.
|
| file | src/c/pebble/io/appmessage/appmessage.h |
| | AppMessage transport. Decodes the inbox and notifies the app through per-channel handlers, and queues the outbound weather, stock, and calendar requests through one outbox.
|
| file | src/c/pebble/io/appmessage/appmessage_features.h |
| | Which of the phone's optional features a face has, worked out from the message keys it declares. The waf build defines a HAS_MESSAGE_KEY_* for every key in the face's messageKeys, and this turns those into one switch per feature, so every file asking the same question gets the same answer.
|
| file | src/c/pebble/io/outbox_queue.h |
| | The outbox's work queue, its failed set, and the slot holding whatever is in flight.
|
| file | src/c/pebble/io/tuple_read.c |
| | Reads a value out of an inbound message tuple.
|
| file | src/c/pebble/io/tuple_read.h |
| | Reads a value out of an inbound message tuple.
|
|
| typedef void(*) | WeatherHandler(const WeatherMessage *msg) |
| | Called with one weather message, holding every group of readings it carried.
|
| typedef void(*) | CoordsHandler(const char *lat, const char *lon) |
| | Called with a fresh pair of coordinates.
|
| typedef void(*) | SettingsChangedHandler(bool time_or_date_changed) |
| | Called after a settings save that changed something.
|
| typedef void(*) | UnitChangedHandler(bool fahrenheit) |
| | Called when the wearer switches the temperature unit on the settings page.
|
| typedef void(*) | StockStripHandler(const uint8_t *buf, uint16_t len) |
| | Called with a packed watchlist strip. The handler owns the wire format.
|
| typedef void(*) | CalendarStripHandler(const uint8_t *buf, uint16_t len) |
| | Called with a packed agenda strip. The store owns the wire format.
|
| typedef void(*) | CustomColorsHandler(const char *combined) |
| | Called inbound with the combined custom-colours string, for the face to split and store.
|
| typedef void(*) | CustomColorsProvider(char *out, size_t n) |
| | Called outbound to rebuild the combined custom-colours string before a settings reply is sent.
|
| typedef void(*) | InboxCompleteHandler(void) |
| | Called once after every inbox message is fully handled.
|
|
|
void | appmessage_on_weather (WeatherHandler cb) |
| | One weather message, every group it carried.
|
|
void | appmessage_on_coords (CoordsHandler cb) |
| | Latitude and longitude.
|
|
void | appmessage_on_settings_changed (SettingsChangedHandler cb) |
| | A setting changed on the phone.
|
|
void | appmessage_on_unit_changed (UnitChangedHandler cb) |
| | The wearer switched the temperature unit.
|
|
void | appmessage_on_stock_strip (StockStripHandler cb) |
| | Packed watchlist strip.
|
|
void | appmessage_on_calendar_strip (CalendarStripHandler cb) |
| | Packed agenda strip.
|
|
void | appmessage_on_custom_colors (CustomColorsHandler cb) |
| | Inbound: splits and stores the combined string.
|
|
void | appmessage_set_custom_colors_provider (CustomColorsProvider cb) |
| | Outbound: rebuilds the combined string.
|
| void | appmessage_add_inbox_complete (InboxCompleteHandler cb) |
| | Adds work to run once after a whole inbound message is handled, after every channel in it.
|
| void | appmessage_open (uint32_t inbox_size) |
| | Register the SDK callbacks and open the inbox and outbox.
|
|
void | appmessage_request_weather (void) |
| | Asks the phone for a fresh weather reading. The weather store calls this on its turn on the shared cadence. On a face that does not declare the weather keys it sends nothing and logs one warning the first time it is called. The weather keys are WEATHER_REQUEST, WEATHER_TEMPERATURE, WEATHER_CONDITIONS, and WEATHER_OK, and a face that declares only some of them fails to build, with each missing one named.
|
|
void | appmessage_request_stock (void) |
| | Asks the phone for fresh quotes. The stock store calls this on its turn on the shared cadence. Does nothing on faces that do not declare the stock keys.
|
|
void | appmessage_request_calendar (void) |
| | Asks the phone for a fresh agenda. The calendar store calls this on its turn on the shared cadence. Does nothing on faces that do not declare the calendar keys.
|
| static bool | outbox_busy (const OutboxQueue *outbox) |
| | Whether anything is in flight, which is what says the outbox is busy.
|
| static bool | outbox_pending (const OutboxQueue *outbox, OutboxKind kind) |
| | Whether this kind is already somewhere in the outbox.
|
| static bool | outbox_push (OutboxQueue *outbox, OutboxKind kind, int retries) |
| | Add a job to the work queue unless its kind is already pending.
|
| static void | outbox_pop_front (OutboxQueue *outbox) |
| | Drop the front job off the work queue, shifting the rest forward.
|
| static void | outbox_take_head (OutboxQueue *outbox) |
| | Take the head of the queue as the job now in flight.
|
| static OutboxJob | outbox_release (OutboxQueue *outbox) |
| | Mark whatever was in flight as settled, whichever way it went.
|
| static void | outbox_hold_failed (OutboxQueue *outbox, OutboxJob job) |
| | Hold a nacked job for the next pass, if it still has retries.
|
| static int | outbox_retry_pass (OutboxQueue *outbox) |
| | Move the whole failed set back into the work queue for another pass.
|
| static void | outbox_clear (OutboxQueue *outbox) |
| | Forget everything waiting, for a phone that is no longer there.
|
| int32_t | tuple_int_or (const Tuple *tuple, int32_t fallback) |
| | Reads an int tuple, whatever width the phone sent it at.
|
| const char * | tuple_str_or (const Tuple *tuple, const char *fallback) |
| | Reads a cstring tuple, or the fallback when it is not one that can be read.
|
The AppMessage pipeline to the phone and the byte readers behind it.
The stores use the byte readers to unpack the packed strips the phone sends.
| void appmessage_open |
( |
uint32_t | inbox_size | ) |
|
Register the SDK callbacks and open the inbox and outbox.
Call after settings_init and after the channel handlers are installed. The outbox is sized from the face's settings table, counting every string at its full buffer, so it needs nothing from the face.
The inbox is the face's to size, because the biggest message in is the settings page's save and Clay sends every message key in it, including ones the watch never reads. Add up the longest value each key on the settings page can hold plus 7 bytes of header per key, and leave some room over. A message bigger than the inbox is dropped whole and logged with its reason, so a settings save that never lands is the sign the number is too small.
- Parameters
-
| inbox_size | The inbox buffer in bytes. Anything over the platform maximum opens at the maximum. |