I have a timer sending some sensor readings, if i set the timer for 5 seconds, i'm getting this error Intermittently (once every 20-30 seconds):throw new Error("SSL: alert: " + session.alert.level + ", " + session.alert.description);
If i set the timer to 7 seconds or more, this error does not occur.
I've been digging through docs and i am stumped although I'm sure the answer is in there somewhere.
Is it possible to write configs/preferences to a partition at flash time? If I compiled a moddable program that accepts preferences, I may make it easier
to do fleet provisioning if I can flash configs when I flash the compiled moddable program.
esptool.py
.
I'm basically attempting to recreate this flow:
https://www.youtube.com/watch?v=ZsD59Tg2oCQ
for multiple devices, they're using esptool-js I believe
Yes, it is. Socket is implemented for all the simulators on macOS, Windows, and Linux. That allows just about all the network modules to work. For example, you can run the httpget
example:
cd $MODDABLE/examples/network/http/httpget
mcconfig -d -m
You can run the WebSocket examples the same way. Unfortunately.... the websocketclient
example currently throws an exception because the echo server it uses was recently shut down. But, the example is still correct... if you can find another echo server. ;)
cd $MODDABLE/examples/network/websocket/websocketclient
mcconfig -d -m
let device = compartment.importNow(info.path).default;
Great. So, in this JS file that is loaded by the mcsim (let's call it device.js), which contains code describing the interface and behavior of the simulator (making use of DeviceBehavior and DeviceWorker imported from DevicePane), I just can't import any module. In the beginning of the file, if I for example write
import { Client } from "websocket"
xsbug will raise an error in the mcsim/main.js file when trying to load this device.js file in the reloadDevices function saying that module websocket can't be found.
Right, you can't do that. ;)
What you are overlooking is that within mcsim there are two completely separate JavaScript virtual machines. There is one for mcsim itself, which includes Piu and a handful of other modules from the Moddable SDK. The other virtual machine is for the hosted Moddable SDK project running in the simulator. That project includes whatever modules from the Moddable SDK that your project manifest uses, such as WebSockets. There might be a way to modify mcsim to include some other modules. But, we've never tried because we didn't intend for it to be used that way.
The simulator already has a communication path for you to use. Here's an easy way to see that.
Add these lines at the end of $MODDABLE/examples/helloworld/main.js:
screen.onMessage = function(msg) {
msg = JSON.parse(msg);
screen.postMessage(JSON.stringify({led: msg.button}));
}
Then on the command line, do this:
cd $MODDABLE/examples/helloworld
mcconfig -d -m -p simulator/moddable_two
Now you can blink the light in the simulator, as shown below.
mcsim
simulator is still considered experimental and so we haven't documented it yet. That said, it works well and we use it on nearly every client project we do, so maybe it is finally time to retire the venerable screen test
(our original and still default simulator) and make the switch.