|
PebbleOS
|
Typed key/value attributes describing timeline items and actions. More...
Data Structures | |
| struct | Uint32List |
| Variable-length list of 32-bit values. More... | |
| struct | Attribute |
| Attribute: an id and a value whose type depends on the id. More... | |
| struct | AttributeList |
| List of attributes. More... | |
| union | Attribute.__unnamed79__ |
| Value; the member matching the type of Attribute::id is valid. More... | |
Macros | |
| #define | ATTRIBUTE_ICON_LARGE_SIZE_PX 80 |
| Size of large icons, in pixels. | |
| #define | ATTRIBUTE_ICON_SMALL_SIZE_PX 50 |
| Size of small icons, in pixels. | |
| #define | ATTRIBUTE_ICON_TINY_SIZE_PX 25 |
| Size of tiny icons, in pixels. | |
| #define | ATTRIBUTE_TITLE_MAX_LEN 64 |
| Maximum length of a title, in bytes. | |
| #define | ATTRIBUTE_SUBTITLE_MAX_LEN 64 |
| Maximum length of a subtitle, in bytes. | |
| #define | ATTRIBUTE_APP_GLANCE_SUBTITLE_MAX_LEN (150) |
| Maximum length of an app glance subtitle template string, in bytes. | |
| #define | Uint32ListSize(num_values) (sizeof(Uint32List) + (num_values) * sizeof(uint32_t)) |
| Size in bytes of a Uint32List holding a number of values. | |
Functions | |
| void | attribute_init_string (Attribute *attribute, char *buffer, AttributeId attribute_id) |
| Initialize a string attribute. | |
| bool | attribute_copy (Attribute *dest, const Attribute *src, uint8_t **buffer, uint8_t *const buffer_end) |
| Deep copy an attribute, placing its string or list data in a buffer. | |
| bool | attribute_list_copy (AttributeList *out, const AttributeList *in, uint8_t *buffer, uint8_t *const buffer_end) |
| Deep copy an attribute list into one contiguous buffer. | |
| size_t | attribute_list_get_buffer_size (const AttributeList *list) |
| Get the size of a buffer holding a deep copy of an attribute list. | |
| size_t | attribute_list_get_string_buffer_size (const AttributeList *list) |
| Get the size of the string and list data of an attribute list. | |
| void | attribute_list_add_cstring (AttributeList *list, AttributeId id, const char *cstring) |
| Add a string attribute, or replace the value of an existing one. | |
| void | attribute_list_add_uint32 (AttributeList *list, AttributeId id, uint32_t uint32) |
| Add a uint32 attribute, or replace the value of an existing one. | |
| void | attribute_list_add_resource_id (AttributeList *list, AttributeId id, uint32_t resource_id) |
| Add a resource id attribute, or replace the value of an existing one. | |
| void | attribute_list_add_uint8 (AttributeList *list, AttributeId id, uint8_t uint8) |
| Add a uint8 attribute, or replace the value of an existing one. | |
| void | attribute_list_add_string_list (AttributeList *list, AttributeId id, struct pbl_string_list *string_list) |
| Add a string list attribute, or replace the value of an existing one. | |
| void | attribute_list_add_uint32_list (AttributeList *list, AttributeId id, Uint32List *uint32_list) |
| Add a Uint32List attribute, or replace the value of an existing one. | |
| void | attribute_list_add_attribute (AttributeList *list, const Attribute *new_attribute) |
| Add an attribute, or replace an existing one with the same id. | |
| void | attribute_list_init_list (uint8_t num_attributes, AttributeList *list_out) |
| Allocate a zeroed attribute list on the kernel heap. | |
| void | attribute_list_destroy_list (AttributeList *list) |
| Free the attributes array of a list. | |
| Attribute * | attribute_find (const AttributeList *attr_list, AttributeId id) |
| Find an attribute by id. | |
| const char * | attribute_get_string (const AttributeList *attr_list, AttributeId id, char *default_value) |
| Get a string attribute. | |
| struct pbl_string_list * | attribute_get_string_list (const AttributeList *attr_list, AttributeId id) |
| Get a string list attribute. | |
| uint8_t | attribute_get_uint8 (const AttributeList *attr_list, AttributeId id, uint8_t default_value) |
| Get a uint8 attribute. | |
| uint32_t | attribute_get_uint32 (const AttributeList *attr_list, AttributeId id, uint32_t default_value) |
| Get a uint32 or resource id attribute. | |
| Uint32List * | attribute_get_uint32_list (const AttributeList *attr_list, AttributeId id) |
| Get a Uint32List attribute. | |
| size_t | attribute_list_serialize (const AttributeList *attr_list, uint8_t *buffer, uint8_t *buf_end) |
| Serialize an attribute list. | |
| size_t | attribute_list_get_serialized_size (const AttributeList *attr_list) |
| Get the serialized size of an attribute list. | |
| bool | attribute_check_serialized_list (const uint8_t *cursor, const uint8_t *val_end, uint8_t num_attributes, bool has_attribute[]) |
| Check that a serialized attribute list is well formed and record which ids it contains. | |
| int32_t | attribute_get_buffer_size_for_serialized_attributes (uint8_t num_attributes, const uint8_t **cursor, const uint8_t *end) |
| Get the size of the buffer needed to deserialize attributes. | |
| bool | attribute_deserialize_list (char **buffer, char *const buf_end, const uint8_t **cursor, const uint8_t *payload_end, AttributeList *attr_list) |
| Deserialize attributes into an attribute list. | |
Typed key/value attributes describing timeline items and actions.
Each AttributeId has a fixed value type: a string, an 8- or 32-bit integer, a resource id, a string list or a Uint32List. The type is noted on each id; the matching Attribute member holds the value.
On the wire (BlobDB, Pebble Protocol) an attribute is a SerializedAttributeHeader followed by length bytes of value: strings without terminator, integers little endian, string lists as their serialized bytes and Uint32Lists as the struct. When deserializing, the title and subtitle are truncated to 64 bytes, the body and string lists to 512 bytes and the subtitle template string to 150 bytes. Attributes with an id this firmware does not know are skipped.
Building a list on the stack and reading it back:
| struct Uint32List |
| struct Attribute |
Attribute: an id and a value whose type depends on the id.
| Data Fields | ||
|---|---|---|
| union Attribute.__unnamed79__ | __unnamed__ | Value; the member matching the type of Attribute::id is valid. |
| AttributeId | id | Attribute id. |
| struct AttributeList |
List of attributes.
| Data Fields | ||
|---|---|---|
| Attribute * | attributes | Attributes. |
| uint8_t | num_attributes | Number of attributes. |
| union Attribute.__unnamed79__ |
Value; the member matching the type of Attribute::id is valid.
| Data Fields | ||
|---|---|---|
| char * | cstring | String value. |
| int16_t | int16 | Signed 16-bit value; no attribute currently uses it. |
| int32_t | int32 | Signed 32-bit value; no attribute currently uses it. |
| int8_t | int8 | Signed 8-bit value; no attribute currently uses it. |
| struct pbl_string_list * | string_list | String list value. |
| uint16_t | uint16 | 16-bit value; no attribute currently uses it. |
| uint32_t | uint32 | 32-bit or resource id value. |
| Uint32List * | uint32_list | Uint32List value. |
| uint8_t | uint8 | 8-bit value. |
| #define ATTRIBUTE_APP_GLANCE_SUBTITLE_MAX_LEN (150) |
Maximum length of an app glance subtitle template string, in bytes.
| #define ATTRIBUTE_ICON_LARGE_SIZE_PX 80 |
Size of large icons, in pixels.
| #define ATTRIBUTE_ICON_SMALL_SIZE_PX 50 |
Size of small icons, in pixels.
| #define ATTRIBUTE_ICON_TINY_SIZE_PX 25 |
Size of tiny icons, in pixels.
| #define ATTRIBUTE_SUBTITLE_MAX_LEN 64 |
Maximum length of a subtitle, in bytes.
| #define ATTRIBUTE_TITLE_MAX_LEN 64 |
Maximum length of a title, in bytes.
| #define Uint32ListSize | ( | num_values | ) | (sizeof(Uint32List) + (num_values) * sizeof(uint32_t)) |
Size in bytes of a Uint32List holding a number of values.
| num_values | Number of values. |
| enum AttributeId |
Attribute identifiers, as used on the wire.
| Enumerator | |
|---|---|
| AttributeIdUnused | Unused id; never matched by lookups. |
| AttributeIdTitle | (string) Title shown in a detailed view, at most 64 bytes. |
| AttributeIdSubtitle | (string) Auxiliary text shown under the title, at most 64 bytes. |
| AttributeIdBody | (string) Body text of the view, at most 512 bytes. |
| AttributeIdIconTiny | (resource id) Tiny icon, shown in the status bar or banner. |
| AttributeIdIconSmall | (resource id) Small icon, shown in the rendered view. |
| AttributeIdIconLarge | (resource id) Large icon, shown when actions are triggered. |
| AttributeIdAncsAction | (uint8) ANCS action id persisted in the actions of ANCS notifications. |
| AttributeIdCannedResponses | (string list) Canned responses offered by a reply action. |
| AttributeIdShortTitle | (string) Title shown in a list view. |
| AttributeIdIconPin | (resource id) Icon shown for the pin in the timeline. |
| AttributeIdLocationName | (string) Name of the location, in a broad sense, of the item. |
| AttributeIdSender | (string) Sender of a message, organizer of an event, etc. |
| AttributeIdLaunchCode | (uint32) Launch code passed to the app by an open watch app action. |
| AttributeIdLastUpdated | (uint32) Unix time the item was last updated, e.g. for weather. |
| AttributeIdRankAway | (string) Rank of the away team in the league. |
| AttributeIdRankHome | (string) Rank of the home team in the league. |
| AttributeIdNameAway | (string) Abbreviated name of the away team, at most 4 characters. |
| AttributeIdNameHome | (string) Abbreviated name of the home team, at most 4 characters. |
| AttributeIdRecordAway | (string) Record (wins and losses) of the away team. |
| AttributeIdRecordHome | (string) Record (wins and losses) of the home team. |
| AttributeIdScoreAway | (string) Current score of the away team, in game only. |
| AttributeIdScoreHome | (string) Current score of the home team, in game only. |
| AttributeIdSportsGameState | (uint8) GameState of a sports pin, selecting the pre-game or in-game view. |
| AttributeIdBroadcaster | (string) TV channel, radio station, website, etc. broadcasting the event. |
| AttributeIdHeadings | (string list) Section headings of a generic pin, paired with the paragraphs. |
| AttributeIdParagraphs | (string list) Section paragraphs of a generic pin, paired with the headings. |
| AttributeIdPrimaryColor | (uint8) Primary color of the source, as GColor8 ARGB. |
| AttributeIdBgColor | (uint8) Background color of the source, as GColor8 ARGB. |
| AttributeIdSecondaryColor | (uint8) Secondary color of the source, as GColor8 ARGB. |
| AttributeIdAppName | (string) Display name of the app the notification originates from. |
| AttributeIdDisplayRecurring | (uint8) CalendarRecurringType of a calendar event. |
| AttributeIdiOSAppIdentifier | (string) iOS app identifier, e.g. com.apple.MobileSMS. |
| AttributeIdEmojiSupported | (uint8) Whether a reply action offers emoji; emoji are offered when absent. |
| AttributeIdAncsId | (uint32) ANCS UID of the item or action, when the parent id links to another item. |
| AttributeIdHealthInsightType | (uint8) Health insight the item comes from. |
| AttributeIdShortSubtitle | (string) Subtitle shown in a list view. |
| AttributeIdTimestamp | (uint32) ANCS timestamp of the notification, seconds since the epoch. |
| AttributeIdDisplayTime | (uint8) WeatherTimeType: which time, if any, a weather pin shows. |
| AttributeIdAddress | (string) Phone number, email address or other handle of a contact. |
| AttributeIdMuteDayOfWeek | (uint8) MuteBitfield of the days on which an app's notifications are muted. |
| AttributeIdMetricNames | (string list) Metric names of a pin. |
| AttributeIdMetricValues | (string list) Metric values of a pin. |
| AttributeIdMetricIcons | (Uint32List) Metric icons, as TimelineResourceId. |
| AttributeIdHealthActivityType | (uint8) Health activity the item comes from. |
| AttributeIdAlarmKind | (uint8) AlarmKind of an alarm pin. |
| AttributeIdAuthCode | (string) Authentication code, e.g. the Nexmo SMS check-in code. |
| AttributeIdSubtitleTemplateString | (string) Template string shown under a title (app glances), at most 150 bytes. |
| AttributeIdIcon | (resource id) Generic icon. |
| AttributeIdVibrationPattern | (Uint32List) Custom vibration pattern, as passed to vibes_enqueue_custom_pattern(). |
| AttributeIdMuteExpiration | (uint32) Unix time at which an app's mute expires. |
| AttributeIdNotificationFilteringRules | (string list) Notification filtering rules of an app, as bytes: a rule count, then for each rule its match type, match field and case sensitivity bytes and a NUL-terminated pattern. |
| AttributeIdImageAspectRatio | (uint8) The phone holds an image for this item, fetchable over the imaging endpoint keyed by the item's UUID. The value is the image's height/width in sixteenths, so the card can reserve a band of the right shape before the pixels arrive. Absent or 0 means no image. |
| AttributeIdWeatherPinKind | (uint8) WeatherPinKind of a weather pin. |
| NumAttributeIds | Number of attribute ids. |
| bool attribute_check_serialized_list | ( | const uint8_t * | cursor, |
| const uint8_t * | val_end, | ||
| uint8_t | num_attributes, | ||
| bool | has_attribute[] | ||
| ) |
Check that a serialized attribute list is well formed and record which ids it contains.
| cursor | Start of the serialized attributes. | |
| val_end | End of the data. | |
| num_attributes | Number of serialized attributes. | |
| [out] | has_attribute | Array of NumAttributeIds flags, indexed by id; set for each known id found. |
| bool attribute_copy | ( | Attribute * | dest, |
| const Attribute * | src, | ||
| uint8_t ** | buffer, | ||
| uint8_t *const | buffer_end | ||
| ) |
Deep copy an attribute, placing its string or list data in a buffer.
| [out] | dest | Destination attribute. |
| src | Source attribute. | |
| [in,out] | buffer | Pointer to free memory for the data; advanced past what was used. |
| buffer_end | End of the buffer. |
| bool attribute_deserialize_list | ( | char ** | buffer, |
| char *const | buf_end, | ||
| const uint8_t ** | cursor, | ||
| const uint8_t * | payload_end, | ||
| AttributeList * | attr_list | ||
| ) |
Deserialize attributes into an attribute list.
Attributes with an id this firmware does not know are skipped, and attr_list->num_attributes is updated to the number actually stored.
| [in,out] | buffer | Buffer for string and list data; advanced past what was used. |
| buf_end | End of the buffer. | |
| [in,out] | cursor | Start of the serialized attributes; advanced past them. |
| payload_end | End of the serialized data. | |
| [in,out] | attr_list | List with num_attributes set to the serialized count and room for that many attributes. |
| Attribute * attribute_find | ( | const AttributeList * | attr_list, |
| AttributeId | id | ||
| ) |
| int32_t attribute_get_buffer_size_for_serialized_attributes | ( | uint8_t | num_attributes, |
| const uint8_t ** | cursor, | ||
| const uint8_t * | end | ||
| ) |
Get the size of the buffer needed to deserialize attributes.
| num_attributes | Number of serialized attributes. | |
| [in,out] | cursor | Start of the serialized attributes; advanced past them. |
| end | End of the data. |
| const char * attribute_get_string | ( | const AttributeList * | attr_list, |
| AttributeId | id, | ||
| char * | default_value | ||
| ) |
| struct pbl_string_list * attribute_get_string_list | ( | const AttributeList * | attr_list, |
| AttributeId | id | ||
| ) |
| uint32_t attribute_get_uint32 | ( | const AttributeList * | attr_list, |
| AttributeId | id, | ||
| uint32_t | default_value | ||
| ) |
| Uint32List * attribute_get_uint32_list | ( | const AttributeList * | attr_list, |
| AttributeId | id | ||
| ) |
Get a Uint32List attribute.
Asserts if id is not a Uint32List attribute.
| uint8_t attribute_get_uint8 | ( | const AttributeList * | attr_list, |
| AttributeId | id, | ||
| uint8_t | default_value | ||
| ) |
| void attribute_init_string | ( | Attribute * | attribute, |
| char * | buffer, | ||
| AttributeId | attribute_id | ||
| ) |
| void attribute_list_add_attribute | ( | AttributeList * | list, |
| const Attribute * | new_attribute | ||
| ) |
| void attribute_list_add_cstring | ( | AttributeList * | list, |
| AttributeId | id, | ||
| const char * | cstring | ||
| ) |
Add a string attribute, or replace the value of an existing one.
The list grows on the kernel heap. The string is not copied, so it must stay valid until the list is copied or added to a timeline item.
| list | Attribute list. |
| id | String attribute id, e.g. Title, Subtitle or Body. |
| cstring | String value. |
| void attribute_list_add_resource_id | ( | AttributeList * | list, |
| AttributeId | id, | ||
| uint32_t | resource_id | ||
| ) |
Add a resource id attribute, or replace the value of an existing one.
| list | Attribute list. |
| id | Icon attribute id. |
| resource_id | Timeline resource id. |
| void attribute_list_add_string_list | ( | AttributeList * | list, |
| AttributeId | id, | ||
| struct pbl_string_list * | string_list | ||
| ) |
Add a string list attribute, or replace the value of an existing one.
The list is not copied, so it must stay valid until the attribute list is copied or added to a timeline item. Asserts if id is not a string list attribute.
| list | Attribute list. |
| id | String list attribute id, e.g. Headings or Paragraphs. |
| string_list | Value. |
| void attribute_list_add_uint32 | ( | AttributeList * | list, |
| AttributeId | id, | ||
| uint32_t | uint32 | ||
| ) |
Add a uint32 attribute, or replace the value of an existing one.
| list | Attribute list. |
| id | uint32 attribute id. |
| uint32 | Value. |
| void attribute_list_add_uint32_list | ( | AttributeList * | list, |
| AttributeId | id, | ||
| Uint32List * | uint32_list | ||
| ) |
Add a Uint32List attribute, or replace the value of an existing one.
The list is not copied, so it must stay valid until the attribute list is copied or added to a timeline item. Asserts if id is not a Uint32List attribute.
| list | Attribute list. |
| id | Uint32List attribute id, e.g. MetricIcons. |
| uint32_list | Value. |
| void attribute_list_add_uint8 | ( | AttributeList * | list, |
| AttributeId | id, | ||
| uint8_t | uint8 | ||
| ) |
Add a uint8 attribute, or replace the value of an existing one.
| list | Attribute list. |
| id | uint8 attribute id. |
| uint8 | Value. |
| bool attribute_list_copy | ( | AttributeList * | out, |
| const AttributeList * | in, | ||
| uint8_t * | buffer, | ||
| uint8_t *const | buffer_end | ||
| ) |
Deep copy an attribute list into one contiguous buffer.
| [out] | out | Destination list; its attributes and data live in buffer. |
| in | Source list. | |
| buffer | Buffer of at least attribute_list_get_buffer_size() of in bytes. | |
| buffer_end | End of the buffer. |
| void attribute_list_destroy_list | ( | AttributeList * | list | ) |
Free the attributes array of a list.
Only for lists built with attribute_list_add_ or attribute_list_init_list(), not for copies made with attribute_list_copy(). Values are not freed.
| list | Attribute list. |
| size_t attribute_list_get_buffer_size | ( | const AttributeList * | list | ) |
Get the size of a buffer holding a deep copy of an attribute list.
| list | Attribute list. |
| size_t attribute_list_get_serialized_size | ( | const AttributeList * | attr_list | ) |
Get the serialized size of an attribute list.
| attr_list | Attribute list, may be NULL. |
| size_t attribute_list_get_string_buffer_size | ( | const AttributeList * | list | ) |
Get the size of the string and list data of an attribute list.
| list | Attribute list. |
| void attribute_list_init_list | ( | uint8_t | num_attributes, |
| AttributeList * | list_out | ||
| ) |
Allocate a zeroed attribute list on the kernel heap.
The attributes start as AttributeIdUnused; fill them in place. The attribute_list_add_ functions append after them.
| num_attributes | Number of attributes. | |
| [out] | list_out | List to initialize. |
| size_t attribute_list_serialize | ( | const AttributeList * | attr_list, |
| uint8_t * | buffer, | ||
| uint8_t * | buf_end | ||
| ) |
Serialize an attribute list.
| attr_list | Attribute list. | |
| [out] | buffer | Output buffer of at least attribute_list_get_serialized_size() bytes. |
| buf_end | End of the buffer. |