Live Pattern Preview Binary Frames Format


What is the format for the Live Pattern Preview binary frames? In Wireshark, I show the ws binary frame length as 188 bytes.

My understanding is that Pattern Preview Binary Frames are 181 bytes in length and in the following format:

Header: 1 byte (5 designates a preview frame)
Data: 180 bytes (r,g,b - 3 bytes)
Total length: 181

Actual length: 188

Am I missing something?

Thanks for your assistance.

Hi @Kamehana ,

As @Nick_W mentioned here:

So for 60 pixels, you should have a WebSocket frame of 60 * 3 + 2 = 182 bytes.

UPDATE: oops, I should have double checked. It is 60 * 3 + 1 = 181 bytes. These don’t have the flags byte, just the type.

The rest is probably the overhead of the WebSocket protocol itself (WS has it’s own frame headers) and wouldn’t be sent to your WebSocket client application.

If you view this in your browser console’s network tab, you can see the preview frames as they stream from the browser after the websocket protocol has been decoded.

I actually get 181 bytes. It’s possible that preview frames don’t include the second status byte.

In which case I was wrong, the first byte would be 5, the next 180 bytes are 60 r,g,b values.

I’ll take a look at the byte values tomorrow.

Just to confirm: I am trying to get the frames for the live preview window (top of the web interface) for the pattern that currently active.

I get the following error when I try to view the preview frames as they stream from the browser.

Thank you. I appreciate the help/

Ok, it’s as I thought. No status byte.

This is how I decode the first pixel of preview data bytes:

    async def _handle_binary_data(self, data):
        override _handle_binary_data to get preview frames
        if data[0] == self.data_type['preview_frame']:
            self.rgb = (data[1], data[2], data[3])
1 Like

This is great! Thank you.