Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: libmDot-mbed5 ISL29011
Diff: examples/src/ota_example.cpp
- Revision:
- 39:76f8a75ed3ec
- Parent:
- 33:15ea8f985c54
--- a/examples/src/ota_example.cpp Thu May 02 20:47:12 2019 +0000
+++ b/examples/src/ota_example.cpp Thu Dec 19 09:33:42 2019 -0600
@@ -1,6 +1,6 @@
#include "dot_util.h"
#include "RadioEvent.h"
-
+
#if ACTIVE_EXAMPLE == OTA_EXAMPLE
/////////////////////////////////////////////////////////////////////////////
@@ -61,7 +61,7 @@
#endif
mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
-
+
#if CHANNEL_PLAN == CP_US915
plan = new lora::ChannelPlan_US915();
#elif CHANNEL_PLAN == CP_AU915
@@ -85,7 +85,7 @@
// attach the custom events handler
dot->setEvents(&events);
- if (!dot->getStandbyFlag()) {
+ if (!dot->getStandbyFlag() && !dot->getPreserveSession()) {
logInfo("mbed-os library version: %d.%d.%d", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
// start from a well-known state
@@ -103,6 +103,10 @@
logError("failed to set network join mode to OTA");
}
}
+
+ // To preserve session over power-off or reset enable this flag
+ // dot->setPreserveSession(true);
+
// in OTA and AUTO_OTA join modes, the credentials can be passed to the library as a name and passphrase or an ID and KEY
// only one method or the other should be used!
// network ID = crc64(network name)
@@ -162,7 +166,7 @@
// put the LSL29011 ambient light sensor into a low power state
lux.setMode(ISL29011::PWR_DOWN);
-#else
+#else
// get some dummy data and send it to the gateway
light = lux.read_u16();
tx_data.push_back((light >> 8) & 0xFF);
@@ -183,7 +187,7 @@
//sleep_wake_interrupt_only(deep_sleep);
sleep_wake_rtc_or_interrupt(deep_sleep);
}
-
+
return 0;
}