Hacking Pebble on iOS

25
HACKING PEBBLE WITH IOS A brief introduction Aiden Montgomery http://www.constructivecod ing.com @AidenMontgomery

description

This is a brief introduction to hacking the Pebble smart watch with iOS. We cover the difference between Watch Face and Watch Apps, then how to send messages to and from the Pebble and your iPhone.

Transcript of Hacking Pebble on iOS

Page 1: Hacking Pebble on iOS

HACKING PEBBLE WITH IOS

A brief introduction

Aiden Montgomery

http://www.constructivecoding.com

@AidenMontgomery

Page 2: Hacking Pebble on iOS

WHAT IS PEBBLE?Where did it come from?

http://getpebble.com

Page 3: Hacking Pebble on iOS

SPECIFICATION

•Pebble OS, modified FreeRTOS•Cortex-M3 ARM microprocessor•1024KB Flash Memory•RAM between 64KB and 128KB•1.26” screen -144 x 168 pixels•Black and white “transflective LCD” (ePaper)

Page 4: Hacking Pebble on iOS

SPECIFICATION

•Backlight (motion activated)•Vibrating motor•Ambient light sensor•Bluetooth 2.1 (supports 4.0 future update)•Three-axis accelerometer•Magnetometer•7 day battery (not too sure about that)

Page 5: Hacking Pebble on iOS

WHAT CAN IT DO?

Control your phone’s music playback

Page 6: Hacking Pebble on iOS

WHAT CAN IT DO?

Golf range finder?

Page 7: Hacking Pebble on iOS

WHAT CAN IT DO?

Fitness applications. (Runkeeper)

Page 8: Hacking Pebble on iOS

WHAT CAN IT DO?Tell the time?

Multiple watch faces?http://www.mypebblefaces.com/

Page 9: Hacking Pebble on iOS

WHAT CAN IT DO?

Receive notifications

Page 10: Hacking Pebble on iOS

WHAT CAN IT DO?•Display SMS•Display Caller ID•Accept/Reject Calls

Demo Time

Page 11: Hacking Pebble on iOS

WATCHFACES VS APPSWhat is the difference?

A standard app:

• Generally has the system status bar at the top of the display—showing the time. (Although apps can also be made “fullscreen” which removes the status bar.)

• May update the display more frequently than a watch face.

• Can respond to button presses.

A watch face app:

• Is displayed full screen without the system status bar.

• Usually uses the minute or second handlers.

• Is expected to be very careful with its use of system resources (e.g. power, display updates) in order to preserve battery life.

• Can be made a “default” that is automatically displayed when the launcher menu times out.

Page 12: Hacking Pebble on iOS

KEY CONCEPTS•Event Handlers•Tick Handler•Input Handler

•Resources•Types•Fonts•Bitmaps•Data

•Build process converts resources into useable a format

•On-screen Layers•Object/Layer hierarchy•Layers are drawn on•Higher-level layers•TextLayer•BmpContainer

Page 13: Hacking Pebble on iOS

ANATOMY OF AN APPThere are certain things all Pebble watchapps need to have

Headers

Meta Data

Page 14: Hacking Pebble on iOS

ANATOMY OF AN APPThere are certain things all Pebble watchapps need to have

Window

Handler +Event Loop

Page 15: Hacking Pebble on iOS

WHAT CAN IT DO?

Anything we want?

Page 16: Hacking Pebble on iOS

PEBBLE IOS SDK•http://developer.getpebble.c

om/•PebbleKit•Pebble SDK•Current version is 1.12•11.6MB extracted

Page 17: Hacking Pebble on iOS

DEMO APPLICATIONSports Application

Page 18: Hacking Pebble on iOS

PREREQUISITES•PythonPebble relies heavily on Python based

scripts

•ARM toolchainCompile applications for the ARM

architecture

http://developer.getpebble.com/1/GettingStarted/MacOS/

Page 19: Hacking Pebble on iOS

HELLO WORLD

Time for code.

Page 20: Hacking Pebble on iOS

PHONE/APP COMMS•Bi-directional Communication•Communication over Bluetooth•SDK abstracts communications (somewhat)•APIs for pushing messages called AppMessage•AppSync is a layer on top of AppMessage

•iOS has a Communication Session•Single session for all 3rd party apps•Only opened from iOS•Last one in wins•Close the session when you are done -closeSession:

Page 21: Hacking Pebble on iOS

RECEIVING MESSAGES•Define Inbound Buffer•Messages are all dictionaries•Size calculation•1 + (n * 7) + D1 + ... + Dn•n = number of tuples•Dx sizes of the values

•Define Handlers•in_received•in_dropped

Page 22: Hacking Pebble on iOS

IOS (FINALLY)Required

Frameworks

Additional Configuration•Add the value "com.getpebble.public" to the

"Supported external accessory protocols" (UISupportedExternalAccessoryProtocols) array in your app's Info.plist

•Optionally, add the value "App communicates with an accessory" (external-accessory) to the "Required background modes" (UIBackgroundModes) array in your app's Info.plist

Page 23: Hacking Pebble on iOS

HANDLING THE PEBBLE•Setup a delegate for Pebble Central•Get the last connected watch•Attempt to connect to the watch•Handle connection and disconnection events•Use the connected watch to send/receive messages

Demo Time

Page 24: Hacking Pebble on iOS

MADE FOR IPHONEPebble participate in the Made for iPhone

program.

To submit your app to the App StorePebble need to whitelist your application.

Once you have an App completed, email Pebble

[email protected]

Page 25: Hacking Pebble on iOS

•http://kickstarter.com•http://getpebble.com•http://developer.getpebble.com•http://developer.getpebble.com/1/GettingStarted/MacOS/•http://pebbledev.org/wiki/Main_Page

Links

Aiden Montgomeryhttp://

www.constructivecoding.com@AidenMontgomer

y