Here is the 'chatty' console output, that shows that the method in parsed request / url / or what ever is a "GET" (line 18) and NOT a "POST" as in req.method (line 13..15).... Lines 13..15 were 'progressively' figuring out of req.method returns really must the method as trimmed and as string... (because the logical expression - in original, first post's code line 50 and in my code 66 - just never made it to true).
Another point (about the code in previous post - lines 71..73) I would like to make is:
The statement (line 72)
digitalWrite([LED2,LED1], upd.query.led);
gets lucky just because of the fact that the characters 0, 1, 2 have the same two least significant bits in combination on and of as the integer values 0,1,2,3. With a different coding that ASCII, this fails, and even with ASCII* encoding, it fails for more than 4 output lines / LED's in the array. Therefore (line 73),
makes it clear, and works up to 31 output lines LEDs... again, a comment, such as: // "0..3..9" have same bits on in LNIB as 0..3..9 saves everyone's day - LNIB being Least significant NIBble (half-byte).
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Here is the 'chatty' console output, that shows that the method in parsed request / url / or what ever is a "GET" (line 18) and NOT a "POST" as in req.method (line 13..15).... Lines 13..15 were 'progressively' figuring out of req.method returns really must the method as trimmed and as string... (because the logical expression - in original, first post's code line 50 and in my code 66 - just never made it to true).
Another point (about the code in previous post - lines 71..73) I would like to make is:
The statement (line 72)
gets lucky just because of the fact that the characters 0, 1, 2 have the same two least significant bits in combination on and of as the integer values 0,1,2,3. With a different coding that ASCII, this fails, and even with ASCII* encoding, it fails for more than 4 output lines / LED's in the array. Therefore (line 73),
makes it clear, and works up to 31 output lines LEDs... again, a comment, such as: // "0..3..9" have same bits on in LNIB as 0..3..9 saves everyone's day - LNIB being Least significant NIBble (half-byte).