Diaoul / arduino-ESP8266

An Arduino library to manage the ESP8266.
MIT License
68 stars 46 forks source link

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

Open tprochazka opened 9 years ago

tprochazka commented 9 years ago

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

Diaoul commented 9 years ago

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.

tprochazka commented 9 years ago

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.

Diaoul commented 9 years ago

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

tprochazka commented 9 years ago

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.