Avatar for espftw

espftw

Member since Feb 2018 • Last active Jul 2019
  • 6 conversations
  • 13 comments

Most recent activity

  • in ESP32
    Avatar for espftw

    When compiling the code, it sometimes says that certain modules cannot be found. These are modules that I created and put in the sandbox/modules dir.

    If I push the same code a few times, it seems to compile the modules correctly on the 2nd or 3rd attempt.

    For the record this is with 9 small modules (sub 20 lines), using v1.99 because I cannot get wifi connection to work on >v2

  • in ESP32
    Avatar for espftw

    How do you use that? I get an error.

  • in ESP32
    Avatar for espftw

    I tried v1.98 which works fine and v2.0 and up work although there is an issue with the WiFi module saying

    ERROR: Wifi: event_handler STA_START: esp_wifi_connect: 12298(SSID is invalid)
    WARNING: Wifi:startMDNS - espressif
    

    Although the connection is in fact successful

    I'm using v1.98 for now because it doesn't crash on requests and doesn't have this WiFi issue.

  • in ESP32
    Avatar for espftw

    Running Espruino 1v99.175 on an ESP32

    This is the same result when I try any of the simple HTTP request examples on the site.

    Guru Meditation Error: Core  0 panic'ed (LoadProhibited)
    . Exception was unhandled.
    Register dump:
    PC      : 0x40118821  PS      : 0x00060f30  A0      : 0x8013b053  A1      : 0x3ffdbec0
    A2      : 0x00000000  A3      : 0x0000414d  A4      : 0x3f40ffc0  A5      : 0x00000000
    A6      : 0x00000001  A7      : 0x00000000  A8      : 0x8011881f  A9      : 0x3ffdbea0
    A10     : 0xfffffff0  A11     : 0x00000000  A12     : 0x00000001  A13     : 0x00000a8c
    A14     : 0x00000000  A15     : 0x00000416  SAR     : 0x0000001e  EXCCAUSE: 0x0000001c
    EXCVADDR: 0xfffffffe  LBEG    : 0x40096b78  LEND    : 0x40096ba6  LCOUNT  : 0x00000000
    Backtrace: 0x40118821:0x3ffdbec0 0x4013b050:0x3ffdbee0 0x4012be86:0x3ffdbf00 0x4012bfe5:0x3ffdbf30 0x4012d5f6:0x3ffdbf50 0x4012d873:0x3ffdc000 0x40151812:0x3ffdc0c0 0x40151837:0x3ffdc120 0x4011a6e7:0x3ffdc180 0x4011d5dd:0x3ffdc200 0x4011ba51:0x3ffdc340 0x4011bb45:0x3ffdc370 0x4011bc08:0x3ffdc390 0x4011bee7:0x3ffdc3b0 0x4011befb:0x3ffdc3d0 0x4011bf0b:0x3ffdc3f0 0x4011cac4:0x3ffdc410 0x4011d040:0x3ffdc430 0x4011d218:0x3ffdc450 0x4011db15:0x3ffdc470 0x4011ba51:0x3ffdc560 0x4011bb45:0x3ffdc590 0x4011bc08:0x3ffdc5b0 0x4011bee7:0x3ffdc5d0 0x4011befb:0x3ffdc5f0 0x4011bf0b:0x3ffdc610 0x4011cac4:0x3ffdc630 0x4011d040:0x3ffdc650 0x4011d218:0x3ffdc670 0x4011db15:0x3ffdc690 0x4011ba51:0x3ffdc780 0x4011bb45:0x3ffdc7b0 0x4011bc08:0x3ffdc7d0 0x4011bee7:0x3ffdc7f0 0x4011befb:0x3ffdc810 0x4011bf0b:0x3ffdc830 0x4011cac4:0x3ffdc850 0x4011d040:0x3ffdc870 0x4011d218:0x3ffdc890 0x4011db15:0x3ffdc8b0 0x4011eca2:0x3ffdc9a0 0x4014c94e:0x3ffdca00 0x4014caa4:0x3ffdca40 0x4014cad9:0x3ffdca70 0x4011a6e7:0x3ffdca90 0x4011d5dd:0x3ffdcb10 0x4011eca2:0x3ffdcc00 0x401206e8:0x3ffdcc60 0x40120c20:0x3ffdcc90 0x40120c80:0x3ffdccd0 0x401223de:0x3ffdccf0
    Rebooting...
    ets Jun  8 2016 00:22:57
    rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_d­rv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:2
    load:0x3fff0018,len:4
    load:0x3fff001c,len:2364
    load:0x40078000,len:0
    load:0x40078000,len:10880
    entry 0x40078c4c
    WARNING: has simple connection not implemented yet
    Loading 15996 bytes from flash...
    Running onInit()...
    
  • started
    • 4 comments
    • 985 views
  • in ESP32
    Avatar for espftw

    If the AP is setup before the WebSocket connection, it fails to connect.

  • in ESP32
    Avatar for espftw

    Sorry for the delayed response, I was dissecting the code and finding the exact moment where it goes wrong. I seem to have found that as soon as wifi.setAP() is called, it prevents execution of all socket transmissions, even those which are called previous to wifi.setAP().

    In the callbacks below, if you halt execution of Setup_AccessPoint() so that wifi.setAP() is never called, the WS.send() functions are successful. However, if Setup_AccessPoint() is called, no previous or subsequent WS.send() calls are successful.

    Seems weird that the previous ones don't work either, but the server never receives the data if wifi.setAP() is called.

    function onInit() {  
      /***************************************­*****************************
       * Import modules
       ****************************************­****************************/
      var 
        wifi = require('Wifi'),
        http = require('http'), 
        WebSocket = require("ws"),
        WebServer = require('WebServer');
      
      /***************************************­*****************************
       * Declare globals & functions
       ****************************************­****************************/
      var
        WS, // stores the WebSocket
        Setup_WiFi = function(callback) {
          console.log('Setup_WiFi is initiating.');
          wifi.connect('MY_WIFI', {password: 'MY_PASSWORD'}, Validate_WiFi(callback)); 
        },
        Validate_WiFi = function(callback) {
          if ( wifi.getIP().ip == '0.0.0.0' ) {
            console.log('[Notice][Validate_WiFi : Connection failed]');
            setTimeout(function(){
              Setup_WiFi(callback);
            } , 1500);
            return;
          } 
          
          console.log('[Notice][Validate_WiFi : Connection successful]');      
          callback();
        },
        Setup_Socket = function(callback) {
          console.log('Setup_Socket is initiating.');
          
          WS = new WebSocket( 'SOCKET_IP' , {
            port: SOCKET_PORT,
            keepAlive: 5000
          });
          
          WS.on('error', function() {
            console.log('Socket error has occurred');
          });
    
          WS.on('open', function() {
            console.log("Connected to socket");
            callback();
          });
    
          WS.on('message', function(data) {
            data = JSON.parse(data);
            console.log('Received data: ');
            console.log(data);
          });
          
        },
        Setup_AccessPoint = function(callback) {
          console.log('Creating AccessPoint.');
          
          
          // ###
          // As soon as the wifi.startAP() is called, no previous 
          // or subsequent socket transmission are successful.
          // ###
          
          wifi.startAP('Sample AP', {}, function(err) {
            // If this point is reached, socket will not work.
            if (err) throw err;
            console.log('AccessPoint is live.');
            callback();
          });
          
        };
    
      
      /***************************************­*****************************
       * Program procedure index
       * 1. Connect to WiFi
       * 2. Connect to WebSocket
       * 3. Create Access Point
       ****************************************­****************************/
      
      /***************************************­*****************************
       * Wait for WiFi connection before proceeding
       ****************************************­****************************/
      Setup_WiFi(function(){
        console.log('Setup_WiFi has finished.');
        Setup_Socket(function(){
          WS.send('Sample data');
          console.log('Setup_Socket has finished.');
          Setup_AccessPoint(function(){
            WS.send('Sample data #2');
            console.log('Setup_AccessPoint has finished.');
          });
        });
      });
      
    }  
    save();
    
Actions