This is an mbed side application meant to demonstrate how to create a custom GATT service/characteristic with Evothings.

Dependencies:   BLE_API mbed nRF51822

Intro

This code is meant to be run on an mbed enabled BLE board and paired with the mbed-evothings-customGATT smartphone application.

Details

This code is a demonstration of how to create a custom service (UUID=0xA0000) with two characteristics, a read only characteristic (UUID=0xA001) and a write characteristic (UUID=0xA002). What is written to the write characteristic will be copied across to the read characteristic and broadcast out. If a single byte is written it will be used to toggle the on board LED, if more than 1 byte is written the data will be written out to the terminal. The default max size is 10bytes.

Viewing Data

You can use either the LightBlue app on iOS or the nRF Master Control Panel application on Android to view the advertising data. Alternatively you can use a custom Evothings App to view the data.

Evothings?

Evothings is a rapid prototyping environment that uses cordova to enable you to rapidly develop smartphone applications in Javascript. Please download the Evothings workbench to your computer and the Evothings client to your smartphone. Then grab the code from the github page, drag and drop the index.htm file into Evothings workbench and run it on the Evothings client.

Reference

Committer:
mbedAustin
Date:
Sat Feb 14 06:49:01 2015 +0000
Revision:
1:94152e7d8b5c
Parent:
0:cd5b6733aeb1
Child:
2:e84c13abc479
added a little more skeleton to it, still needs to be fully flushed out, tossed the HeartRate service code into the custom service.h file, added link to Grove Colour Sensor example for inspiration for later

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 0:cd5b6733aeb1 1 #include "mbed.h"
mbedAustin 0:cd5b6733aeb1 2 #include "BLEDevice.h"
mbedAustin 1:94152e7d8b5c 3 #include "CustomService.h"
mbedAustin 1:94152e7d8b5c 4
mbedAustin 1:94152e7d8b5c 5
mbedAustin 1:94152e7d8b5c 6 // BLE object
mbedAustin 1:94152e7d8b5c 7 BLEDevice ble;
mbedAustin 1:94152e7d8b5c 8
mbedAustin 1:94152e7d8b5c 9 // LED object
mbedAustin 1:94152e7d8b5c 10 DigitalOut led(LED1);
mbedAustin 1:94152e7d8b5c 11
mbedAustin 1:94152e7d8b5c 12 const static char DEVICE_NAME[] = "MyDeviceName"; // change this
mbedAustin 1:94152e7d8b5c 13 static const uint16_t uuid16_list[] = {0xFF}; //Custom UUID, FF is reserved for development
mbedAustin 1:94152e7d8b5c 14
mbedAustin 1:94152e7d8b5c 15 // Restart advertising when phone app disconnects
mbedAustin 1:94152e7d8b5c 16 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
mbedAustin 1:94152e7d8b5c 17 {
mbedAustin 1:94152e7d8b5c 18 ble.startAdvertising(); // restart advertising
mbedAustin 1:94152e7d8b5c 19 }
mbedAustin 0:cd5b6733aeb1 20
mbedAustin 0:cd5b6733aeb1 21
mbedAustin 0:cd5b6733aeb1 22 int
mbedAustin 0:cd5b6733aeb1 23 main(void)
mbedAustin 0:cd5b6733aeb1 24 {
mbedAustin 1:94152e7d8b5c 25 led = 0; // turn LED off
mbedAustin 1:94152e7d8b5c 26 ble.init(); // initialize BLE
mbedAustin 1:94152e7d8b5c 27
mbedAustin 1:94152e7d8b5c 28 // TODO: impliment the rest of triggering for LED based on Write of characteristic.
mbedAustin 1:94152e7d8b5c 29 // TODO: impliment a read characteristic that sends text back to app
mbedAustin 1:94152e7d8b5c 30 // take a look at http://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_GroveColourSensor/file/000c8f8c7f03/main.cpp for inspiration.
mbedAustin 0:cd5b6733aeb1 31 }