I am using the folllowing RPC loopback call, which successfully updates firmware:
RPC.call (RPC.LOCAL, ‘OTA.Update’, {url:“192.168.1.9/fw/fw.zip”,ignore_same_version:true}, function (resp,ud){print(‘Response:’,JSON.stringify(resp));},null);
However, when the RPC is called when the version to be updated is the same as the currently operating version, the RPC issues a message indicating that the app will not be written, but still loads the file system, switches partitions and reboots.
The desired operation would be to ignore everything and do nothing if the firmware versions are the same. How can I achieve this functionality?
I eventually developed a scheme to do this function as follows:
I created a file with the contents "X.Y"and uploaded it to the remote http server, along with the new firmware upgrade file (fw.zip) I then wrote some code to download the revision info file and parse it into 2 integers.
As a part of the system config, I created new parameters in the config.schema of mos.yml which indicate the current firmware rev number (in this case, it’s 1.3). (By doing it this way, I must manage the update number continuously by updating the config.schema of each newly published firmware revision.)
Then, I use the build created APIs mgos_sys_config_get_frevmajor() and mgos_sys_config_get_frevminor() to retrieve the current version’s major and minor rev integers. Comparing these numbers with the web site retrieved number, I then call the loopback RPC OTA.Update if required.
I use another approach using the group event handler for MGOS_EVENT_OTA_BASE. When MGOS_EVENT_OTA_BEGIN is issued, I compare the current fw_id with the new one and if they are the same I abort the update.