Created
November 7, 2019 02:33
-
-
Save markterrill/82ce13c01b747b0ba056927d4e9738b7 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(SEMI_AUTOMATIC); | |
SYSTEM_THREAD(ENABLED); | |
STARTUP(prepare()); | |
void prepare() { | |
// Set the prefix so we can't lose it | |
System.set(SYSTEM_CONFIG_SOFTAP_PREFIX, "Smart"); | |
} | |
bool boolStartConnect = false; | |
void timer_10sec_connect() { | |
//WiFi.listen(true); // go to listen mode | |
Serial.println("in 10sec timer going to do connect()"); | |
Particle.connect(); | |
boolStartConnect = true; | |
} | |
Timer timerParticleConnect(10000, timer_10sec_connect, true); // one shot timer for connectivity | |
byte mac[6]; | |
char strVersion[32]; | |
String sV = "20171230-1400-01"; | |
void setup() { | |
delay (3000); | |
// Start serial at 9600 baud | |
Serial.begin(9600); | |
Serial1.begin(115200); // BT module | |
// Update version as property functions can't be in global scope | |
sV.concat("_"); | |
sV.concat(System.version()); | |
sV.toCharArray(strVersion, 32); | |
// Spark read/write variables | |
Particle.variable("version", strVersion, STRING); | |
Particle.function("reset", callReset); | |
Serial.println("start of setup 0 functions"); | |
delay(500); | |
//WiFi.connect(); | |
//Particle.connect(); | |
Serial.println("start of setup 1 connect"); | |
delay(2000); | |
timerParticleConnect.start(); // just in case | |
WiFi.macAddress(mac); // Save the particle mac address | |
Serial.println("start of setup 1 wifi"); | |
} | |
int callReset(String nonsenseArg){ | |
Serial.println("Going to reset device now due to cloud function call!"); | |
Particle.publish("info", "Going to reset device now due to cloud function call!", 60, PRIVATE); | |
delay(2000); // 2 seconds | |
System.reset(); | |
return 1; | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment