• I've been able to get a bunch of stuff to work from the IDE => RAM, then I figured out how to get it going properly from USB (no computer/IDE) by removing onInit(); and using save() command. So yeah, that works when powered over USB cube.

    However, when I apply 5V to the VUSB pin, it just flashes a blue light on and off... Not sure why it works in all circumstances but this?

    Thoughts?

    const wifi = require("Wifi");
    const ws = require("ws");
    
    const WIFI_NAME = "OceanusStudio";
    const WIFI_OPTIONS = { password : "studio125" };
    
    const connectToWifi = () => {
    	wifi.connect(WIFI_NAME, WIFI_OPTIONS, (err)  => {
    		if (err) {
    		  //console.log("Connection error: " + err);
    		  return;
    		} else {
    			//console.log("Wifi Connected!");
    
    			var info = {
    					ip: "192.168.0.159",
    					gw: "192.168.0.1",
    					netmask: "255.255.255.0"
    			};
    
    			wifi.setIP(info, (err) => {
    					//console.log("IP set!");
    					startServer();
    			});
    		}
    	});
    };
    
    const getPage = () => {
    	var today = new Date();
    	var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
    	return 'allo guv :: ' + time;
    };
    
    const onHttpRequest = (request, response) => {
    	//console.log("Processing request");
    	response.writeHead(200, { 'Content-Type': 'text/html' });
    	response.end(getPage());
    };
    
    const startServer = () => {
    	//console.log("Starting Server");
    	ws
    		.createServer(onHttpRequest)
    		.listen(80)
    		.on("websocket", (socket) => {
    			//console.log("websocket connection");
    			socket.on("message", (msg) => {
    				//console.log("websocket message: " + msg);
    				socket.send("pong");
    			});
    		});
    
    };
    
    function onInit() {
    	connectToWifi();
    }
    

    Thanks!
    Matt

About

Avatar for mattw @mattw started