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

Revision:
12:6d1f77d0cb37
Parent:
11:b59226338001
Child:
13:62b1d32745ac
--- a/main.cpp	Wed Mar 11 14:23:25 2015 +0000
+++ b/main.cpp	Tue Mar 17 20:38:40 2015 +0000
@@ -1,11 +1,10 @@
 #include "mbed.h"
 #include "BLEDevice.h"
-#include "CustomService.h"
 
 BLEDevice ble;
 DigitalOut led(LED1);
 uint16_t customServiceUUID  = 0xA000;
-uint16_t reachCharUUID      = 0xA001;
+uint16_t readCharUUID      = 0xA001;
 uint16_t writeCharUUID      = 0xA002;
 
 const static char     DEVICE_NAME[]        = "ChangeMe!!"; // change this
@@ -13,12 +12,10 @@
 
 // Set Up custom Characteristics
 static uint8_t readValue[10] = {0};
-GattCharacteristic readChar(reachCharUUID, readValue, sizeof(readValue), sizeof(readValue),
-                            GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
+ReadOnlyArrayGattCharacteristic<uint8_t, sizeof(readValue)> readChar(readCharUUID, readValue);
 
 static uint8_t writeValue[10] = {0};
-GattCharacteristic writeChar(writeCharUUID, writeValue, sizeof(writeValue), sizeof(writeValue),
-                             GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
+WriteOnlyArrayGattCharacteristic<uint8_t, sizeof(writeValue)> writeChar(writeCharUUID, writeValue);
 
 // Set up custom service
 GattCharacteristic *characteristics[] = {&readChar, &writeChar};