You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Ok, so I do the following:

    • Copy/paste example to right-hand side of IDE
    • change Wifi credentials
    • upload. It says:

      Saving key
      Saving cert
      Saving ca
      Done!
      
    • type 'onInit()'. It says:

      >onInit()
      =undefined
      Connecting to WiFi
      192.168.1.117
      

    Wait a minute, and it says:

    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...
    

    (so it fails)

    • wait another minute, and I get:

      Connecting to Google
      Connecting with TLS...
      Loading the CA root certificate...
      Loading the Client certificate...
      Loading the Client Key...
      Performing the SSL/TLS handshake...
      >Verifying peer X.509 certificate...
      Connected to Google
      Google connection closed, 6294 bytes received
      

    So it works - but it's properly tight on memory.

    What's happening is the first time it's got the command history and other stuff in memory, and it tries to allocate everything it needs but it can't find enough continuous space, even after it's freed everything.

    Next time the history's already been freed so it's able to 'fill the gaps' while executing, leaving a much larger contiguous amount of memory.

    I just modified onInit as follows, and it works first time:

    function onInit() {
      clearInterval();
      // initialise the ESP8266, after a delay
      setTimeout(function() {
        // try and free some memory
        delete fwrite;
        delete onInit;
        global["\xff"].history=[];    
        // original code.....
        digitalWrite(B9,1); // enable on Pico Shim V2
    

    However I've just pushed the new version of the Web IDE (0.65.2) with the send module as function enhancement, so you could give that a try too.

About

Avatar for Gordon @Gordon started