Slide 1

Slide 1 text

Introductions

Slide 2

Slide 2 text

Twitter @lgleasain Github lgleasain www.lancegleason.com www.polyglotprogrammincinc.com [email protected]

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Software

Slide 14

Slide 14 text

Options

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Pros •Extensible •Common Pinouts

Slide 17

Slide 17 text

Cons • Impossible to create a at scale prototype • Many extensions overkill for wearables

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Pros • Inexpensive • Available GPS Module • Low Power • Aduino Based • Lots of Support

Slide 20

Slide 20 text

Cons • No easy way to integrate Bluetooth or Wifi • Requires a physical connection to get data • Things like an accelerometer require a separate component

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Features • Bluetooth Support • Robust API for Android and IOS • Built in Sensors (temperature, accelerometer etc.) • Built in support for rechargeable batteries

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Cons • Really Small • Tough to write custom drivers • Proprietary

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Bluetooth • Same Frequency range as 2.4 Gigahertz Wifi • 79 Channels VS 13 • Less Throughput

Slide 33

Slide 33 text

Bluetooth LE • Always off • Less Throughput • Often lower transmit power • Designed for low data low power Applications

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

Android • Bluetooth 4.0 supported radio • Android 4.3 or greater

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

repositories { ivy { url "http://ivyrep.mbientlab.com" layout "gradle" } } compile 'com.mbientlab:metawear:1.5.3' Include the Repo

Slide 42

Slide 42 text

Update The Manifest

Slide 43

Slide 43 text

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) { } }

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

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();

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

.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

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

Example Code Available at https://github.com/lgleasain/Metawear-Android-SOS

Slide 54

Slide 54 text

Twitter @lgleasain Github lgleasain www.lancegleason.com www.polyglotprogrammincinc.com [email protected]