Okay, so to trigger a handshake I just need to have somewhere in the loop() or setup() function
Particle.disconnect(); delay(3000); Particle.connect();
and on the Particle.connect()
it will do a handshake?
Currently, this is what I’m doing:
void setup()
{
initAll();
takeMeasurements();
slowClock();
sprintf(publishString, "{\"m_min\":%d,\"m_q1\":%d,\"m_med\":%d,\"m_q3\":%d,\"m_max\":%d,\"m_soc\":%f}", m_min, m_q1, m_med, m_q3, m_max, m_soc);
unsigned long t_now = Time.now(); // seconds since Jan 1 1970 (UTC)
int Sleep_Duration = getSleepDelay(t_now);
System.sleep(SLEEP_MODE_SOFTPOWEROFF, Sleep_Duration);
Particle.connect();
waitUntil(Particle.connected);
DPRINTLN("--- setup ====================================");
}
void loop()
{
DPRINTLN("+++ loop *************************************");
if (published == false)
{
DPRINTLN("loop branch 1; publishing");
published = Particle.publish(EVENT_NAME, publishString, PRIVATE);
DPRINTF("Published with return value: %d (1 means success)\n", published);
}
else
{
DPRINTLN("loop branch 2; delay, disconnect, write to eeprom, go to sleep");
delay(DELAY_CLOUD);
Particle.disconnect();
unsigned long t_now = Time.now(); // seconds since Jan 1 1970 (UTC)
int Sleep_Duration = getSleepDelay(t_now);
DPRINTF("End of connected cycle; time read: %s\n", Time.format(Time.now(), TIME_FORMAT_DEFAULT).c_str());
DPRINTF("Going to sleep for %d seconds\n", Sleep_Duration);
System.sleep(SLEEP_MODE_SOFTPOWEROFF, Sleep_Duration);
}
DPRINTLN("--- loop *************************************");
}
Basically, you’re saying if I add into the beginning of the loop function that snippet of code of Particle.disconnect(), and Particle.connect() it will do a handshake?