Developing with mbed and Bluetooth LE - Bluetooth World 2016

41
Developing with Bluetooth World 15 March 2016 mbed and Bluetooth LE

Transcript of Developing with mbed and Bluetooth LE - Bluetooth World 2016

Page 1: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Developing with

Bluetooth World 15 March 2016

mbed and Bluetooth LE

Page 2: Developing with mbed and Bluetooth LE - Bluetooth World 2016

@janjongboom

Developer EvangelistInternet of Things

Page 3: Developing with mbed and Bluetooth LE - Bluetooth World 2016
Page 4: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Choosing a vendor, not a chipown SDKs, IDEs, programming patterns

Page 5: Developing with mbed and Bluetooth LE - Bluetooth World 2016

UnstreamlinedSingle-platform tools

No code sharing Lack of libraries, documentation

Page 6: Developing with mbed and Bluetooth LE - Bluetooth World 2016

(since 2009)

mbed

Page 7: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Online IDE

Code sharing

Single way of building for all targets

Page 8: Developing with mbed and Bluetooth LE - Bluetooth World 2016

91 boards supported

~200 staff working on it

170,000+ developers

Page 9: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Focused on prototyping

Page 10: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Building on top of mbedNew release: mbed OS

Page 11: Developing with mbed and Bluetooth LE - Bluetooth World 2016

mbed OSOpen source embedded platform

Operating system for microcontrollers

Rock-solid HAL and libraries (e.g. Bluetooth)

Page 12: Developing with mbed and Bluetooth LE - Bluetooth World 2016

One year on AA battery 0.137 mA

Page 13: Developing with mbed and Bluetooth LE - Bluetooth World 2016

DifferencesTask scheduler

Automatic battery management

The embedded event loop is dead

while(1){

delay_ms(1);

}

Page 14: Developing with mbed and Bluetooth LE - Bluetooth World 2016

yottaBuild tools and library management

Cross-platform (Windows, OS X, Linux, Browser)

Easily integrated in own workflow

Coming to uVision and new online IDE

Page 15: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Let's build something...

Page 16: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Get a boardMaxim MAX32610-based (???)

Nordic nRF51822-based

ST Nucleo IDB04A1

Page 17: Developing with mbed and Bluetooth LE - Bluetooth World 2016

configure Install yotta yottadocs.mbed.com

Initialize project yottainit

Set up target yottatargetnrf51dk-gcc

Add BLE yottainstallble

Page 18: Developing with mbed and Bluetooth LE - Bluetooth World 2016

github.com/ARMmbed/ble-examples

Page 19: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Built-in GATT services(e.g. heart rate)

Page 20: Developing with mbed and Bluetooth LE - Bluetooth World 2016

1#include"ble/BLE.h"23conststaticcharDEVICE_NAME[]="HRM";4staticconstuint16_tuuid16_list[]={GattService::UUID_HEART_RATE_SERVICE};56staticuint8_thrmCounter=100;//initHRMto100bps78autohrServicePtr=newHeartRateService(9ble,hrmCounter,HeartRateService::LOCATION_FINGER);1011/*snip..configuration*/12ble.gap().setAdvertisingInterval(1000);13ble.gap().startAdvertising();

Page 21: Developing with mbed and Bluetooth LE - Bluetooth World 2016

1voidupdateHr(void)2{3if(BLE::Instance().getGapState().connected){4hrmCounter++;56if(hrmCounter==175){7hrmCounter=100;8}910hrServicePtr->updateHeartRate(hrmCounter);11}12}1314voidapp_start(int,char**)15{16Scheduler::postCallback(updateHr).period(minar::milliseconds(500));17}

Page 22: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Building$yottabuild

$cpbuild/heartrate.hex/Volumes/MBED

Page 23: Developing with mbed and Bluetooth LE - Bluetooth World 2016
Page 24: Developing with mbed and Bluetooth LE - Bluetooth World 2016

1classButtonService{2uint16_tBUTTON_SERVICE_UUID=0xA000;3uint16_tBUTTON_STATE_CHARACTERISTIC_UUID=0xA001;45ButtonService(BLE&_ble,boolbuttonPressedInitial):6ble(_ble),buttonState(BUTTON_STATE_CHARACTERISTIC_UUID,7GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)8{9GattCharacteristic*charTable[]={&buttonState};10GattServiceservice(ButtonService::BUTTON_SERVICE_UUID,/*chars*/);11ble.gattServer().addService(buttonService);12}1314voidupdateButtonState(boolnewState){15ble.gattServer().write(buttonState.getValueHandle(),newState);16}1718BLE&ble;19ReadOnlyGattCharacteristic<bool>buttonState;20};

Page 25: Developing with mbed and Bluetooth LE - Bluetooth World 2016
Page 26: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Physical WebWalk up and use anything

Page 27: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Physical Web beacon

http://goo.gl/a1b4cd

(Eddystone protocol)

Page 28: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Official Eddystone library for mbed OS

Page 29: Developing with mbed and Bluetooth LE - Bluetooth World 2016

1#include"EddystoneService.h"23autoeddyServicePtr=newEddystoneService(4ble,defaultAdvPowerLevels,radioPowerLevels);56constchar*url="http://mbed.com";7eddyServicePtr->setURLData(url);89eddyServicePtr->startBeaconService();

Page 30: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Web BluetoothGATT from JS

Some great demo's: http://thebubbleworks.com

Page 31: Developing with mbed and Bluetooth LE - Bluetooth World 2016

http://rollingspider.xyz/aa73bc21

Page 32: Developing with mbed and Bluetooth LE - Bluetooth World 2016

http://meeting.arm.com/tesla

Page 33: Developing with mbed and Bluetooth LE - Bluetooth World 2016

One problem...Eddystone is non-connectable

No service UUIDs in frames

... send two frames!

Page 34: Developing with mbed and Bluetooth LE - Bluetooth World 2016

http://blog.mbed.com/post/137093070607/

Page 35: Developing with mbed and Bluetooth LE - Bluetooth World 2016
Page 36: Developing with mbed and Bluetooth LE - Bluetooth World 2016

End-to-endDemo time!

Page 37: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Juggling visualizerOn device, accelerometer service

Sends out URL

Web app that plots values over time

Page 38: Developing with mbed and Bluetooth LE - Bluetooth World 2016
Page 39: Developing with mbed and Bluetooth LE - Bluetooth World 2016

http://github.com/web-bluetooth/juggling

Page 40: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Get hacking!

Page 41: Developing with mbed and Bluetooth LE - Bluetooth World 2016

Thank you!http://janjongboom.com