Chat freely about the open source Javascript projects for ESP8266

User avatar
By Erni
#31502 @hygy

I tried your webserver with the latest binaries, and it is running fine.
Sometimes you have to do the upload twice, I don't know why (the first time you get a reset, and the next time it works)
User avatar
By Markus Gritsch
#31511 I also got it working, but it is very fragile. When two requests are performed in quick succession, the device reboots:
Code: Select allled on
{ "free": 747, "usage": 276, "total": 1023, "history": 115 }
led off
{ "free": 747, "usage": 276, "total": 1023, "history": 115 }
led on
{ "free": 747, "usage": 276, "total": 1023, "history": 115 }
led off
{ "free": 747, "usage": 276, "total": 1023, "history": 115 }
led on
{ "free": 747, "usage": 276, "total": 1023, "history": 115 }
led on
{ "free": 747, "usage": 276, "total": 1023, "history": 115 }
led on
ASSERT(pSocketData->currentTx == ((void *)0)) FAILED AT libs/network/esp8266/network_esp8266.c:945
  #1[r1,l2] Object {
    #2[r1,l2] Name String [1 blocks] "ÿ"      #3[r1,l2] Object {
        #6[r1,l2] Name String [2 blocks] "timers"          #8[r2,l1] Array(0) [ ]
        #9[r1,l2] Name String [2 blocks] "watches"          #11[r2,l1] Array(0) [ ]
        #14[r1,l2] Name String [1 blocks] "net"          #51[r1,l3] String [2 blocks] "\x04\x00\x00\x00\x00ÿÿÿ"
        #22[r1,l2] Name String [2 blocks] "history"          #24[r1,l1] Array(27) [
            #46[r1,l2] Name Integer 2              #42[r1,l1] String [6 blocks] "ESP8266WiFi.beAccessPoint('ESP_1610')"
            #47[r1,l2] Name Integer 4              #18[r1,l1] String [3 blocks] "ESP8266WiFi.init();"
            #60[r1,l2] Name Integer 12              #65[r1,l1] String [4 blocks] "    var GPIO2 = new Pin(2);"
            #82[r1,l2] Name Integer 13              #85[r1,l1] String [5 blocks] "    var http = require(\"http\");"
            #170[r1,l2] Name Integer 14              #181[r1,l1] String [81 blocks] "    var httpSrv = http.createServer(function(request, response) {\n        print(process.memory());\n\n        response.write(\"<html><body>\");\n        if (request.url == \"/on\") {\n            response.write(\"<b>LED is on</b>\");\n            digitalWrite(GPIO2, false);\n            print (\"led on\");\n        } else if (request.url == \"/off\") {\n            response.write(\"<b>LED is off</b>\");\n            print (\"led off\");\n            digitalWrite(GPIO2, true);\n        } else {\n            response.write(\"Welcome to ESP with JS\");\n        }\n        response.end(\"<br><a href='/on'>Led ON</a><br><a href='/off'>Led OFF</a></body></html>\");\n    });"
            #270[r1,l2] Name Integer 15              #271[r1,l1] String [4 blocks] "    httpSrv.listen(80);"
            #39[r1,l2] Name Integer 26              #313[r1,l1] String [4 blocks] "ESP8266WiFi.getState()"
          ]
        #80[r1,l2] Name String [2 blocks] "modules"          #91[r1,l1] Object {
            #81[r1,l2] Name String [1 blocks] "http"              #92[r2,l1] ...

          }
        #276[r1,l2] Name String [2 blocks] "HttpS"          #278[r1,l1] Array(1) [
            #279[r1,l2] Name Integer 0              #264[r3,l1] ...

          ]
        #301[r1,l2] Name String [2 blocks] "HttpSC"          #304[r1,l2] Array(10) [
            #296[r1,l3] Name Integer 9              #369[r1,l2] Object {
                #370[r1,l2] Name String [2 blocks] "__proto__"                  #295[r2,l1] ...

                #349[r1,l2] Name String [1 blocks] "type"= int 1

                #302[r1,l2] Name String [1 blocks] "res"                  #405[r1,l2] Object {
                    #323[r1,l2] Name String [2 blocks] "__proto__"                      #298[r2,l1] ...

                    #337[r1,l2] Name String [1 blocks] "code"= int 200

                    #342[r1,l2] Name String [1 blocks] "hdr"                      undefined
                    #329[r1,l2] Name String [1 blocks] "dSnd"                      #384[r1,l2] String [19 blocks] "HTTP/1.0 200 OK\r\nServer: Espruino 1v81.615\r\n\r\n<html><body><b>LED is on</b><br><a href='/on'>Led ON</a><br><a href='/off'>Led OFF</a></body></html>"
                    #368[r1,l2] Name String [2 blocks] "close"                      #350[r1,l1] Bool true
                  }
                #409[r1,l2] Name String [1 blocks] "svr"                  #264[r3,l1] ...

                #359[r1,l2] Name String [1 blocks] "sckt"= int 11

                #412[r1,l2] Name String [1 blocks] "dRcv"                  #382[r1,l1] String [1 blocks] ""
                #400[r1,l2] Name String [2 blocks] "headers"                  #419[r1,l1] Object {
                    #292[r1,l2] Name String [1 blocks] "Host"                      #335[r1,l1] String [2 blocks] "192.168.4.1"
                    #333[r1,l2] Name String [2 blocks] "User-Agent"                      #360[r1,l1] String [10 blocks] "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0"
                    #325[r1,l2] Name String [2 blocks] "Accept"                      #390[r1,l1] String [9 blocks] "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
                    #364[r1,l2] Name String [3 blocks] "Accept-Language"                      #318[r1,l1] String [4 blocks] "de,en-US;q=0.7,en;q=0.3"
                    #317[r1,l2] Name String [3 blocks] "Accept-Encoding"                      #371[r1,l1] String [3 blocks] "gzip, deflate"
                    #305[r1,l2] Name String [2 blocks] "Referer"                      #366[r1,l1] String [4 blocks] "http://192.168.4.1/on"
                    #374[r1,l2] Name String [2 blocks] "Connection"                      #334[r1,l1] String [2 blocks] "keep-alive"
                  }
                #331[r1,l2] Name String [2 blocks] "method"                  #398[r1,l1] String [1 blocks] "GET"
                #406[r1,l2] Name String [1 blocks] "url"                  #415[r1,l1] String [1 blocks] "/on"
                #418[r1,l2] Name String [1 blocks] "hdrs"                  #341[r1,l1] Bool true
              }
          ]
      }
    #16[r1,l2] Name String [2 blocks] "ESP8266WiFi"      #17[r1,l1] NativeFunction 0x402223ac (1) { }
    #25[r1,l2] Name String [2 blocks] "ESP8266State"      undefined
    #64[r1,l2] Name String [2 blocks] "GPIO2"      #83[r1,l1] Pin 2
    #76[r1,l2] Name String [1 blocks] "Pin"      #66[r2,l1] NativeFunction 0x40234148 (9) {
        #45[r1,l2] Name String [2 blocks] "prototype"          #73[r1,l1] Object {
            #78[r1,l2] Name String [2 blocks] "constructor"              #66[r2,l2] ...

          }
      }
    #84[r1,l2] Name String [1 blocks] "http"      #92[r2,l1] NativeFunction 0x40222420 (0) { }
    #172[r1,l2] Name String [2 blocks] "httpSrv"      #264[r3,l1] Object {
        #265[r1,l2] Name String [2 blocks] "__proto__"          #261[r2,l1] Object {
            #262[r1,l2] Name String [2 blocks] "constructor"              #258[r1,l1] NativeFunction 0x40222410 (1) {
                #259[r1,l2] Name String [2 blocks] "prototype"                  #261[r2,l2] ...

              }
          }
        #268[r1,l2] Name String [1 blocks] "type"= int 1

        #267[r1,l2] Name String [2 blocks] "#onconnect"          #167[r1,l1] Function {
            #166[r1,l2] Name Param "request"               undefined
            #164[r1,l2] Name Param "response"               undefined
            #257[r1,l2] Name String [1 blocks] "ÿcod"              #160[r1,l1] String [73 blocks] "{\n        print(process.memory());\n\n        response.write(\"<html><body>\");\n        if (request.url == \"/on\") {\n            response.write(\"<b>LED is on</b>\");\n            digitalWrite(GPIO2, false);\n            print (\"led on\");\n        } else if (request.url == \"/off\") {\n            response.write(\"<b>LED is off</b>\");\n            print (\"led off\");\n            digitalWrite(GPIO2, true);\n        } else {\n            response.write(\"Welcome to ESP with JS\");\n        }\n        response.end(\"<br><a href='/on'>Led ON</a><br><a href='/off'>Led OFF</a></body></html>\");\n    }"
          }
        #280[r1,l2] Name String [1 blocks] "port"= int 80

        #281[r1,l2] Name String [1 blocks] "sckt"= int 1

      }
    #275[r1,l2] Name String [2 blocks] "httpSRq"      #62[r2,l1] NativeFunction 0x40222400 (1) {
        #285[r1,l2] Name String [2 blocks] "prototype"          #295[r2,l1] Object {
            #48[r1,l2] Name String [2 blocks] "constructor"              #62[r2,l2] ...

          }
      }
    #290[r1,l2] Name String [2 blocks] "httpSRs"      #288[r2,l1] NativeFunction 0x402223f0 (1) {
        #77[r1,l2] Name String [2 blocks] "prototype"          #298[r2,l1] Object {
            #294[r1,l2] Name String [2 blocks] "constructor"              #288[r2,l2] ...

          }
      }
    #347[r1,l2] Name String [2 blocks] "process"      #348[r1,l1] NativeFunction 0x402224a0 (1) { }
  }

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 30648, room 16
tail 8
chksum 0x4f
load 0x3ffe8000, len 2108, room 0
tail 12
chksum 0x00
ho 0 tail 12 room 4
load 0x3ffe8840, len 28804, room 12
tail 8
chksum 0xb6
csum 0xb6
nîsys=68011 rtc=50447953
don't use rtc mem data

I added this issue: https://github.com/espruino/Espruino/issues/673

Edit: This is now fixed in Build for 2015-10-18
Last edited by Markus Gritsch on Mon Oct 19, 2015 1:24 am, edited 1 time in total.
User avatar
By hygy
#31641 @Markus Gritsch I think this is the same bug. :)

But now I saved a new js code, and I cannot use the board anymore couse it is alwayes resetting, how can I save() a new empy code, or stg working code?

thanks
HyGy
User avatar
By Markus Gritsch
#31649 I had the same behaviour yesterday, after saving the simple webserver example in the onInit() function.

Reflashing the board with the Espruino binaries does also not help, because this does not overwrite the respective region in the flash, where the state is saved when calling save().

So depending on the firmware upload software you use you have to erase all flash, or flash the empty bin to the board, to overwrite the saved state.