Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Revision 1:acae50e4bc88, committed 2016-05-11
- Comitter:
- janjongboom
- Date:
- Wed May 11 08:58:49 2016 +0000
- Parent:
- 0:0c885d287f5a
- Commit message:
- LightSensor
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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**) {