-
-
-
-
-
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 -
-
-
-
-
-
Okay Gordon, I'm really not getting it. Here is the Github for what we got goin:
https://github.com/giokincade/autolocatorjs.git
The current file I am deploying is mw-test.js. The relevant code is:
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.1.9" }; wifi.setIP(info, wifi.getIP((err) => { console.log("IP set!"); startServer(); })); } }); };
I checked that it's syntactically valid, etc.-- seems fine. But the Espy is throwing an error w underlying code, I believe. And it is looping the upload process. Here's one cycle. Also, I'm including my deploy process as well. I'm a newbie so some basic mistake is totally possible.
Matts-MacBook-Pro:autolocatorjs mattwalsh$ ./script/deploy + set -e + source script/env +++ espruino --list +++ grep usbmodem +++ awk '{print $1}' +++ head -1 (node:2022) Warning: N-API is an experimental feature and could change at any time. ++ BOARD_PORT=/dev/tty.usbmodem1421 + echo /dev/tty.usbmodem1421 /dev/tty.usbmodem1421 + espruino --port /dev/tty.usbmodem1421 --board board.json --watch src/mw-test.js Espruino Command-line Tool 0.1.31 ----------------------------------- Explicit board JSON supplied: "board.json" Connecting to '/dev/tty.usbmodem1421' (node:2026) Warning: N-API is an experimental feature and could change at any time. Connected Module Wifi not found ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v05 (c) 2019 G.Williams > >Upload Complete Wifi Connected! IP set! Starting Server Uncaught Error: Function "b" not found! at line 1 col 12 if("OK"==a)b(null);else return b("setIP failed: "+(a?a:"Time... ^ in function "c" called from line 1 col 25 g=void 0;var b;c&&(b=c(a))?(g=e,c=b):clearTimeout(d);void 0=... ^ in function "g" called from line 2 col 4 g(f)}b=b.substr(a+1);if(p&&d)return q("");"\n"==b[0]&&(b=b.s... ^ in function called from system Uncaught Error: Function "b" not found! at line 1 col 32 ...OK"==a)b(null);else return b("setIP failed: "+(a?a:"Timeout"... ^ in function "c" called from line 1 col 15 g=void 0;c&&c();void 0===g&&0<k.length&&f.cmd.apply(f,k.shif... ^ in function called from system
What am I doing wrong here? For what it's worth, our initial test.js works:
>Upload Complete Wifi Connected! IP Address: 192.168.1.158 Starting Server Processing request Processing request
The setIP part of this is causing the failure. I don't get it. Any ideas?
-
-
-
-
Hi guys--
I'm writing an application to control an analog tape recorder (Otari MTR-90 MK2, if you're curious.). We created a successful alpha with Arduino UNO and some complex add-on shields, and it's basically working, but we think Espruino Wifi can we do everything we need, and keep it all happily in the land of JS. Plus it's way smaller.
However, we will need to set a hostname, or at the very least an ip address. The Espy will be mounted to the machine and derive power from a voltage regulator fed by the machine-- so basically, it'll boot up when the machine is powered on. There's no direct feedback to the user. I can get a little hello world going, but I can't get the DNS to set.
This is working code, below. Any attempt at setHostname or setIp causes various failures. I'm on firmware 2v05.
THANKS!
const wifi = require("Wifi"); const ws = require("ws"); const WIFI_NAME = "MeowNetJr"; const WIFI_OPTIONS = { password : "cookiejr" }; const connectToWifi = () => { wifi.connect(WIFI_NAME, WIFI_OPTIONS, (err) => { if (err) { console.log("Connection error: " + err); return; } else { console.log("Wifi Connected!"); //wifi.setHostname("my-espy"); //wifi.save(); wifi.getIP((err, info) => { if (info && info.ip) { console.log("IP Address: " + info.ip ); startServer(); } }); } }); }; var page = '<html><body><script>var ws;setTimeout(function(){'; page += 'const ws = new WebSocket("ws://" + location.host);'; page += 'ws.onmessage = function (event) { console.log("MSG:"+event.data); };'; page += 'setTimeout(function() { ws.send("Hello to Espruino!"); }, 1000);'; page += '</script><p>something</p></body></html>'; const onHttpRequest = (request, response) => { console.log("Processing request"); response.writeHead(200, { 'Content-Type': 'text/html' }); response.end(page); }; 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(); } onInit();
-
The PHPOC shield has a separate flashing process that needs to be done in Windows. We don't have a Windows machine so we're running this VM which doesn't always work. It works like 30% of the time so updating code is a hassle. Anyway, once the Espruino gets here it'll be way easier. We'll redo the "server" code in JS and refactor the client in React. It'll be all JS with a simple USB process to update code for now. (Later on, we'll load from the SD.)
So yes, @Robin it works as you described. We have the ins and outs of the Arduino hooked up to a 25 pin Honda connector at the back of the machine. We're basically reading tach pulses and tape direction to do the counter, and sending hi or low to issue the transport commands. The Otari machine controls the motor functions-- we just issue commands.
I'm not sure what we're gonna do when we get this software fully done. But we should prolly do something. It would be amazing to have someone work on the code with us, but how many Otari owners also code. Anyway, thanks to you for your help!
Matt
-
After a day of wrestling with the crappy PHPOC shield, we're ready to try the Espruino. We did manage to read the tachometer and compute counter time accurately and issue all the transport commands.
Here's a little vid of me and my buddies playing with the current iteration.
Matt
-
Cool! Thanks for the info! I'm meeting up with my friends today so this will be helpful.
And yeah, I get it re: Teac. ;) The Ampex is set up as a 2 track altho I do have the 4 track block. The other machine -- Otari MTR-90 mk 2 16 track 2"-- is the one we're doing first. We did a very bad version of hardware and software using an Arduino with a PHPOC shield. It's just not the right idea. But it should be up and working today. I'll post a video if its not disastrous.
But yeah, as soon as the Espruino comes we're gonna ditch the PHPOC.
M
-
-
Thanks again guys. 2.5k might be enough storage, but I'm building one for my friend in Chicago and one for another friend in South Carolina. If I send them an SD card and tell them to edit it they'll figure it out. Asking them to flash a PROM might be too complicated for them.
Also. So when my pals install their devices, I'd like to have them get updates over the internet. So basically, if it detects a new file in a particular S3 bucket, it asks "Do you wanna update?" in the JS, and then it writes the new JS files to the SD, specifies those new files in the config, and reboots. When it reboots, it does its normal routine, and loads the new JS it just downloaded.
So the SD disk needs to hold code, potentially, as well. In fact, my idea is to make the actual application as dumb as possible, and deploy all the real code over the internet. Again, my buddies are not going to want to manage this stuff in any way more complicated than a normal app on the phone.
What do you guys think?
Thanks,
MattPS. This little app is a web-based autolocator/remote for my analog tape recorders.
-
-
Thank you all. I think this will work. I'll probably need some kind of pcb because I'll need to use the SD to store a config file containing WIFI credentials and DNS info for particular installations. So my plan is to write the creds on a Mac or whatever, insert into the SD board connected to the Espruino. When the Espruino boots it reads creds and connects to wifi and starts a webserver.
Best,
Matt -
Interface is not right. But it's working pretty well.