ESP8266 Internet Radio unreliable WiFi data
Posted: Sun Feb 11, 2024 9:24 pm
Hello,
I used a very simple WiFi client to connect to an internet radio stream on a ESP8266 Node V3 board.
I have a big problems with the data reception reliability:
- if I try to receive the data as quick as possible (main loop basically containing if client connected and if client available then read all data and store in a ring buffer) then I read very within 200 ms about 20kB of data, which, however, does not seem to be ok.
I see that is not ok because I detect the meta interval info from the header and I parse the meta info on each interval from the stream.
In this error case the meta section in the received stream occurs in 200 ms interval, and not in 1..1.5 seconds interval as usual. And after receiving 3...5 times this meta info it losses the sync within the stream (means that the chunk meta number after counting the interval has nonsense values (larger than 100). So I have the feeling that the read data from the client is old data repeated.
I found out that if I insert some delay in the reception part (where I read out the data from client) then the thing works, meaning that meta info comes regularly in the specified intervals and losses sync only when the ring buffer overrun (read out from the buffer is slower than the writing to the buffer).
To fix this thing I finally ended up with implementing a dynamic delay on the WIFi client read-out side dependent on the ring buffer fill status. And it works like a charm, nice continuous sound, no buffer overflow, and no missed metadata within 1 hour test period.
So my question would be: is this kind of behavior known? I mean no one had any problems with such kind of setup before?
I appreciate any reply / hint / advice / comment.
I used a very simple WiFi client to connect to an internet radio stream on a ESP8266 Node V3 board.
I have a big problems with the data reception reliability:
- if I try to receive the data as quick as possible (main loop basically containing if client connected and if client available then read all data and store in a ring buffer) then I read very within 200 ms about 20kB of data, which, however, does not seem to be ok.
I see that is not ok because I detect the meta interval info from the header and I parse the meta info on each interval from the stream.
In this error case the meta section in the received stream occurs in 200 ms interval, and not in 1..1.5 seconds interval as usual. And after receiving 3...5 times this meta info it losses the sync within the stream (means that the chunk meta number after counting the interval has nonsense values (larger than 100). So I have the feeling that the read data from the client is old data repeated.
I found out that if I insert some delay in the reception part (where I read out the data from client) then the thing works, meaning that meta info comes regularly in the specified intervals and losses sync only when the ring buffer overrun (read out from the buffer is slower than the writing to the buffer).
To fix this thing I finally ended up with implementing a dynamic delay on the WIFi client read-out side dependent on the ring buffer fill status. And it works like a charm, nice continuous sound, no buffer overflow, and no missed metadata within 1 hour test period.
So my question would be: is this kind of behavior known? I mean no one had any problems with such kind of setup before?
I appreciate any reply / hint / advice / comment.