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);
            });
        });
    }
    
  • Sat 2020.09.19

    Hey @user114366 I agree with you that duplicate functions would not be normal. Has the clear screen button in the WebIDE upper left been depressed, before performing the dump?

    Are you able to duplicate this anomaly? I only ask as several months ago, I uncovered nearly the same observation using this very exact module, but was chastised as my observation couldn't be duplicated. I now find it interesting that someone else, using a similar environment has Now come across what I pointed out then. In my case I could duplicate the non-overwriting of an existing object in memory, and it appears that is what you have discovered also. Mine was on a Windows10 laptop. Yours? Had you been uploading code files from the R-Hand editor side along with cut-n-paste snippets into the L-Hand console side?

    Along with dump() has trace() been tried to see if there is a duplicate?

    I also realize that more testing may take you down a time consuming rabbit hole, but should your instance also point to the same similar anomaly, it will help to pin point what is going on.

  • Interesting!

    Yes, what I posted was all the output after the "dump()" command was executed 🙂. Right-hand editor only (except from when using dump()/reset()/trace()). The output of trace does not make sense to me 😏.

    Me:
    Windows 10 desktop
    Espruino IDE 0.73.7
    Upload destination: Flash
    Hardware: Ai-Thinker ESP32-S
    process.env: {
    VERSION: "2v06",
    GIT_COMMIT: "21168a2b",
    BOARD: "ESP32",
    FLASH: 0, STORAGE: 262144, RAM: 524288,
    SERIAL: "8caab5a2-89e8",
    CONSOLE: "Serial1",
    MODULES: "Flash,Storage,hea" ... "r,crypto,neopixel",
    EXPTR: 1073484860 }

    Did you post about the issue back then? Maybe we can continue there then.

    I tried some simpler code (function onInit() { let a = 0; }), but I'm not sure how dump is supposed to work, but if I go to "Device Storage" and inspect the content of "RAM" it seems to hold exactly the same content as dump() outputs (dual onInit() function + pinMode's). If I inspect the .bootcde-file, I see the actual code that I uploaded (single function only, and no pinMode's).

    Just to expand on what I said by RAM before; if I click flash with a = 0, and inspect the RAM, I see two onInit functions there with a = 0. If I set a = 1 and inspect the RAM, I then see two functions with a = 1 (this proving that the data is updated--I temporarily had the idea that the first onInit held some data from an old upload).

    Something else, which might be interesting. If I have let b; outside of a function, the first occurence becomes var b = undefined; (the next still being let b;), but anything inside functions does not seem to be touched. So I guess the first "copy" (before all the pinMode's) is pre-parsed code, but I wonder why the original is still present though.

About

Avatar for Robin @Robin started