Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pebble Watch Development

Royce Mars
January 07, 2017

Pebble Watch Development

Royce Mars

January 07, 2017

Transcript

61 slides
  1. Pebble Developer Portal https://developer.pebble.com • Instructions for CloudPebble and SDK

    • C Language • Android and iOS SDKs • Guides, examples, blog
  2. New Cloud Project Project types available: • Pebble C SDK

    • Simple.js • Pebble.js (beta) SDK versions available: 2 and 3. Templates: • Empty project • Minimal • ButtonClick • HelloWorld • AppMessage
  3. WatchFace TickTimerService Register with TickTimerService: static void tick_handler(struct tm *tick_time,

    TimeUnits units_changed) {...} tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
  4. Customizations • Add resources to appinfo.json, in array media •

    Use GFont for TextLayer custom fonts • Use GBitmap for BitmapLayer • Use create_with_resource for loading resources • Use _destroy functions to free resources
  5. Limitations • Number of resources - 256 • Max resource

    size - 128kB (Aplite), 256kB (Basalt and Chalk)
  6. Event Services https://developer.pebble.com/docs/c/Foundation/Event_Service/ https://developer.pebble.com/guides/events-and-services/events/ Handler may listen for event, or

    use “peek” style to read single data from API • AppFocusService • AccelerometerService • BatteryStateService • ConnectionService • HealthService • TickTimerService
  7. Storage API Limited to 4KB persist_write_data(key, &data, sizeof(Data)); persist_read_data(key, &data,

    sizeof(Data)); Alternative - localStorage API in PebbleKit JS. But it’s not battery efficient And depends on connection between Watch and Phone
  8. PebbleKit JS • Access to extended storage with localStorage. •

    Internet access using XMLHttpRequest. • Location data using geolocation. • The ability to show a configuration page to allow users to customize how the app behaves.
  9. AppMessage API Bi-directional communication between phone apps and Pebble watchapps.

    ACKnowledged or "NACK'ed," app_message_open() APP_MESSAGE_INBOX_SIZE_MINIMUM and APP_MESSAGE_OUTBOX_SIZE_MINIMUM app_message_inbox_size_maximum() and app_message_outbox_size_maximum()
  10. PebbleKit Android dependencies { compile 'com.getpebble:pebblekit:3.0.0' } PebbleDictionary dict =

    new PebbleDictionary(); dict.addString(AppKeyContactName, contactName); final UUID appUuid = UUID.fromString("EC7EE5C6-8DDF-4089-AA84-C3396A11CC95"); // Send the dictionary PebbleKit.sendDataToPebble(getApplicationContext(), appUuid, dict);
  11. PebbleKit Android Messages will be received on Pebble Watch in:

    AppMessageInboxReceived PebbleKit.registerReceivedDataHandler(getApplicationContext(), dataReceiver);
  12. PebbleKit Android // Create a new receiver to get AppMessages

    from the C app PebbleDataReceiver dataReceiver = new PebbleDataReceiver(appUuid) { @Override public void receiveData(Context context, int transaction_id, PebbleDictionary dict) { // A new AppMessage was received, tell Pebble PebbleKit.sendAckToPebble(context, transaction_id); } };
  13. PebbleKit Android @Override public void receiveData(Context context, int transaction_id, PebbleDictionary

    dict) { final int AppKeyAge = 1; // If the tuple is present... Long ageValue = dict.getInteger(AppKeyAge); if(ageValue != null) { // Read the integer value
  14. PebbleKit iOS [PBPebbleCentral defaultCentral].delegate = self; - (void)pebbleCentral:(PBPebbleCentral*)central watchDidConnect:(PBWatch*)watch isNew:(BOOL)isNew

    { NSLog(@"Pebble connected: %@", [watch name]); // Keep a reference to this watch self.connectedWatch = watch; }
  15. PebbleKit iOS [self.connectedWatch appMessagesPushUpdate:update onSent:^(PBWatch *watch, NSDictionary *update, NSError *error)

    { if (!error) { NSLog(@"Successfully sent message."); } else { NSLog(@"Error sending message: %@", error); } }];

More Decks by Royce Mars

Other Decks in Programming