Avatar for user94507

user94507

Member since Oct 2018 • Last active Oct 2018
  • 1 conversations
  • 3 comments

Most recent activity

  • in ESP8266
    Avatar for user94507

    @allObjects ah ya! i have overseen this in your suggestion! Brilliant! The way around beak is perfect. Thank you.

    @Gordon I have tried using the function Array.filter() replacing the inner loop. This works although I must pass a parameter to this function and so the Web Ide warns me "don't use a function within a loop".
    By the way Array.find() is not implemented yet which would have been my favorite choice.

  • in ESP8266
    Avatar for user94507

    Thanks for your tips, you are right there are some other issues. I came not across this yet because I got this compilation error which was irritating me. The mentioned error message does not go away, even with the corrected code. Of course I can remove the the breaks, but the code is not efficient because it does not stop looping when the correct record is found.

  • in ESP8266
    Avatar for user94507

    I have a nested while construct to find a value found in a source array to be within a destination array. When found want to break out from both loops. But it throws an error on the break statement in the outer loop. Could this be an error or do I miss something?

    I am using Espruino 1v99 on a ESP2866

    Here is the code:

    var oWifi = require('Wifi');
    oWifi.scan(function(aAp) {
      aAp.sort(function(a, b) {
        var r = a.rssi === b.rssi ? 0 : (a.rssi < b.rssi ? 1 : -1);
        return r;
      });
      console.log(aAp);
      var i=0, k=0, foundMy=false;
      while (i<aAp.length) {
        foundMy = false;
        while (k<aMyAp.length) {
          if (aAp[i].ssid === aMyAp[i].ssid) {
            foundMy = true;
            break;
          }
          k++;
        }
        if (foundMy) {
          break;  <--- Uncaught SyntaxError: BREAK statement outside of SWITCH, FOR or WHILE loop
        }
        i++;
      }
      if (foundMy) {
        oWifi.connect(aMyAp[k].ssid, {password: aMyAp[k].pwd}, function(err) {
          if (err===null) {
             console.log('Connection success to:', aMyAp[k].ssid);
          }
        });
      } else {
        console.log('no Ap found');
      }
    });
    
Actions