SimpleBLE prototype

Dependencies:   BLE_API mbed nRF51822

Revision:
0:0c885d287f5a
Child:
1:acae50e4bc88
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 09 13:19:09 2016 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+#include "SimpleBLE.h"
+
+uint16_t counter = 0;
+
+void onColorCharWrite(const uint8_t* buff, size_t length) {
+    printf("Hey got new color! %d %d %d\n", buff[0], buff[1], buff[2]);
+}
+
+SimpleBLE ble("HPE_LIGHTSENSOR");
+ReadOnlyCharacteristic<uint16_t>* lightChar = ble.createReadOnlyChar<uint16_t>(0x9381, 0x9382, true, counter);
+ReadOnlyCharacteristic<uint16_t>* otherChar = ble.createReadOnlyChar<uint16_t>(0x9381, 0x9383, false, 0xaa);
+ReadWriteCharacteristic<uint32_t>* colorChar = ble.createReadWriteChar<uint32_t>(0x9384, 0x9385, false, 0x0, &onColorCharWrite);
+
+DigitalOut led(LED1);
+
+void blink() {
+    led = !led;
+    
+    lightChar->update(++counter);
+}
+
+int main(int, char**) {
+    Ticker t;
+    t.attach(blink, 1.0f);
+    
+    ble.spin();
+    
+    // will never return
+}