Last active
February 12, 2018 23:27
-
-
Save eely22/ada2225b402ffa221123ad69f0027309 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "application.h" | |
SYSTEM_MODE(MANUAL); | |
int timeLastPublish = 0; | |
int timeBetweenPublishes = 300000; | |
bool sendData = false; | |
void dataCallbackHandler(uint8_t *data, uint16_t length) { | |
sendData = true; | |
} | |
void setup() { | |
pinMode(D7, OUTPUT); | |
BLE.registerDataCallback(dataCallbackHandler); | |
pinMode(D6, INPUT_PULLDOWN); | |
if (digitalRead(D6) == HIGH) { | |
SYSTEM_MODE(AUTOMATIC); | |
} | |
} | |
void loop() { | |
System.sleep(SLEEP_MODE_CPU); | |
if (sendData) | |
{ | |
uint8_t rsp[2]; | |
rsp[0] = 'H'; | |
rsp[1] = 'i'; | |
BLE.sendData(rsp, 2); | |
timeLastPublish = millis(); | |
sendData = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment