Closed hcarter333 closed 1 year ago
Starting from here
var score_params = "tclass=" +
encodeURIComponent(test_type) +
"&name=" + encodeURIComponent(login_user) +
"&elementscores=" + encodeURIComponent(score_str) +
"&passedseen=" + encodeURIComponent(passedseen_str);
//Now send the scores to the db
if (typeof XMLHttpRequest != "undefined") {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.open("GET", '/hamtestscore', true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.onreadystatechange = log_scores_cb;
req.send(score_params);
js message post:
client connected from ('192.168.4.16', 64930)
b'GET /light/on HTTP/1.1\r\nHost: 192.168.4.1\r\nConnection: keep-alive\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36\r\nContent-type: application/x-www-form-urlencoded\r\nAccept: */*\r\nOrigin: null\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: en-US,en;q=0.9\r\n\r\n'
python message post
client connected from ('192.168.4.16', 64952)
b'GET /light/on?msg=k HTTP/1.1\r\nHost: 192.168.4.1\r\nUser-Agent: python-requests/2.31.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n'
So the arguments are missing. The orisingal command in the exam file as a POST. Trying that instead.
Nope:
Trying a better GET
GET mostly works, but sometimes the Pico gets messages sent twice from JavaScript
https://stackoverflow.com/questions/15958026/getting-errno-9-bad-file-descriptor-in-python-socket
No repeated commadns now, just extra commands. Geesh. May have to do with just Python.
Also getting
connection closed [Errno 9] EBADF
connection closed [Errno 9] EBADF
Wound up being caused by an extra client close in the main.py script. It has been resolved.
This isn't going to work without a much more complete web server on the pico-W and a much better understanding of what a web browser typically sends. I'm closing it for now. We have other ways to do this with Python.
Finished for the moment.
Using the code from the ham radio exam, send key down and key up commands over wifi to the pico keyer.