the software developers guide to prototyping wearable devices

29
T3 Session 4/16/2015 11:00 AM "The Software Developers Guide to Prototyping Wearable Devices" Presented by: Lance Gleason Polyglot Programming Inc. Brought to you by: 340 Corporate Way, Suite 300, Orange Park, FL 32073 8882688770 9042780524 [email protected] www.sqe.com

Upload: techwellpresentations

Post on 13-Aug-2015

171 views

Category:

Software


1 download

TRANSCRIPT

Page 1: The Software Developers Guide to Prototyping Wearable Devices

 

T3 Session  4/16/2015  11:00  AM  

     

"The Software Developers Guide

to Prototyping Wearable

Devices"  

Presented by:

Lance Gleason

Polyglot Programming Inc.          

 Brought  to  you  by:  

 

   

340  Corporate  Way,  Suite  300,  Orange  Park,  FL  32073  888-­‐268-­‐8770  ·∙  904-­‐278-­‐0524  ·∙  [email protected]  ·∙  www.sqe.com

Page 2: The Software Developers Guide to Prototyping Wearable Devices

Lance Gleason

Polyglot Programming Inc. Lance Gleason has been a computer nut ever since his dad bought him a computer when he was a kid. After getting a BS and MS in Computer Science, he worked on a number of large projects as a Java developer and architect for companies like Kodak, CNN, and GE. These days he is the CEO and founder of Polyglot Programming LLC. which focuses on Ruby, mobile and wearable software development. Lance regularly speaks about Ruby/wearable development at conferences around the world and is the co-organizer of the Atlanta Sensors and Startups Meetup, Ruby DCamp ZA, and Rubyfuza (the only Ruby conference in Africa). He is known to practice interspecies pair (purr) programming with his orange tabby, Allie, and when he’s not writing code, you will find him diving with sharks, trekking through Chernobyl, sampling wine, cheering on the Springboks or perfecting his biltong recipe. Follow Lance on Twitter @lgleasain.  

Page 3: The Software Developers Guide to Prototyping Wearable Devices

Introductions

Twitter @lgleasainGithub lgleasain

www.lancegleason.comwww.polyglotprogrammincinc.com

[email protected]

Page 4: The Software Developers Guide to Prototyping Wearable Devices
Page 5: The Software Developers Guide to Prototyping Wearable Devices
Page 6: The Software Developers Guide to Prototyping Wearable Devices
Page 7: The Software Developers Guide to Prototyping Wearable Devices

http://www.polyglotprogramminginc.com/purr-programming-2-0/

Page 8: The Software Developers Guide to Prototyping Wearable Devices
Page 9: The Software Developers Guide to Prototyping Wearable Devices

Software

Options

Page 10: The Software Developers Guide to Prototyping Wearable Devices

Pros•Extensible •Common Pinouts

Page 11: The Software Developers Guide to Prototyping Wearable Devices

Cons• Impossible to create a at

scale prototype • Many extensions overkill for

wearables

Page 12: The Software Developers Guide to Prototyping Wearable Devices

Pros• Inexpensive

• Available GPS Module

• Low Power

• Aduino Based

• Lots of Support

Cons• No easy way to integrate Bluetooth

or Wifi

• Requires a physical connection to get data

• Things like an accelerometer require a separate component

Page 13: The Software Developers Guide to Prototyping Wearable Devices
Page 14: The Software Developers Guide to Prototyping Wearable Devices
Page 15: The Software Developers Guide to Prototyping Wearable Devices

Features• Bluetooth Support

• Robust API for Android and IOS

• Built in Sensors (temperature, accelerometer etc.)

• Built in support for rechargeable batteries

Specs• ! Nordic Semiconductor nRF51822 BLE SoC

• ! 2.4 GHz transceiver

• ! ARM®Cortex™-M0 32 bit processor

• ! 256 kB flash program memory

• ! 16 kB RAM

• ! 8/9/10 bit ADC

Page 16: The Software Developers Guide to Prototyping Wearable Devices

Specs Continued• Accelerometer

• Temperature Sensor

• Push Button Switch

• Bright LED

• Driver for vibration motor

• micro usb chargable

• I2C bus, and support for 4 digital/analog and 4 digital pins

Page 17: The Software Developers Guide to Prototyping Wearable Devices

Cons

• Really Small

• Tough to write custom drivers

• Proprietary

Page 18: The Software Developers Guide to Prototyping Wearable Devices

Bluetooth• Same Frequency range as 2.4 Gigahertz Wifi

• 79 Channels VS 13 • Less Throughput

Page 19: The Software Developers Guide to Prototyping Wearable Devices

Bluetooth LE• Always off

• Less Throughput

• Often lower transmit power

• Designed for low data low power Applications

Page 20: The Software Developers Guide to Prototyping Wearable Devices

IOS• IPad 3rd Generation or better • Iphone 4S or greater

Page 21: The Software Developers Guide to Prototyping Wearable Devices

Android• Bluetooth 4.0 supported radio • Android 4.3 or greater

Page 22: The Software Developers Guide to Prototyping Wearable Devices
Page 23: The Software Developers Guide to Prototyping Wearable Devices

repositories { ivy { url "http://ivyrep.mbientlab.com" layout "gradle" } }

compile 'com.mbientlab:metawear:1.5.3'

Include the Repo

<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >

<service android:name="com.mbientlab.metawear.api.MetaWearBleService" />

<!-- Other application info --> </application>

Update The Manifest

Page 24: The Software Developers Guide to Prototyping Wearable Devices

package com.example.metawear;

import com.mbientlab.metawear.api.MetaWearBleService; import android.app.Activity; import android.content.ServiceConnection;

public class ExampleActivity extends Activity implements ServiceConnection { private MetaWearBleService mwService= null;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

//< Bind the MetaWear service when the activity is created getApplicationContext().bindService(new Intent(this, MetaWearBleService.class), this, Context.BIND_AUTO_CREATE); }

@Override public void onDestroy() { super.onDestroy();

//< Unbind the service when the activity is destroyed getApplicationContext().unbindService(this); }

@Override public void onServiceConnected(ComponentName name, IBinder service) { //< Get a reference to the MetaWear service from the binder mwService= ((MetaWearBleService.LocalBinder) service).getService(); }

//< Don't need this callback method but we must implement it @Override public void onServiceDisconnected(ComponentName name) { } }

public class ExampleActivity extends Activity implements ServiceConnection { @Override protected void onResume() { super.onResume(); registerReceiver(MetaWearBleService.getMetaWearBroadcastReceiver(), MetaWearBleService.getMetaWearIntentFilter()); }

@Override protected void onPause() { super.onPause(); unregisterReceiver(MetaWearBleService.getMetaWearBroadcastReceiver()); } }

Nofifications via Activity

Page 25: The Software Developers Guide to Prototyping Wearable Devices

private final string MW_MAC_ADDRESS= "EC:2C:09:81:22:AC"; private MetaWearController mwCtrllr;

public void onServiceConnected(ComponentName name, IBinder service) { mwService= ((MetaWearBleService.LocalBinder) service).getService();

final BluetoothManager btManager= (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); final mwBoard= btManager.getAdapter().getRemoteDevice(MW_MAC_ADDRESS) mwCtrllr= mwService.getMetaWearController(mwBoard); }

//< Connect to the board the object is controlling mwCtrllr.connect();

///< Close the Bluetooth connection mwCtrllr.close();

Instantiate and Connect

private DeviceCallbacks dCallbacks= new DeviceCallbacks() { @Override public void connected() { Log.i("ExampleActivity", "A Bluetooth LE connection has been established!"); } @Override public void disconnected() { Log.i("ExampleActivity", "Lost the Bluetooth LE connection!"); } }; ///< Register the callback, log message will appear when connected mwController.addDeviceCallback(dCallbacks); ///< Remove the callback, no feedback for when a ble connection is made mwController.removeDeviceCallback(dCallbacks);

Registering Callbacks

Page 26: The Software Developers Guide to Prototyping Wearable Devices

import com.mbientlab.metawear.api.characteristic;

//< Setup callback for receiving device information mwCtrllr.addDeviceCallback(new DeviceCallbacks() { @Override public void receivedGATTCharacteristic(GATTCharacteristic characteristic, byte[] data) { Log.i("ExampleActivity", String.format("%s= %s", characteristic.toString(), new String(data)); }

@Override public void receivedRemoteRSSI(int rssi) { log.i("ExampleActivity", String.format("RSSI= %d dBm", rssi)); } });

//< Read characteristics from the device information service //< GATT characteristics are from the DeviceInformation enum mwCtrllr.readDeviceInfo(); //< Read battery level from the battery service //< GATT characteristics are from the Battery enum mwCtrllr.readBatteryLevel(); //< Read RSSI value mwCtrllr.readRemoteRSSI();

mwController.addModuleCallback(new MechanicalSwitch.Callbacks() { @Override public void pressed() { if (saviours != null && saviours.getCount() > 0) { Toast.makeText(getActivity(), "button pressed", Toast.LENGTH_SHORT).show(); sendText(true); } else { Toast.makeText(getActivity(), R.string.error_no_contact, Toast.LENGTH_SHORT).show(); } } })

Switch Callback

Page 27: The Software Developers Guide to Prototyping Wearable Devices

.addModuleCallback(new Accelerometer.Callbacks() { @Override public void shakeDetected(MovementData moveData) { shakeCounts.getAndIncrement(); if (!setTimerTask.get()) { resetTask= new TimerTask() { @Override public void run() { shakeCounts.set(0); setTimerTask.getAndSet(false); } }; timer.schedule(resetTask, RESET_DELAY); setTimerTask.getAndSet(true); } if (shakeCounts.get() == MAX_SHAKES) { resetTask.cancel(); setTimerTask.getAndSet(false); shakeCounts.getAndSet(0); if (saviours != null && saviours.getCount() > 0) { sendText(false); } else { Toast.makeText(getActivity(), R.string.error_no_contact, Toast.LENGTH_SHORT).show(); } } } });

Shake Callback

Page 28: The Software Developers Guide to Prototyping Wearable Devices
Page 29: The Software Developers Guide to Prototyping Wearable Devices

Example Code Available at

https://github.com/lgleasain/Metawear-Android-SOS

Twitter @lgleasainGithub lgleasain

www.lancegleason.comwww.polyglotprogrammincinc.com

[email protected]