You are reading a single comment by @Robin and its replies. Click here to read the full conversation.
  • Oh, that makes perfect sense, thanks 🙂! Unfortunately it means that I can't easily take the wifi-module source code and add the extra functionaly in there directly--so I have to stick with the current approach.

    Great suggestion with using dump 👍. It does seem a little strange. It's as if some stuff (eg. the onInit) is defined twice. I guess the pinMode is stuff generated by default. This is what I get:

    var ssid = "EDITED OUT";
    var password = "EDITED OUT";
    var Wifi = undefined;
    function onInit() {
      const w = wifi.connect(ssid, { password: password }, () => {
            console.log("Connected");
            Wifi = w;
     
            wifi.enableMDNS("abcd", "iot", 80, function (result) {
                console.log("enableMDNS result: " + result);
            });
        });
    }
    pinMode(D0, "input_pullup", true);
    pinMode(D12, "input_pullup", true);
    pinMode(D13, "input_pullup", true);
    pinMode(D14, "input_pullup", true);
    pinMode(D15, "input_pullup", true);
    pinMode(D18, "input_pullup", true);
    pinMode(D19, "input_pullup", true);
    pinMode(D21, "input_pullup", true);
    pinMode(D22, "input_pullup", true);
    pinMode(D25, "input_pullup", true);
    pinMode(D26, "input_pullup", true);
    pinMode(D27, "input_pullup", true);
    pinMode(D34, "input_pullup", true);
    pinMode(D35, "input_pullup", true);
    pinMode(D36, "input_pullup", true);
    pinMode(D37, "input_pullup", true);
    pinMode(D38, "input_pullup", true);
    pinMode(D39, "input_pullup", true);
    // Code saved with E.setBootCode
    // ****************************************­********************
    // *** IMPORTS
    // ****************************************­********************
    const ssid = "EDITED OUT";
    const password = "EDITED OUT";
    // ****************************************­********************
    // *** IMPORTS / CONSTANTS
    // ****************************************­********************
    //const ssid = "<ACCESS_POINT_SSID>";
    // const password = "<PASSWORD>";
    const wifi = require("Wifi");
    let Wifi = null;
    wifi.enableMDNS = (hostname, serviceType, port, callback) => {
        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 }, () => {
            console.log("Connected");
            Wifi = w;
     
            wifi.enableMDNS("abcd", "iot", 80, function (result) {
                console.log("enableMDNS result: " + result);
            });
        });
    }
    
About

Avatar for Robin @Robin started