Pebble-LE C API
Functions
-
void pebble_le_connect()
Connects to a nearby Pebble Watch via Bluetooth LE.
Performs bluetooth pairing if necessary.
-
void pebble_le_connect_with_bt_addr(const char *bt_addr)
Connects to a specific Pebble Watch via Bluetooth LE given its bluetooth address.
Performs bluetooth pairing if necessary.
- Parameters:
bt_addr – Bluetooth address of the targeted Pebble.
-
void pebble_le_free(const char *bt_addr)
Closes the connection with the specified Pebble Watch and frees the related memory.
- Parameters:
bt_addr – Bluetooth address of the Pebble to disconnect.
-
void pebble_le_register_watch_connectivity(void (*connected_callback)(const char *bt_addr, bool connected))
Registers a function that will be called after a watch has connected or disconnected.
Only one callback may be registered at a time. Each subsequent call to this function will replace the previous callback. The callback is optional; setting it to NULL will deregister the current callback and no function will be called anymore.
- Parameters:
callback – The callback that will be called going forward; NULL to not have a callback.
-
void pebble_le_register_inbox_received(AppMessageInboxReceived received_callback)
Registers a function that will be called after any Inbox message is received successfully.
Only one callback may be registered at a time. Each subsequent call to this function will replace the previous callback. The callback is optional; setting it to NULL will deregister the current callback and no function will be called anymore.
- Parameters:
callback – The callback that will be called going forward; NULL to not have a callback.
-
void pebble_le_app_message_outbox_begin(DictionaryIterator **iterator)
Initialize the given DictionaryIterator for writing to the AppMessage-Outbox.
- Parameters:
iterator – Location to write the DictionaryIterator pointer. This will be NULL on failure.
-
bool pebble_le_app_message_outbox_send(const char *bt_addr, const char *app_uuid, DictionaryIterator *iterator)
Sends out an app message.
This will free the DictionaryIterator containing the message.
- Parameters:
bt_addr – Bluetooth address of the targeted Pebble.
app_uuid – UUID of the watch-app to send the AppMessage to.
iterator – The DictionaryIterator containing the message.
- Returns:
true on successful send,
- Returns:
false otherwise.
-
bool dict_write_data(DictionaryIterator *iter, const uint32_t key, const uint8_t *const data, const uint16_t size)
Adds a key with a byte array value pair to the dictionary.
- Parameters:
iter – The dictionary iterator
key – The key
data – Pointer to the byte array
size – Length of the byte array
- Returns:
true on success,
- Returns:
false otherwise.
Variables
-
PebbleLELogLevel pebble_le_log_level
Get / set verbosity of libpebble-le.
Data Structures
Typedefs
-
typedef struct Dictionary Dictionary
-
typedef bool (*AppMessageInboxReceived)(DictionaryIterator *iterator, const char *app_uuid, const char *bt_addr)
Called after an incoming message is received.
- Param iterator:
The dictionary iterator to the received message.
- Param app_uuid:
UUID of the watch-app that sent the message.
- Param bt_addr:
Bluetooth address of the Pebble from which the message was received.
- Return:
true to return an ACK reply to the watch,
- Return:
false to return a NACK reply to the watch.
Enums
-
struct DictionaryIterator
From Pebble SDK pebble.h.