Avatar for Cale

Cale

Member since Jun 2015 • Last active Dec 2016
  • 8 conversations
  • 102 comments

Started into Javascript a few years ago trying to make custom interactive Google Spreadsheets. Expanded slightly into HTML. I work with some PLC systems with work. Love the idea of Espruino and want to help better connect it with Google sheets. Gears are turning on all the possibilities!

Most recent activity

  • in Projects
    Avatar for Cale

    Couldn't you also set up a captive portal with this?

  • in JavaScript
    Avatar for Cale

    Ok got it. Thank you

  • in JavaScript
    Avatar for Cale

    Here is an example that causes errors...

    var wifi;
    var wifiTry = 1;
    function connectWifi(){
      console.log("Connecting to WiFi");
      wifi.connect("access","password", function(err) {
        if (err) {
          throw err;
        }
        console.log("Connected!");
        wifi.getIP(function(e, ip) {
          LED2.set();
          console.log(ip);
        });
      });
    }
    //checks the ESP8266 connection status
    function espStatus(callback){
      wifi.at.cmd('AT+CIPSTATUS\r\n',1000,func­tion(d){
        console.log('ESP8266 '+d);
        var status = d.slice(-1);//get the last character
        if(status == 2){//connection is good
          console.log('good connection');
          wifiTry=0;
        }else if(wifiTry>1){
          clearInterval();//clearInterval is causing issues here
          wifiTry=0;
          console.log('end');
        }else{//connection is bad and we need to reconnect
          wifiTry++;
          console.log('bad connection');
          //need timeout to give esp8266 time to think.
          setTimeout(connectWifi,500);
        }
      });
    }
    
    function onInit() {
      clearInterval();
      E.enableWatchdog(10, true); //should restart the pico if it freezes
      // initialise the ESP8266, after a delay
      setTimeout(function() {
        digitalWrite(B9,1); // enable on Pico Shim V2
        Serial2.setup(115200, { rx: A3, tx : A2 });
        wifi = require("ESP8266WiFi_0v25").connect(Seri­al2, function(err){
          if(err){
            throw err;
          }
          connectWifi();
          setInterval(espStatus, 30000);
        });
      }, 2000);
    }
    

    And this is the error:

    Uncaught Error: Unknown Timeout
     at line 1 col 52
    ...))?(d=p,b=f):clearTimeout(e);void 0===d&&0<g.length&&(a=g.sh...
                                  ^
    in function "d" called from line 1 col 324
    ...c&&(e[c](k),n=!0);n||d&&d(k)}a=a.subs­tr(f+1);"\n"==a[0]&&(a=...
                                  ^
    in function called from system
    
  • in JavaScript
    Avatar for Cale

    under else if statement: Still clearing the setTimeout even though it is run after clearInterval

    function espStatus(callback){
      wifi.at.cmd('AT+CIPSTATUS\r\n',1000,func­tion(d){
        console.log('ESP8266 '+d);
        var status = d.slice(-1);//get the last character
        if(status == 2){//connection is good
          console.log('good connection');
          wifiTry=0;
        }else if(wifiTry>3){
          clearInterval();//clearInterval clears both intervals and timeouts!!
          wifiTry=0;
          setTimeout(startServer,500);
        }else{//connection is bad and we need to reconnect
          wifiTry++;
          console.log('bad connection');
          //need timeout to give esp8266 time to think.
          setTimeout(connectWifi,500);
        }
      });
    }
    
  • in JavaScript
    Avatar for Cale

    ugh... I just seen that. ok

  • in JavaScript
    Avatar for Cale

    Shouldn't the following code output (from console.log()) onInit, foo, bar ?? Instead on onInit, foo ??
    It seems that clearInterval is killing the setTimeout? That's not normal is it?

    function bar(){
      console.log('bar');
    }
    
    function foo(){
      console.log('foo');
      setTimeout(bar, 500);
      clearInterval();
    }
    
    function onInit(){
      console.log('onInit');
      setInterval(foo, 500);
    }
    onInit();
    

    I'm on PICO:

    "VERSION": "1v89.11",
      "BUILD_DATE": "Nov 22 2016",
    
  • in News
    Avatar for Cale

    I set up my own pass through server app that is getting the information where it needs to go. Sorry @Gordon I just do not know what else to do with this. I wonder if this is something to do with my location and country? I did at one time get it to work on the wiznet, but my application would be much nicer with esp8266. I'll keep plugging at it every now and then. Thanks again.

  • in News
    Avatar for Cale

    A minute after gaining wifi connection this all happens right in a row...... no time gap.

    Connecting to Google
    Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    ERROR: Failed! mbedtls_ssl_setup: Not enough memory
    ERROR: Unable to create socket
    Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    Performing the SSL/TLS handshake...
    

    Then after another minute:

    Connecting to Google
    Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    Performing the SSL/TLS handshake...
    ERROR: Failed! mbedtls_ssl_handshake returned Not enough memory
    ERROR: Failed! mbedtls_ssl_handshake returned Public key type mismatch
    
  • in News
    Avatar for Cale

    I recopied everything exactly from the example:

    Connecting to Google
    Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    Performing the SSL/TLS handshake...
    ERROR: Failed! mbedtls_ssl_handshake returned -0x3b10
    ERROR: Failed! mbedtls_ssl_handshake returned -0x4290
    

    I'll also put together a push through node app to get me going in the mean time and I'll keep trying to figure this out from my end. Let me know if you can think of anything else I can try on the Pico.

Actions