arduino-ESP8266 icon indicating copy to clipboard operation
arduino-ESP8266 copied to clipboard

All read() methods mixing incomming data from multiple connection to one stream

Open tprochazka opened this issue 9 years ago • 4 comments

ESP8266 support multiple incoming connection which is recognizable by "id" in "+IPD,id,length" string. Problem is that main class directly import Stream interface which is designed handle only one stream.

Related discussion on fix proposal: https://github.com/Diaoul/arduino-ESP8266/pull/14 https://github.com/Diaoul/arduino-ESP8266/pull/14#discussion_r22430400

tprochazka avatar Jan 03 '15 08:01 tprochazka

You can subclass the ESP8266 class to achieve what you want or create a wrapper or use @lasselukkari's ESP8266Server class. The ESP8266 class does not aim to abstract this behavior.

I don't see why you absolutely want the Stream interface to be bound to one id in particular in the low level library. At the low level we see only one Stream: the Serial one so ESP8266 reflects that.

Diaoul avatar Jan 03 '15 09:01 Diaoul

I only want to avoid mix two incoming requests and have possibility to reply to booth of them. This is currently not possible. But if you are OK with it, I will keep my fork. My changes are small so I think that I'm able to live with this and keep it updated by changes from you.

@lasselukkari's ESP8266Server class has this some problem, it doesn't solve this problem.

tprochazka avatar Jan 03 '15 19:01 tprochazka

Why no add a readPacket method that reads exactly one IPD block?

Diaoul avatar Jan 03 '15 21:01 Diaoul

I already wrote, that new method like availablePacket() should be enough. Rename current available to availablePacket() and original available will simply call _serial->available() So available() will be in sync with data() and for waiting for next block will be used new method.

tprochazka avatar Jan 04 '15 21:01 tprochazka