3Hi pol & others,
I looked into this again today, and I think it's been happening for me as well the entire time - I just hadn't noticed it. Sorry!
10 seconds after a client connects to the ESP in SoftAP mode, the AP disassociates it for inactivity (regardless of whether it was active or not). Some of my devices were transparently re-associating without me noticing, but not all of mine were (and some, like my Android phone, actually seem to get stuck where the device thinks it's still associated even though it isn't.)
The short/quick answer is that you can work around this by replacing the SDK's internal hostap timeout function. It's hacky (and it means clients will never get booted for inactivity), but you can do it by adding this code to your program:
void sdk_hostap_handle_timer(void *cnx_node)
{
}
... full explanation of what I think the behaviour around the bug is:
* In libnet80211/ieee80211_hostap.o when hostap_input() sees packets from a new station, it calls a static function which adds the station to the internal connection table - via cnx_node_alloc() - and sets up a timer to call hostap_handle_timer() every 10 seconds (repeating). The argument passed to hostap_handle_timer() is the cnx_node structure that was just allocated.
* hostap_input is also supposed to look up each incoming packet's sender(?) in the internal connection table (cnx_node_search()), and if it finds a matching entry it writes the current count of hardware timer FRC2 to offset 0x108 in the allocated 'cnx_node' structure. This is a "last seen" timestamp.
* Every ten seconds the hostap_handle_timer() function compares the current FRC2 timer count to the stored timestamp, and if they're too far apart (ie no wifi frame received recently) then it sends a disassociation frame to the idle client and removes it using cnx_node_leave().
* cnx_node_leave() itself checks some internal state and prints the "max connection!" message each time it removes an "idle" client. (Unclear if this is a bug itself, or a symptom of the bug.)
... the bug happens because the "last frame receiver" timer value is never written to FRC2 offset 0x108 in hostap_input, this value is always zero so even an active client is disconnected after 10 seconds.
I don't know what causes that buggy behaviour. The bug could be in hostap_input, or maybe the "cnx node" is never properly registered.
I've opened an issue on the mailing list to track this:
https://github.com/SuperHouse/esp-open-rtos/issues/140
Angus
On Tue, May 03, 2016 at 07:27:56AM -0700, pol delgado martín wrote:
> Ok, after some research...
>
> About dhcp:
>
> - dhcp is working fine!
> The dhcp handshake completes succesfully. It can be seen in the captures
> i attached.
> It also can be observed connecting with a client and trying for example
> ifconfig.
> Furthermore before it disconects you can even talk for example to the
> telnet server in the access_point example (see captures attached).
> - Adding router and dns options to dhcp improves the situation, but it
> is not the solution, not even a dirty fix, seconds of difference still not
> usable, at least in my case, almost for sure the issue is not on dhcp
> options (see next point)
>
> - I tried to disable the dhcp server and manually configure the client.
> I telneted succesfully, but after a few time, same issue, the client
> disconnected without even using DHCP!
>
> It is possible to get a stable connection without internet (in fact in my
> captures both devices dumps look almost identical : succesful dhcp hs, no
> dns queries are resolved, some tcp connections missed and icmpv6 messages
> missed too) , taking this into account and If i'm getting things right it
> is not the client's issue.
> As for the captive portal i'm betting it will not solve the problem, as i
> said i get reliable connection without it in other no internet AP devices,
> so not needed for sure.
> We must trace "max connection!" message, it seems that something weird is
> happening at the esp at this moment, maybe then the data link layer packets
> are not handled?
> Any hints for getting more info about it? Thougts?
>
>
> El martes, 8 de septiembre de 2015, 12:23:43 (UTC+2), Michael Jacobsen
> escribió:
> >
> > Hi,
> >
> > Really need the SoftAP-mode and therefore also the DHCP functions. I see
> > that 'libudhcp' is removed due to licensing issues.
> >
> > Any alternatives?
> >
> > /michael
> >
>
> --
> You received this message because you are subscribed to the Google Groups "esp-open-rtos mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
esp-open-rto...@googlegroups.com.
> To post to this group, send email to
esp-op...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/esp-open-rtos/5b8beee2-cb9d-49ad-bfa0-1fccdd8dd63b%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.