2019-05-10 05:17:29 +00:00
|
|
|
#include "CloudStatus.h"
|
2021-03-28 01:19:55 +00:00
|
|
|
#include "../../../Static.h"
|
2019-05-10 05:17:29 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
CloudStatus::onStart()
|
|
|
|
{
|
|
|
|
SINGLE_THREADED_BLOCK() {
|
|
|
|
if (Particle.connected()) {
|
|
|
|
initNetwork(0, cloud_status_connected);
|
|
|
|
} else {
|
|
|
|
System.on(cloud_status, &CloudStatus::initNetwork);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
CloudStatus::initNetwork(system_event_t event, int param) {
|
|
|
|
if (param == cloud_status_connected) {
|
|
|
|
Log.info("Connected to T H E C L O U D");
|
|
|
|
MainLoop::instance()->dispatch(InputEvent{InputEvent::NetworkStatus, true});
|
2021-03-28 01:19:55 +00:00
|
|
|
} else if (param == cloud_status_disconnected) {
|
|
|
|
Log.info("Lost cloud connection!!");
|
|
|
|
MainLoop::instance()->dispatch(InputEvent{InputEvent::NetworkStatus, false});
|
2019-05-10 05:17:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC_ALLOC(CloudStatus);
|