Blynk example for RedBearLab BLE Nano
Dependencies: BLE_API Blynk mbed nRF51822
Diff: source/main.cpp
- Revision:
- 9:6d4eec96b28e
- Parent:
- 5:c52894060941
- Child:
- 10:6e02ef811ea3
--- a/source/main.cpp Thu Dec 21 12:39:06 2017 +0000 +++ b/source/main.cpp Fri Jan 26 22:22:23 2018 +0000 @@ -23,7 +23,13 @@ #include <mbed.h> Serial pc(USBTX, USBRX); -//#define BLYNK_DEBUG +// TODO: these defines are included as a workaround. +// I'm investigating further. +#define BLYNK_NO_INFO +#define BLYNK_USE_DIRECT_CONNECT +// end of workaround + +#define BLYNK_DEBUG #define BLYNK_PRINT pc #include <BlynkSimpleRedBearLab_BLE_Nano.h> @@ -34,21 +40,6 @@ uint8_t device_name[] = "Blynk"; -PwmOut speaker(p30); -BLYNK_WRITE(V1) { - if (param.asInt()) { - speaker.period(1.0/param.asInt()); - speaker = 0.5; - } else { - speaker = 0; - } -} - -PwmOut ledR(p15); -BLYNK_WRITE(V2) { - ledR = 1.0 - (param.asDouble()/1024.0f); -} - void setup() { ble.init(); @@ -68,17 +59,16 @@ ble.startAdvertising(); printf("Waiting for connections...\n"); - - ledR = 1.0; - speaker = 0.0; } void loop() { - Blynk.run(); + ble.waitForEvent(); + Blynk.run(); } int main(void) { setup(); + while(1) { loop(); }