hacking pebble on ios
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
![Page 1: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/1.jpg)
HACKING PEBBLE WITH IOS
A brief introduction
Aiden Montgomery
http://www.constructivecoding.com
@AidenMontgomery
![Page 3: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/3.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/4.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/5.jpg)
WHAT CAN IT DO?
Control your phone’s music playback
![Page 6: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/6.jpg)
WHAT CAN IT DO?
Golf range finder?
![Page 7: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/7.jpg)
WHAT CAN IT DO?
Fitness applications. (Runkeeper)
![Page 8: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/8.jpg)
WHAT CAN IT DO?Tell the time?
Multiple watch faces?http://www.mypebblefaces.com/
![Page 9: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/9.jpg)
WHAT CAN IT DO?
Receive notifications
![Page 10: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/10.jpg)
WHAT CAN IT DO?•Display SMS•Display Caller ID•Accept/Reject Calls
Demo Time
![Page 11: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/11.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/12.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/13.jpg)
ANATOMY OF AN APPThere are certain things all Pebble watchapps need to have
Headers
Meta Data
![Page 14: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/14.jpg)
ANATOMY OF AN APPThere are certain things all Pebble watchapps need to have
Window
Handler +Event Loop
![Page 15: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/15.jpg)
WHAT CAN IT DO?
Anything we want?
![Page 16: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/16.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/17.jpg)
DEMO APPLICATIONSports Application
![Page 18: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/18.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/19.jpg)
HELLO WORLD
Time for code.
![Page 20: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/20.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/21.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/22.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/23.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/24.jpg)
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
![Page 25: Hacking Pebble on iOS](https://reader035.vdocument.in/reader035/viewer/2022081414/54c850184a7959d7758b4575/html5/thumbnails/25.jpg)
•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