mDot save and restore session

Home Forums mDot/xDot mDot save and restore session

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #13687
    Alejandro Veiga
    Participant

    I 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

    #13688
    Bryan Tran
    Moderator
    #13695
    Alejandro Veiga
    Participant

    Brian,
    Where can I find documentation about AUTO_OTA mode?
    Thanks for your support,
    Alejandro

    #13696
    Bryan Tran
    Moderator
    #13701
    Alejandro Veiga
    Participant

    Thanks Brian

    #13716
    Ashu Joshi
    Participant

    Bryan:

    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?

    #13718
    Ashu Joshi
    Participant

    To 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?

    #13719
    Jason Reiss
    Keymaster

    Yes 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.

    #13721
    Ashu Joshi
    Participant

    Originally 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.

    #13871
    Ashu Joshi
    Participant

    I 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?

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.