#PDR15 - Smartstrap Workshop

37
2015 Pebble Developer Retreat Smartstraps Brian Gomberg

Transcript of #PDR15 - Smartstrap Workshop

Page 1: #PDR15 - Smartstrap Workshop

2015 Pebble Developer Retreat

Smartstraps

Brian Gomberg

Page 2: #PDR15 - Smartstrap Workshop

What is a smartstrap?

Page 3: #PDR15 - Smartstrap Workshop

Electrical Connection

Page 4: #PDR15 - Smartstrap Workshop

GND GNDDATA PWR

Page 5: #PDR15 - Smartstrap Workshop

Smartstrap Protocol

Page 6: #PDR15 - Smartstrap Workshop

Smartstrap Protocol

•Master / slave model (watch is master)

•Notification mechanism

•Data arrives intact or not at all

Page 7: #PDR15 - Smartstrap Workshop

Physical Layer

Link Layer

Profile Layer

Link Control Profile Raw Data Profile Generic Service Profile

Page 8: #PDR15 - Smartstrap Workshop

Generic Service Profile

•Attributes and Services:

•An attribute is a distinct piece of information

•A service is a collection of related attributes

Page 9: #PDR15 - Smartstrap Workshop
Page 10: #PDR15 - Smartstrap Workshop

Defining Services and Attributes

Page 11: #PDR15 - Smartstrap Workshop

Connection Process

Page 12: #PDR15 - Smartstrap Workshop

Charging flux capacitors!

What profiles do you support?

I support ALL the profiles!

Profile Discovery

All Profiles Supported

Page 13: #PDR15 - Smartstrap Workshop

Woot! Are you ready to go?

Let’s talk faster.Status Request

Change Baud Rate

Page 14: #PDR15 - Smartstrap Workshop

What services do you support?

I support service 0x1234, the best service.

Service Discovery

Service 0x1234

Page 15: #PDR15 - Smartstrap Workshop

static SmartstrapAttribute *color_attr;

static void init(void) { const SmartstrapServiceId service_id = 0x1234; const SmartstrapAttributeId attribute_id = 0x0042; const size_t length = 1; color_attr = smartstrap_attribute_create(service_id, attribute_id, length); smartstrap_subscribe((SmartstrapHandlers) { ... });}

static void deinit(void) { smartstrap_attribute_destroy(color_attr); smartstrap_unsubscribe();}

Page 16: #PDR15 - Smartstrap Workshop

static const uint16_t SERVICES[] = {0x1234};static uint8_t buffer[GET_PAYLOAD_BUFFER_SIZE(1)];

void setup() { const uint8_t pin = 1; ArduinoPebbleSerial::begin_software(pin, buffer, sizeof(buffer), Baud57600, SERVICES, 1);}

Page 17: #PDR15 - Smartstrap Workshop

Reading Attributes

Page 18: #PDR15 - Smartstrap Workshop

What is your favorite color?

I like green.

Read 0x1234, 0x0042

0b11001100

Page 19: #PDR15 - Smartstrap Workshop

smartstrap_attribute_read(color_attr);

Page 20: #PDR15 - Smartstrap Workshop

uint16_t service_id, attribute_id;size_t length;RequestType type;if (ArduinoPebbleSerial::feed(&service_id, &attribute_id, &length, &type)) { // ... buffer[0] = 0b11110111; ArduinoPebbleSerial::write(true, buffer, 1);}

Page 21: #PDR15 - Smartstrap Workshop

static void prv_did_read_handler(SmartstrapAttribute *attribute, SmartstrapResult result, const uint8_t *data, size_t length) { // handle read...}

Page 22: #PDR15 - Smartstrap Workshop

Notifications

Page 23: #PDR15 - Smartstrap Workshop

Wait! I change my mind!

Notification

0x1234, 0x0042

Page 24: #PDR15 - Smartstrap Workshop

ArduinoPebbleSerial::notify(0x1234, 0x0042);

Page 25: #PDR15 - Smartstrap Workshop

static void prv_notify_handler(SmartstrapAttribute *attribute) { // ...}

Page 26: #PDR15 - Smartstrap Workshop

Demo

Page 27: #PDR15 - Smartstrap Workshop

Smartstrap AdapterPebble Time Teensy 3.1

Page 28: #PDR15 - Smartstrap Workshop
Page 29: #PDR15 - Smartstrap Workshop

Links• Documentation: http://developer.pebble.com/guides/hardware/

• Arduino Library: https://github.com/pebble/ArduinoPebbleSerial

• Teensy 3.2: https://www.pjrc.com/store/teensy32.html

Page 30: #PDR15 - Smartstrap Workshop

Examples

Page 31: #PDR15 - Smartstrap Workshop
Page 32: #PDR15 - Smartstrap Workshop
Page 33: #PDR15 - Smartstrap Workshop
Page 34: #PDR15 - Smartstrap Workshop
Page 35: #PDR15 - Smartstrap Workshop
Page 36: #PDR15 - Smartstrap Workshop
Page 37: #PDR15 - Smartstrap Workshop

Questions?

Slack Room: #smartstraps Email: [email protected]