SimpleBLE prototype
Dependencies: BLE_API mbed nRF51822
main.cpp@1:acae50e4bc88, 2016-05-11 (annotated)
- Committer:
- janjongboom
- Date:
- Wed May 11 08:58:49 2016 +0000
- Revision:
- 1:acae50e4bc88
- Parent:
- 0:0c885d287f5a
LightSensor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
janjongboom | 0:0c885d287f5a | 1 | #include "mbed.h" |
janjongboom | 0:0c885d287f5a | 2 | #include "SimpleBLE.h" |
janjongboom | 0:0c885d287f5a | 3 | |
janjongboom | 0:0c885d287f5a | 4 | SimpleBLE ble("HPE_LIGHTSENSOR"); |
janjongboom | 1:acae50e4bc88 | 5 | ReadOnlyCharacteristic<uint16_t>* lightChar = ble.createReadOnlyChar<uint16_t>(0x9381, 0x9382, true, 1023); |
janjongboom | 0:0c885d287f5a | 6 | |
janjongboom | 0:0c885d287f5a | 7 | DigitalOut led(LED1); |
janjongboom | 1:acae50e4bc88 | 8 | AnalogIn light(A0); |
janjongboom | 0:0c885d287f5a | 9 | |
janjongboom | 0:0c885d287f5a | 10 | void blink() { |
janjongboom | 0:0c885d287f5a | 11 | led = !led; |
janjongboom | 0:0c885d287f5a | 12 | |
janjongboom | 1:acae50e4bc88 | 13 | lightChar->update(light.read_u16()); |
janjongboom | 0:0c885d287f5a | 14 | } |
janjongboom | 0:0c885d287f5a | 15 | |
janjongboom | 0:0c885d287f5a | 16 | int main(int, char**) { |
janjongboom | 0:0c885d287f5a | 17 | Ticker t; |
janjongboom | 0:0c885d287f5a | 18 | t.attach(blink, 1.0f); |
janjongboom | 0:0c885d287f5a | 19 | |
janjongboom | 0:0c885d287f5a | 20 | ble.spin(); |
janjongboom | 0:0c885d287f5a | 21 | |
janjongboom | 0:0c885d287f5a | 22 | // will never return |
janjongboom | 0:0c885d287f5a | 23 | } |