You are reading a single comment by @rj and its replies. Click here to read the full conversation.
  • In the original post:

    console.log("Start connection process");
    var wifi = require("ESP8266WiFi_0v25").connect(Seri­al, function(err) {
      if (err)return 1;// throw err;
      Wifi=wifi;
    

    Wifi is set to the result of the connect() function. In your case, wifi is set to the actual library.

  • Ah, I see 🙂. I used the access point feature only, so never really had to call connect, I updated the example, still getting the same error I'm afraid 🤔.

    // ****************************************­********************
    // *** IMPORTS / CONSTANTS
    // ****************************************­********************
    const ssid = "<ACCESS_POINT_SSID>";
    const password = "<PASSWORD>";
    
    const wifi = require("Wifi");
    let Wifi;
    
    wifi.enableMDNS = function (hostname, serviceType, port, callback) {   // <-- Also tried fat-arrow syntax
        let mdns = "AT+MDNS=1," + JSON.stringify(hostname) + "," + JSON.stringify(serviceType) + "," + JSON.stringify(port) + "\r\n";
        Wifi.at.cmd(mdns, 500, function (d) {
            callback(d);
        });
    };
    
    // ****************************************­********************
    // *** MAIN
    // ****************************************­********************
    
    /*
     * Called on boot
     */
    function onInit() {
    
        const w = wifi.connect(ssid, { password: password }, function () {
            console.log("Connected");
            Wifi = w;
            
            wifi.enableMDNS("abcd", "iot", 80, function (result) {
                console.log("enableMDNS result: " + result);
            });
        });
    
    }
    
About

Avatar for rj @rj started