Hacking Pebble on iOS

Post on 28-Jan-2015

111 views 1 download

Tags:

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

HACKING PEBBLE WITH IOS

A brief introduction

Aiden Montgomery

http://www.constructivecoding.com

@AidenMontgomery

WHAT IS PEBBLE?Where did it come from?

http://getpebble.com

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)

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)

WHAT CAN IT DO?

Control your phone’s music playback

WHAT CAN IT DO?

Golf range finder?

WHAT CAN IT DO?

Fitness applications. (Runkeeper)

WHAT CAN IT DO?Tell the time?

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

WHAT CAN IT DO?

Receive notifications

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

Demo Time

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.

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

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

Headers

Meta Data

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

Window

Handler +Event Loop

WHAT CAN IT DO?

Anything we want?

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

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

DEMO APPLICATIONSports Application

PREREQUISITES•PythonPebble relies heavily on Python based

scripts

•ARM toolchainCompile applications for the ARM

architecture

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

HELLO WORLD

Time for code.

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:

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

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

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

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

bizdev@getpebble.com

•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