Skip to content

Instantly share code, notes, and snippets.

@eely22
Last active February 12, 2018 23:27
Show Gist options
  • Save eely22/ada2225b402ffa221123ad69f0027309 to your computer and use it in GitHub Desktop.
Save eely22/ada2225b402ffa221123ad69f0027309 to your computer and use it in GitHub Desktop.
#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