You are reading a single comment by @L0cutus and its replies. Click here to read the full conversation.
  • Did you paste the code into the editor (right hand pane in Espruino Web IDE) and upload it to the board?
    What board are you using?

    It should work, because it responds to the form post...

    The "led" field parameter is either 0, 1, 2 or 3. Line 51 writes the bits of the value to both LEDs. if value 0 = 0b00 comes, it writes 0 to both LEDs, if value 2 = 0b10 comes, green LED turns on and red LED turns off. You can validate this by entering into the console (left hand pane in Espruino Web IDE): digitalWrite([LED2,LED1], 2);

    If you just upload the code, nothing is starting it... Espruino interprets the code and establishes just variables and functions. Therefore type into the console:

    onInit();```
    

    To make life easier while you develop and experiment with variations of the code, add as lasts lines to the code:

    // remove this and next line line before saving code to flash
    setTimeout(onInit,1000);
    
  • Yes, i'm uploading via the code editor panel, after uploading it i write to the console the onInit(); command and it does connect and show me the IP, the "GET" version of this code does work without problems but NOT the "POST" one.

    This code:

        if (r.method == "POST" && r.query && r.query.led)
          digitalWrite([LED2,LED1], r.query.led);
        console.log(r.method);
    

    Line 1 (if ) never exeute the digitlWrite since it find always "GET" as the method and never the "POST"
    line 3 ALWAYS return "GET" not "POST" .
    maybe it is because of i'm loading this server in local ?

    Thanks !

About

Avatar for L0cutus @L0cutus started