-
• #2
Uh, can you clarify what you are looking for?
-
• #3
Yes i have 2x device in my home he is WiFi.. sets getting temperature... every time he from Deep sleep he going to my web server and check last Script..,, in WEB server i have Mydevice.min.js and need to be flash automatically.
-
• #4
I found answer.. http://forum.espruino.com/conversations/283045/
I just use
if need update var fs = new(require("FlashStoreWrite"))(0x7c000); // Save module source in EEPROM fs.item('MyGeneralScript').wget('http://MyScript location'); E.on('init', function() { var fs = new(require("FlashStore"))(0x7c000); require( fs.item('MyGeneralScript').module() ); var MY = require("MyGeneralScript"); });
Full my code:
// Init ESP8266 var ESP8266 = require("ESP8266"); //ESP8266.setLog(1); //ESP8266.printLog(); E.setClock(80); // 18:FE:34:Cb:33:66 var fs = new(require("FlashStoreWrite"))(0x7c000); var rfs=new(require("FlashStore"))(0x7c000); var Config = rfs.item('config').valueOf(); console.log(Config); var sleep = 0; var objectToSend = {}; objectToSend.id = 'd03'; // Init WiFi Networks var wifi = require("Wifi"); wifi.setHostname(objectToSend.id); wifi.connect("XXX", {password:"XXX"}, function(err){ setTimeout(function(){ objectToSend.internalIp = wifi.getIP(); //console.log("connected? err=", err, "info=", wifi.getIP()); initDevice(); },2000); }); wifi.stopAP(); wifi.save(); function initDevice(){ var http = require("http"); http.get("MYLINK", function(res) { res.on('data', function(data) { var tt = JSON.parse(data); sleep = tt.sleep; // Set sleep time if(tt.ver>Config.ver){ console.log("GETTING NEW FIRMWARE"); fs.item('config', tt); // Save new general scipt fs.item('Generalscript').wget('LINK TO MY SCRIPT'); } if(tt.debug==1){ console.log("DEBUG"); digitalWrite(D2,0); // Enable LED startDevice(); }else{ digitalWrite(D2,0); // Disable LED startDevice(); } }); }); } function startDevice(){ // Retrieve module source, add to module cache and then use.. require( fs.item('Generalscript').module() ); var GeneralScript = require("Generalscript").Generalscript; var gs = new GeneralScript(); gs.getVer(); }
This is possibly ?