Hello, I’m interested in changing the config on the fly from another microcontroller through web sockets. I’m wondering if it’s possible to change the LED type and the map function.
Yes, you can set LED type and map data (and map function text) via websockets. Led type is pretty simple. Mapping is slightly more complex.
If you have a previously stored map you want to use, uploading it is straightforward. If you want to allow users (or an agent) to dynamically specify a mapping function, you’ll have to evaluate the function on your microcontroller - the Pixelblaze doesn’t run the javascript mapping functions itself.
That’s done by the WebUI, which uses the browser’s “regular” javascript (not the on-device Pixelblaze subset) to evaluate the function, then saves the resulting coordinates and source code to the device.
Anyway, for an example of how to approach this, see the functions createMapData()/setMapData() and setLedType() in the Pixelblaze client Python library here:
Thank you very much for the reply. I really appreciate that. When I looked at your client yesterday, I saw getLedType but I didn’t see setLedType. I must have missed that. I’ll go back and have another look. Doh: I see now I wasn’t really looking at your definitions too hard. I just saw the gets. I didn’t read to the end of the line and see where you have sets. Feeling pretty stupid now. Thanks for the clarification. ![]()
I have another related question. We were hoping to be able to send the same commands that we could send through web sockets but through a serial port connection. The idea there is that in our potential device we’re going to already have an ESP32, which could use web sockets to the pixelblaze but for reliability’s sake it might be nice to have a permanent dedicated channel for the two of them to communicate.
This has been talked about for a while. It’s up to @wizard! I’d like to have this feature too, even if it’s at a low bit rate.
Right now, you can hijack the sensor board serial connection & protocol to send ad-hoc commands to individual patterns, but there’s nobody listening for the system JSON commands.
Thanks for the reply - @wizard how difficult would this be to add?
Thanks to @zranger1 python script example we are sending commands successfully to the PB over websockets. Similar to this post Pixelblaze becomes unresponsive after a handful of broken websocket connections? we find that if a controlling device is rebooted without closing the websockets connection first results in unable to reestablish a connection. Is there any non websockets command that could be sent to reset the connections or a websockets timeout setting that could be set to help mitigate the need for a power cycle of the PB?
The easiest, most reliable way I’ve found to clean up hanging websocket connections is to just tell the Pixelblaze to reboot, then wait a few seconds to restart.
You can do this from the CLI, or or by calling pixelblaze-client’s reboot() function directly. It uses an HTTP post request, so it bypasses any stalled websocket connections.
I did try a post command to reboot, but perhaps I wasn’t waiting long enough for that to be processed before trying again