Developing with Bluetooth World 15 March 2016 mbed and Bluetooth LE
Developing with
Bluetooth World 15 March 2016
mbed and Bluetooth LE
@janjongboom
Developer EvangelistInternet of Things
Choosing a vendor, not a chipown SDKs, IDEs, programming patterns
UnstreamlinedSingle-platform tools
No code sharing Lack of libraries, documentation
(since 2009)
mbed
Online IDE
Code sharing
Single way of building for all targets
91 boards supported
~200 staff working on it
170,000+ developers
Focused on prototyping
Building on top of mbedNew release: mbed OS
mbed OSOpen source embedded platform
Operating system for microcontrollers
Rock-solid HAL and libraries (e.g. Bluetooth)
One year on AA battery 0.137 mA
DifferencesTask scheduler
Automatic battery management
The embedded event loop is dead
while(1){
delay_ms(1);
}
yottaBuild tools and library management
Cross-platform (Windows, OS X, Linux, Browser)
Easily integrated in own workflow
Coming to uVision and new online IDE
Let's build something...
Get a boardMaxim MAX32610-based (???)
Nordic nRF51822-based
ST Nucleo IDB04A1
configure Install yotta yottadocs.mbed.com
Initialize project yottainit
Set up target yottatargetnrf51dk-gcc
Add BLE yottainstallble
github.com/ARMmbed/ble-examples
Built-in GATT services(e.g. heart rate)
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();
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}
Building$yottabuild
$cpbuild/heartrate.hex/Volumes/MBED
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};
Physical WebWalk up and use anything
Physical Web beacon
http://goo.gl/a1b4cd
(Eddystone protocol)
Official Eddystone library for mbed OS
1#include"EddystoneService.h"23autoeddyServicePtr=newEddystoneService(4ble,defaultAdvPowerLevels,radioPowerLevels);56constchar*url="http://mbed.com";7eddyServicePtr->setURLData(url);89eddyServicePtr->startBeaconService();
http://rollingspider.xyz/aa73bc21
http://meeting.arm.com/tesla
One problem...Eddystone is non-connectable
No service UUIDs in frames
... send two frames!
http://blog.mbed.com/post/137093070607/
End-to-endDemo time!
Juggling visualizerOn device, accelerometer service
Sends out URL
Web app that plots values over time
http://github.com/web-bluetooth/juggling
Get hacking!
Thank you!http://janjongboom.com