-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic HTTP class: Thingspeak and Async OTA #1909
base: dev
Are you sure you want to change the base?
Conversation
0880125
to
1653786
Compare
3076bc9 addresses the continuous sending, but buffer is held by the api user. Anyhow, maybe it is better to follow the ESPAsyncTCP buffered client and keep window-sized / mss-sized buffer until ack is received and only then call the client's callback for the next chunk. At least that way client does not need to allocate anything and directly write to such storage (maybe even as a Stream input) edit: Current Core also has a more up-to-date code regarding buffering: Tested with Thingspeak API on low-mem LWIP locally and connecting to "api.thingspeak.com" |
@mhightower83 sorry to "summon" you and bringing up other pr, ref me-no-dev/ESPAsyncTCP#115 And also thanks for the comment there regarding LWIP_NETIF_TX_SINGLE_PBUF, finally that explains no need for data copy flag. |
@mcspr Sorry, I missed your "summon" :) I have xoseperez/espurna in my watch list so your message got drowned out by the other topics. I am surprised there is no additional annotation for the @ reference. me-no-dev/ESPAsyncTCP#94 was interesting. I think I was just lucky :) I was using the fauxmoESP (wemo version) with around 10 devices configured. The fewer the devices the better it worked. The other element was a Windows system with some additional software that wanted to do UPnP discovery, a lot! With the Windows system off, my sketch stayed up most of the day. With it on, a few hours at most. The crashes appeared to be related to TCP RSTs sent to idle TCP connections on the ESP8266. Back then fauxmoESP did not have With this fixed, the problem with NULL _client emerged in SyncClient type interfaces that may have done a yield, etc. Another corner case was in While my modified version of faumoESP diverged a bit from its roots, I don't remember anything specific I had to change for these issues. These issues were dealt with in the ESPAsyncTCP. It was some effort to preserve the API calling interface and make things work. Correction I remembered one bug: You may want to change these lines in fauxmoESP:
One thought, if you are not ready to clean the AsyncClient object from the parent object, don't delete AsyncClient in the Edited: Added @ |
Thank you! Telnet server uses the same technique btw, but I hope that causes less problems than more aggressive WeMo / Hue discovery. I would probably re-do it though, checking for connection state later in loop, sort of like wifiserver does. fauxmo stuff is more tricky, because I am both not an active user and not really sure which one emulation layer should've stayed at all (if not both at the same time). Using updated ESPAsyncTCP bumps .bin size by ~6kb and is currently failing for ssl builds, however those broken, https://travis-ci.org/mcspr/espurna/jobs/587857201#L522 so this still bums me out :/ (why it wasn't esp/netconn underneath in the first place...) |
@mcspr I am really sorry about the broken SSL builds. There are so many build permutations. I really thought I had done that one; however, I can tell by the remaining unused variable warnings that I had missed it. I have to get rid of those things or I cannot see my errors. I didn't have any examples for ESPAsyncTCP with SSL to build against; however, I thought I had at least set the flag and ran compile. Again I am really sorry. Here is a drop-in replacement for the function that call is in. err_t AsyncServer::_poll(tcp_pcb* pcb){
err_t err = ERR_OK;
if(!tcp_ssl_has_client() && _pending){
struct pending_pcb * p = _pending;
if(p->pcb == pcb){
_pending = _pending->next;
} else {
while(p->next && p->next->pcb != pcb) p = p->next;
if(!p->next) return 0;
struct pending_pcb * b = p->next;
p->next = b->next;
p = b;
}
ASYNC_TCP_DEBUG("### remove from wait: %d\n", _clients_waiting);
AsyncClient *c = new (std::nothrow) AsyncClient(pcb, _ssl_ctx);
if(c){
c->onConnect([this](void * arg, AsyncClient *c){
(void)arg;
_connect_cb(_connect_cb_arg, c);
}, this);
if(p->pb) {
auto errorTracker = c->getACErrorTracker();
c->_recv(errorTracker, pcb, p->pb, 0);
err = errorTracker->getCallbackCloseError();
}
}
// Should there be error handling for when "new AsynClient" fails??
free(p);
}
return err;
} With this replacement, it should at least compile. If you know of any examples that use ESPAsyncTCP with SSL, that you can point me to? I can do a little more. |
No need to be sorry :) While we track down that it builds, idk if I would really advice using it right now since it only supports axtls builds (and as the result tls1.1). I have tried to compile someone else's work regarding bearssl (ref: me-no-dev/ESPAsyncTCP#95 (comment)), which does include a small SyncClient example, but I wanted this PR implemented first to have at least something else to test with. Not really small examples, but there are also 2 other users of ESPAsyncTCP & SSL that I know about: nvm my comment about the size, I was looking at travis01 .bin wrong because it includes influxdb support there. real increase is |
Reuse thingspeak http enhancements with ota module: handle lwip2 low memory, handle status errors, handle lifetime (WIP)
It is pretty basic, only "real" HTTP parsing is for status and body. Expected way to properly do that is by using llparse // llhttp instead of rolling our own http parsing: #1835 (comment)
But I want to try to integrate it with async web server first.
Thingspeak should work, OTA was not tested at all. Using draft PR as a means to track this.