SimpleBLE prototype
Dependencies: BLE_API mbed nRF51822
Diff: main.cpp
- Revision:
- 1:acae50e4bc88
- Parent:
- 0:0c885d287f5a
--- a/main.cpp Mon May 09 13:19:09 2016 +0000 +++ b/main.cpp Wed May 11 08:58:49 2016 +0000 @@ -1,23 +1,16 @@ #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); +ReadOnlyCharacteristic<uint16_t>* lightChar = ble.createReadOnlyChar<uint16_t>(0x9381, 0x9382, true, 1023); DigitalOut led(LED1); +AnalogIn light(A0); void blink() { led = !led; - lightChar->update(++counter); + lightChar->update(light.read_u16()); } int main(int, char**) {