Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Bug Reports
  3. OTA firmware updating is too slow..

OTA firmware updating is too slow..

Scheduled Pinned Locked Moved Bug Reports
23 Posts 7 Posters 6.5k Views 9 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • martinhjelmareM Offline
    martinhjelmareM Offline
    martinhjelmare
    Plugin Developer
    wrote on last edited by
    #13

    I implemented a check for firmware update message in my modified SenseBenderMicro sketch, and alternative behavior in the loop if FW update is ongoing. This doesn't solve the problem of dropped messages, but could be good to speed up the update and don't waste time on sensor updates.

    void loop() {
      if (fwUpdateOngoing) {
        fwUpdateOngoing = false;
        fwUpdateOngoing = wait(OTA_WAIT_PERIOD, C_STREAM, ST_FIRMWARE_RESPONSE);
      } else {
        normalFlow();
      }
    }
    
    void normalFlow() {
      // Short delay to allow buttons to properly settle
      sleep(5);
    
      int buttonValue = digitalRead(BUTTON_PIN);
    
      measureCount ++;
      sendBattery ++;
      bool forceTransmit = false;
      transmission_occured = false;
    #ifndef MY_OTA_FIRMWARE_FEATURE
      if ((measureCount == 5) && highfreq)
      {
        clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
        highfreq = false;
      }
    #endif
    
      if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
        forceTransmit = true;
        measureCount = 0;
      }
    
      sendTempHumidityMeasurements(forceTransmit);
      if (buttonValue != oldValue) {
         // Send in the new buttonValue
         send(msg.set(buttonValue==HIGH ? 0 : 1));
         oldValue = buttonValue;
         transmission_occured = true;
      }
    
    #ifdef MY_OTA_FIRMWARE_FEATURE
      if (transmission_occured) {
        fwUpdateOngoing = wait(OTA_WAIT_PERIOD, C_STREAM, ST_FIRMWARE_RESPONSE);
      }
    #endif
    
      sleep(digitalPinToInterrupt(BUTTON_PIN), CHANGE, MEASURE_INTERVAL);
    }
    
    Mark SwiftM M 2 Replies Last reply
    4
    • martinhjelmareM martinhjelmare

      I implemented a check for firmware update message in my modified SenseBenderMicro sketch, and alternative behavior in the loop if FW update is ongoing. This doesn't solve the problem of dropped messages, but could be good to speed up the update and don't waste time on sensor updates.

      void loop() {
        if (fwUpdateOngoing) {
          fwUpdateOngoing = false;
          fwUpdateOngoing = wait(OTA_WAIT_PERIOD, C_STREAM, ST_FIRMWARE_RESPONSE);
        } else {
          normalFlow();
        }
      }
      
      void normalFlow() {
        // Short delay to allow buttons to properly settle
        sleep(5);
      
        int buttonValue = digitalRead(BUTTON_PIN);
      
        measureCount ++;
        sendBattery ++;
        bool forceTransmit = false;
        transmission_occured = false;
      #ifndef MY_OTA_FIRMWARE_FEATURE
        if ((measureCount == 5) && highfreq)
        {
          clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
          highfreq = false;
        }
      #endif
      
        if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
          forceTransmit = true;
          measureCount = 0;
        }
      
        sendTempHumidityMeasurements(forceTransmit);
        if (buttonValue != oldValue) {
           // Send in the new buttonValue
           send(msg.set(buttonValue==HIGH ? 0 : 1));
           oldValue = buttonValue;
           transmission_occured = true;
        }
      
      #ifdef MY_OTA_FIRMWARE_FEATURE
        if (transmission_occured) {
          fwUpdateOngoing = wait(OTA_WAIT_PERIOD, C_STREAM, ST_FIRMWARE_RESPONSE);
        }
      #endif
      
        sleep(digitalPinToInterrupt(BUTTON_PIN), CHANGE, MEASURE_INTERVAL);
      }
      
      Mark SwiftM Offline
      Mark SwiftM Offline
      Mark Swift
      wrote on last edited by
      #14
      This post is deleted!
      tekkaT 1 Reply Last reply
      0
      • Mark SwiftM Mark Swift

        This post is deleted!

        tekkaT Offline
        tekkaT Offline
        tekka
        Admin
        wrote on last edited by
        #15

        @Mark-Swift I'm not sure I understood you right - can you explain how this applies to the bootloader?

        1 Reply Last reply
        0
        • Mark SwiftM Offline
          Mark SwiftM Offline
          Mark Swift
          wrote on last edited by Mark Swift
          #16
          This post is deleted!
          1 Reply Last reply
          0
          • martinhjelmareM martinhjelmare

            I implemented a check for firmware update message in my modified SenseBenderMicro sketch, and alternative behavior in the loop if FW update is ongoing. This doesn't solve the problem of dropped messages, but could be good to speed up the update and don't waste time on sensor updates.

            void loop() {
              if (fwUpdateOngoing) {
                fwUpdateOngoing = false;
                fwUpdateOngoing = wait(OTA_WAIT_PERIOD, C_STREAM, ST_FIRMWARE_RESPONSE);
              } else {
                normalFlow();
              }
            }
            
            void normalFlow() {
              // Short delay to allow buttons to properly settle
              sleep(5);
            
              int buttonValue = digitalRead(BUTTON_PIN);
            
              measureCount ++;
              sendBattery ++;
              bool forceTransmit = false;
              transmission_occured = false;
            #ifndef MY_OTA_FIRMWARE_FEATURE
              if ((measureCount == 5) && highfreq)
              {
                clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
                highfreq = false;
              }
            #endif
            
              if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
                forceTransmit = true;
                measureCount = 0;
              }
            
              sendTempHumidityMeasurements(forceTransmit);
              if (buttonValue != oldValue) {
                 // Send in the new buttonValue
                 send(msg.set(buttonValue==HIGH ? 0 : 1));
                 oldValue = buttonValue;
                 transmission_occured = true;
              }
            
            #ifdef MY_OTA_FIRMWARE_FEATURE
              if (transmission_occured) {
                fwUpdateOngoing = wait(OTA_WAIT_PERIOD, C_STREAM, ST_FIRMWARE_RESPONSE);
              }
            #endif
            
              sleep(digitalPinToInterrupt(BUTTON_PIN), CHANGE, MEASURE_INTERVAL);
            }
            
            M Offline
            M Offline
            manutremo
            wrote on last edited by
            #17

            Sorry to revive this old topic but I didn't find any other one that covered this topic.

            I started implementing FOTA in all my nodes and was finding some low speeds as described on this topic. I then implemented the checks proposed by @martinhjelmare and they certainly helped :grinning: , although they are not yet perfect.

            As I said I didn't other topics covering how to avoid the node from doing anything else while the FOTA is in place, not did I find any other examples on this web nor in the github mysensors examples folder.

            Is this the only way to do this, or is there any other better way around since this was published?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              manutremo
              wrote on last edited by
              #18

              No wonder, I think I found the way... I found there is a function isFirmwareUpdateOngoing() in MyOTAFirmwareUpdate.cpp that seems to provide that functionality in a much easier way :+1:

              1 Reply Last reply
              1
              • Mark SwiftM Offline
                Mark SwiftM Offline
                Mark Swift
                wrote on last edited by
                #19

                @manutremo please share your method so we can all benefit :)

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  manutremo
                  wrote on last edited by
                  #20

                  If I understood correctly, it should as simple as in loop:

                  if (!isFirmwareUpdateOngoing()) {
                  <do whatever>
                  }

                  but for the moment take it with a pinch of salt...

                  1 Reply Last reply
                  1
                  • Mark SwiftM Offline
                    Mark SwiftM Offline
                    Mark Swift
                    wrote on last edited by
                    #21

                    If I recall I tried that, I seem to remember it only works for the sensebender board? Perhaps I'm mistaken though, it was over 1 year ago. @tekka, can you confirm?

                    tekkaT 1 Reply Last reply
                    1
                    • Mark SwiftM Mark Swift

                      If I recall I tried that, I seem to remember it only works for the sensebender board? Perhaps I'm mistaken though, it was over 1 year ago. @tekka, can you confirm?

                      tekkaT Offline
                      tekkaT Offline
                      tekka
                      Admin
                      wrote on last edited by
                      #22

                      @Mark-Swift Correct, this works only with "online" FOTA, i.e. with boards with separate flash/eeprom HW onboard.

                      1 Reply Last reply
                      1
                      • M Offline
                        M Offline
                        manutremo
                        wrote on last edited by
                        #23

                        ok thanks for the clarification, I'm using a mini pro with a I2C memory, which is identified by the MYSController as a sensebender.

                        1 Reply Last reply
                        1
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        14

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.0k

                        Posts


                        Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • MySensors
                        • OpenHardware.io
                        • Categories
                        • Recent
                        • Tags
                        • Popular