Avatar for Steffen

Steffen

Member since Jan 2017 • Last active May 2018
  • 6 conversations
  • 18 comments

Most recent activity

  • in JavaScript
    Avatar for Steffen

    The Wifi module builtin since 1.96 (many thanks, Gordon) connects as expected.
    However, it seems to do an extra callback when it connects.
    The code below is supposed to pulse the green LED on success and the red one on wifi timeout.
    On connect both LEDs go on, at the same time.

    var addr=null;
    
    function cbwi(err) {   
        if (err) {
            digitalPulse(LED1, 1, 1000);
            cowi();   
        } else {
            digitalPulse(LED2, 1, 1000);
            wifi.getIP(function(a) {addr=a;});
            net.createServer((conn) => {
                conn.on('close', USB.setConsole);
                conn.pipe(LoopbackA);
                LoopbackA.pipe(conn);
                LoopbackB.setConsole();
            }).listen(23);   
        }
    }
    
    function cowi() {
          wifi.connect('HXNET1',{password:'xxx'}, function(err) {cbwi(err)});
    }
    
    cowi();
    

    While the connection definitely succeeds (ping replies are sent), the value of the variable addr is 'Timeout'. And the telnet server doesn't get startet.
    What's going on here?

  • in Interfacing
    Avatar for Steffen

    Just tried out the HC-SR04 module. As soon as require("HC-SR04").connect(...) is called the sensor fires off and logs the distance - without waiting for sensor.trigger().
    I suggest to correct the module code to include trig.write(0) as the first line.

  • in JavaScript
    Avatar for Steffen

    In case it doesn't work it writes 'WiFi connect failed: FAIL'.

    Actually, the line conn.on('close',function() {USB.setConsole();}) made the Wifi connect work reliably (!).
    The line USB.setConsole() at the end causes Wifi connect to fail.

    Regarding the LEDs, I'd expect the green one to go on once the Wifi connection is established. It doesn't, even when I can telnet to Espruino. Doing LED2.set() from the console works.

  • in JavaScript
    Avatar for Steffen

    Requiring works. However, connect() succeeds only 1 out of 3 times (power off and on again). Here is my code:

    // clean up before: E.setBootCode();
    
    function onInit() {
      setTimeout(function() {
        require('Wifi').connect('SSID',{password­:'mypassword'}, function(err) {
          console.log(err);
          if (err) return;
          require('net').createServer((conn) => {
            conn.pipe(LoopbackA);
            LoopbackA.pipe(conn);
            LoopbackB.setConsole();
          }).listen(23);
        });
      },3000);
    }
    
    // wait a few seconds, then: save();
    

    With the 1v95 build connect() always succeeds.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Steffen

    Thank you, this answers my question. Stuck with 20 bytes for now.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Steffen

    Does there have to be a separate connection for each chunk of 20 bytes (or maybe 6 x 20 bytes as the Nordic docs indicate)?

  • in JavaScript
    Avatar for Steffen

    And if this code, along with the wifi setup (all nicely wrapped in a function), is set e.g. by E.setBootCode(..) - will it come up again after reset()? Such that a new telnet session can be established without cycling power of the device?

Actions