Avatar for MarcoM

MarcoM

Member since Jan 2016 • Last active Jan 2016
  • 1 conversations
  • 12 comments

Most recent activity

    • 25 comments
    • 9,720 views
  • in ESP8266
    Avatar for MarcoM

    @Ollie, also thanks for the tip of gitter. I think here i'm going offtopic

  • in ESP8266
    Avatar for MarcoM

    @Ollie, thanks. Now i'm struggling on how i can invoke a function (startServer) just after the wifi.connected. How can i use the callback function of wifi.connected if the wifi parameters are saved outside the lines of code but they was stored before with wifi.save()? How can i callback they? Sorry if it can be a silly question, i'm starting out now with programming.

  • in ESP8266
    Avatar for MarcoM

    Thanks @allObjects, can you explain me what you mean by "sequencer and initializer" (or point me where I can read something about its) I'm a total newbie on JavaScript (trying to learn) and on programming in general (coming from the electronic field).
    Saluti.
    Marco

  • in ESP8266
    Avatar for MarcoM

    @tve, i've tried many times but wifi.save() don't save the wifi paramenters. If power down/up again and i try wifi.getIP() i receive an "wifi is not defined". If i put a save() inside the code and do the power cycle again doing a wifi.getIP() i have a response.
    Maybe because at the moment im using an old version? (1v84.tve_master_588d193).
    I'll try with the latest and i let you know.
    Anyway thanks.

  • in ESP8266
    Avatar for MarcoM

    @tve. I tried to put

    var wifi = require("Wifi");
    wifi.connect("myssid", {password:"mypass"}, function(err){
      console.log("connected? err=", err, "info=", wifi.getIP());
    });
    wifi.stopAP();
    wifi.save();
    

    And i'm connected, but next time i do reset() cycle and i try to write a wifi.getIP() i get this response

    >wifi.getIP()
    Uncaught ReferenceError: "wifi" is not defined
     at line 1 col 5
    wifi.getIP()
        ^
    

    It looks like the code is not stored into the flash

  • in ESP8266
    Avatar for MarcoM

    Ok, got it (honestly i haven't realized what the function E.on do, but anyway... at the moment is working).

    E.on('init', function(){
      
    var wifi = require("Wifi");
      wifi.connect("ssid", {password: "password"},
       function(err){if(err)console.log(err);
                     else {
                       console.log("connesso!");
                       var http = require("http");
                       http.createServer(function (req, res) {
                       res.writeHead(200);
                       res.end("Hello World"); 
                       }).listen(8080);}});
       });
    

    And after send the code, do a save(); to store the program from RAM to FLASH.

    Thanks to everyone as pointed me to the solution.
    Marco

  • in ESP8266
    Avatar for MarcoM

    No.. it works only when i'm connected to the web ide via serial.
    If i try to power the esp standalone, the router don't give me an ip? Where it will be the trick?

  • in ESP8266
    Avatar for MarcoM

    Ok, after a while i successfull built something that seems to work:

    function onInit(){
      
      var wifi = require("Wifi");
      wifi.connect("ssid", {password: "password"},
       function(err){if(err)console.log(err);
                     else {
                       console.log("connesso!");
                       var http = require("http");
                       http.createServer(function (req, res) {
                       res.writeHead(200);
                       res.end("Hello World"); 
    
                       }).listen(8080);}});
      wifi.save();
    
      }
    save();
    

    Since @tve pointed me to the good explanation of @allObjects things are slightly more clear.
    Thanks everyone!

  • in ESP8266
    Avatar for MarcoM

    @tve thanks, I've tried to do a search before post my question but I haven't found that thread. Maybe I did a wrong search.
    @MaBe what I found is that when I do a Wifi setup (from the tve tutorial) and I save it, next time I boot the esp, the settings are not saved and I have to repeat the whole process (I've followed the tutorial step by step). How is that possible?
    Thanks guys, I hope one day I can be useful to the community too.

Actions