mDot save and restore session
Tagged: deep sleep, mDot Config, Power, save state, Sleep
- This topic has 9 replies, 4 voices, and was last updated 8 years, 8 months ago by
Ashu Joshi.
-
AuthorPosts
-
July 1, 2016 at 11:04 am #13687
Alejandro Veiga
ParticipantI would like to write a program for mDot with the following pseudocode structure:
Configure mDot
Save configuration
Authenticate OTA against Conduit
Save session, keys and all required information (*)
while(1) {
Go into deepsleep
Wake up
Restore session information (*)
Transmit data to Conduit
}
Which would be the recommended way to do this? In particular, the save and restore code (*).
Is there a working example that shows how to do that?
If not, I would be grateful for any suggestions or ideas.-Alejandro
July 1, 2016 at 11:15 am #13688Bryan Tran
ModeratorAlejandro,
Have you seen this – https://developer.mbed.org/teams/MultiTech/code/mDot_LoRa_Sleep_Example/
Thanks,
BT
July 4, 2016 at 8:25 am #13695Alejandro Veiga
ParticipantBrian,
Where can I find documentation about AUTO_OTA mode?
Thanks for your support,
AlejandroJuly 5, 2016 at 9:13 am #13696Bryan Tran
ModeratorJuly 6, 2016 at 8:39 am #13701Alejandro Veiga
ParticipantThanks Brian
July 6, 2016 at 7:05 pm #13716Ashu Joshi
ParticipantBryan:
I have an endless while loop that I enter after setting up the mDot. To understand the platform better – I removed all Tx to the Conduit – that is I am using it just as a microcontroller platform – reading a sensor and printing it out.
I tried both:
dot->sleep(sleep_time, mDot::RTC_ALARM, false);
dot->sleep(sleep_time, mDot::RTC_ALARM);When I use the statement same as in the example – then the execution begins as if the system is restarting – where as False does not put it in deep sleep and my execution starts with the next statement in the While Loop BUT if I use the deep sleep mode – that is not have the false then it restarts.
My question is – what is the difference in power saving between the two modes? Is it significant?
July 6, 2016 at 7:48 pm #13718Ashu Joshi
ParticipantTo add to the above – in both cases – the LED keeps blinking (I had borrowed the routine from mDotHelloWorld to blink the LED (LED1) – and in both case deep sleep with false or implied true – the LED keeps blinking so trying to figure out what is going on. If the mDot CPU is going to sleep then it should stop the LED blinking?
July 6, 2016 at 9:07 pm #13719Jason Reiss
KeymasterYes the led should stop blinking. Did you also borrow the while(true) from the HelloWorld?
Difference between sleep and deepsleep is ~400 uA. RAM is lost in deepsleep and execution resumes at start of main(), as you have noticed, when the program is reloaded from flash.
July 7, 2016 at 8:28 am #13721Ashu Joshi
ParticipantOriginally yes but it has been modified…. I have the following now:
void endLessTestLoop() {
while(true) {
// printf(“Hello world!\r\n”);
printf(“BME280 Sensor: \n”);
readandprintBME280();mDotGotoDeepSleep(60);
}
}The LED Blink was setup before I call this function – endLessTestLoop.
July 9, 2016 at 11:18 am #13871Ashu Joshi
ParticipantI am trying to save the configuration, check it and if it is already set NOT do it all over again. However I am using the network name to check the config setting and cannot get it to work. Please note that the current code is able to join the network, send data and all that good stuff. Now I am trying to save the Configuration, and trying to prevent going through that when coming out of deep sleep.
Here are the details:
1. This is the string I am using to program the network name:
static std::string config_network_name = "MDOTLORANET";
2. Right at the beginning of the main – I call a function mDotConfig() – this first checks if the config is valid, if not then it will go to setup the config.
Here is the code in it (dot is a global):// get a mDot handle dot = mDot::getInstance(); //dot->setLogLevel(mts::MTSLog::INFO_LEVEL); dot->setLogLevel(mts::MTSLog::TRACE_LEVEL); // Test if we've already saved the config logInfo("Checking Config"); std::string configNetworkName = dot->getNetworkName(); printf("Network Name is %s: \n", (char*)(configNetworkName.c_str())); printf("Name being programmed is %s: \n", (char*)(config_network_name.c_str())); if (configNetworkName.compare(config_network_name) != 0) { logInfo("Setting Up Config"); setupNetwork(); } else { logInfo("Config is good, skipping setting up... "); }
My C/C++ skills are really rusty – so quite possible that I am making a mistake BUT here is what I am observing even before I do the string compare:
#1 – before I printf statement – the statement reading the Network Name takes good bit of time – I think a couple of seconds at least or may be more. Not sure what is going on.
#2. It always turns up blank. The string config_network_name prints fine.
Any idea on what may be going on?
-
AuthorPosts
- You must be logged in to reply to this topic.