Most recent activity
-
Thanks @Gordon, my issue is solved. i just turn off NPM (Beta) from settings.
-
My code is :
var ws = require('ws'); var Wifi = require("Wifi"); Wifi.connect("123", {password: "456"}, function (ap) { console.log("connected:", ap); }); Wifi.on('connected', function (details) { var x = new Date(); console.log("Connected......", x.toString()); Wifi.getAPDetails(function (detail) { console.log("AP Details : ", detail); }); Wifi.getAPIP(function (detail) { console.log("APIP Details : ", detail); }); Wifi.getDetails(function (detail) { console.log("Details : ", detail); }); Wifi.getDHCPHostname(function (detail) { console.log("DHCP HostnameDetails : ", detail); }); Wifi.getHostname(function (detail) { console.log("Hostname Name : ", detail); }); Wifi.getIP(function (detail) { console.log("IP : ", detail); //server(); socketServer(); }); Wifi.getStatus(function (detail) { console.log("Status : ", detail); }); }); /*Wifi.on('probe_recv', function(details) { console.log("probe Details : ",details); });*/ Wifi.scan(function (detail) { console.log("scan Detail : ", detail); }); Wifi.setHostname("123-esp"); Wifi.on('sta_joined', function (details) { console.log("sta_joined : ", details); }); Wifi.on('sta_left', function (details) { console.log("sta_left : ", details); }); Wifi.startAP('123-esp', {authMode: 'wpa2', password: '456', channel: 13}, function (a, b, c, d) { console.log("startAP::", a, b, c, d); }); /*Wifi.stopAP(function(a,b,c,d){ console.log("stopAP ::",a,b,c,d); });*/ Wifi.save(); function server() { var page = "<html>\n<head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"></head>\n<body style=\"width:100%;height:100%;overflow:hidden;\">\n<svg style=\"width:100%;height:100%;\"\n viewbox=\"0 0 500 500\" id=\"svg\">\n <path\n style=\"fill:#80e5ff;fill-opacity:1;fill-rule:nonzero;stroke:none\"\n d=\"M 250 0 C 111.92882 3.7895613e-14 0 111.92882 0 250 C -1.249508e-14 341.05067 48.689713 420.72528 121.4375 464.4375 L 154.625 409.40625 C 100.50052 376.95218 64.28125 317.69934 64.28125 250 C 64.28125 147.43284 147.43284 64.28125 250 64.28125 C 352.56716 64.28125 435.71875 147.43284 435.71875 250 C 435.71875 317.53896 399.66155 376.65256 345.75 409.15625 L 378.71875 464.34375 C 451.37991 420.61135 500 340.98541 500 250 C 500 111.92882 388.07118 -1.8947806e-14 250 0 z \" id=\"ring\"/>\n <rect\n style=\"fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none\"\n id=\"needle\"\n width=\"16\"\n height=\"80\"\n x=\"242\"/>\n <text\n xml:space=\"preserve\"\n style=\"font-size:122.59261322px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Helvetica;-inkscape-font-specification:Helvetica\"\n x=\"250.01915\"\n y=\"845.31812\"\n id=\"text\"><tspan\n id=\"label\"\n x=\"250.01915\"\n y=\"292.95594\">0</tspan></text>\n <path\n style=\"fill:#d5f6ff;fill-opacity:1;fill-rule:nonzero;stroke:none\"\n id=\"up\"\n d=\"m 294.75099,133.39225 -90.93056,0 45.46528,-78.748173 z\"\n transform=\"matrix(0.61903879,0,0,0.61903879,95.682477,91.16682)\"\n />\n <path\n transform=\"matrix(0.61903879,0,0,-0.61903879,95.682477,408.80767)\"\n d=\"m 294.75099,133.39225 -90.93056,0 45.46528,-78.748173 z\"\n id=\"dn\"\n style=\"fill:#d5f6ff;fill-opacity:1;fill-rule:nonzero;stroke:none\" />\n</svg>\n\n<script>\n// Convert touch to mouse event for mobile devices\nfunction touchHandler(event) {\n var touches = event.changedTouches,\n first = touches[0], type = \"\";\n switch(event.type) {\n case \"touchstart\": type=\"mousedown\"; break;\n case \"touchmove\": type=\"mousemove\"; break; \n case \"touchend\": type=\"mouseup\"; break;\n default: return;\n }\n var simulatedEvent = document.createEvent(\"MouseEvent\");\n simulatedEvent.initMouseEvent(type, true, true, window, 1, \n first.screenX, first.screenY, \n first.clientX, first.clientY, false, \n false, false, false, 0/*left*/, null);\n first.target.dispatchEvent(simulatedEvent);\n event.preventDefault();\n}\ndocument.addEventListener(\"touchstart\", touchHandler, true);\ndocument.addEventListener(\"touchmove\", touchHandler, true);\ndocument.addEventListener(\"touchend\", touchHandler, true);\ndocument.addEventListener(\"touchcancel\", touchHandler, true); \n\n// rotate needle to correct position\nvar pos = 50;\nfunction setPos(p) {\n if (p<0) p=0;\n if (p>100) p=100;\n pos = p;\n document.getElementById(\"label\").textContent = pos; \n var a = (pos-50)*2.8;\n document.getElementById(\"needle\").setAttribute(\"transform\",\"rotate(\"+a+\" 250 250)\"); \n}\nsetPos(pos);\n\n// handle events\nvar dragging = false;\nfunction dragStart() {\n dragging = true;\n document.getElementById(\"ring\").style.fill = \"#ff0000\";\n}\ndocument.addEventListener(\"mousemove\", function(e) {\n if (dragging) {\n e.preventDefault();\n var svg = document.getElementById(\"svg\");\n var ang = Math.atan2(e.clientX-(svg.clientWidth/2),(svg.clientHeight/2)-e.clientY)*180/Math.PI;\n setPos(Math.round((ang/2.8)+50));\n }\n});\ndocument.addEventListener(\"mouseup\", function(e) {\n dragging = false;\n document.getElementById(\"ring\").style.fill = \"#80e5ff\";\n document.getElementById(\"up\").style.fill = \"#d5f6ff\";\n document.getElementById(\"dn\").style.fill = \"#d5f6ff\";\n // POST data to Espruino\n var req=new XMLHttpRequest();\n req.open(\"POST\",\"?pos=\"+pos, true);\n req.send();\n});\ndocument.getElementById(\"ring\").onmousedown = dragStart;\ndocument.getElementById(\"needle\").onmousedown = dragStart;\ndocument.getElementById(\"up\").onmousedown = function(e) { e.preventDefault(); this.style.fill = \"#ff0000\"; };\ndocument.getElementById(\"dn\").onmousedown = function(e) { e.preventDefault(); this.style.fill = \"#00ff00\"; };\ndocument.getElementById(\"up\").onmouseup = function(e) { setPos(pos+10); };\ndocument.getElementById(\"dn\").onmouseup = function(e) { setPos(pos-10); };\n</script>\n</body>\n</html>"; function pageHandler(req, res) { if (req.method == "POST") { // If it's a POST, save the data var info = url.parse(req.url, true); console.log("POST ", info); if (info.query && "pos" in info.query) res.writeHead(200); res.end("Ok."); } else { // otherwise write the page out console.log("GET " + req.url); if (req.url == "/") { res.writeHead(200); res.end(page); } else { res.writeHead(404); res.end("404: Not found"); } } } require("http").createServer(pageHandler).listen(80); } function socketServer() { var page = '<html><body><script>var ws;setTimeout(function(){'; page += 'ws = new WebSocket("ws://" + location.host + "/my_websocket", "protocolOne");'; page += 'ws.onmessage = function (event) { console.log("MSG:"+event.data); };'; page += 'setTimeout(function() { ws.send("Hello to Espruino!"); }, 1000);'; page += '},1000);</script></body></html>'; function onPageRequest(req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.end(page); } var server = ws.createServer(onPageRequest); server.listen(8000); server.on("websocket", function (ws) { ws.on('message', function (msg) { print("[WS] " + JSON.stringify(msg)); }); ws.send("Hello from Espruino!"); }); }
i getting error :
NPM: Checking NPM at http://registry.npmjs.org/Wifi
NPM: Checking NPM at http://registry.npmjs.org/http
loadModule(ws.min)
ERROR: Not Found
NPM: Latest version 0.0.0
NPM: URL https://registry.npmjs.org/http/-/http-0.0.0.tgz
[object Object]
loadModule(http)- ws.min requires ["crypto","net","http"]
Queueing crypto
NPM: Checking NPM at http://registry.npmjs.org/crypto
Queueing net
NPM: Checking NPM at http://registry.npmjs.org/net
Already loading http
ERROR: Not Found
NPM: Latest version 0.0.3
NPM: couldn't find latest tarball
[object Object]
loadModule(crypto)
NPM: Latest version 1.0.2
NPM: couldn't find latest tarball
[object Object]
ERROR: Not Found
loadModule(net)
ERROR: Not Found
WARNING: [notify_warn] Module http not found
ERROR: Not Found
ERROR: Not Found
ERROR: Not Found
WARNING: [notify_warn] Module crypto not found
ERROR: Not Found
WARNING: [notify_warn] Module net not found
please help me for this
- ws.min requires ["crypto","net","http"]
Hello All,
I am New to Espruino and electronics. I Need help for one on my small project of I2C communication between atmega8 an esp8266, I just want to send I2C data from esp8266(master) and read at atmega8(slave[slaveid=1]) and same send data from atmega8(slave) to esp8266(master). any one have any idea? how I can do this....
please help me....
I try as following but still not work, is any one help me to know what I am doing wrong here :
esp8266 code :
Atmega8 code :