ESP8266 Developer Zone The Official ESP8266 Forum 2018-10-12T20:50:08+08:00 https://bbs.espressif.com:443/feed.php?f=66&t=1927 2018-10-12T20:50:08+08:00 2018-10-12T20:50:08+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1927&p=33585#p33585 <![CDATA[Re: wifi_softap_get_station_num]]> https://github.com/espressif/ESP8266_RTOS_SDK

Statistics: Posted by Her Mary — Fri Oct 12, 2018 8:50 pm


]]>
2018-10-06T11:23:58+08:00 2018-10-06T11:23:58+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1927&p=32305#p32305 <![CDATA[Re: wifi_softap_get_station_num]]> i have the same error.
1-when i call wifi_softap_get_station_num() ; it return for example 3 but why when i visit all records in wifi_softap_get_station_info(); then
list has 1 or 2 record!!!???

2-and why when i config esp8266 as softap and connected to it by my laptop then print all record in wifi_softap_get_station_info(); and find my laptop mac and ip so AT THIS TIME i call ESP.restart(); then esp rebooted but i call wifi_softap_get_station_info(); and see for example 3 (a number that larger than 1) and then print all records in wifi_softap_get_station_info(); and see this list is EMPTY!!! at this time i was visit the EMPTY result in by BROWSER and this means my laptop was reconected quickly to ESP but why wifi_softap_get_station_info(); is EMPTY and wifi_softap_get_station_info(); return number larger than 1 !!!

my esp info:
SDK Version Core Version Boot Version
2.2.1(cfd48f3) 2_4_2 31

Statistics: Posted by Guest — Sat Oct 06, 2018 11:23 am


]]>
2018-02-24T06:40:51+08:00 2018-02-24T06:40:51+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1927&p=19440#p19440 <![CDATA[Re: wifi_softap_get_station_num]]> my problem is this:
"Think this needs changing asap as at the moment its telling you a client is connected when its not yet connected ...."
how can fix it ?
please help me?

Statistics: Posted by maab2050 — Sat Feb 24, 2018 6:40 am


]]>
2017-02-26T18:49:20+08:00 2017-02-26T18:49:20+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1927&p=11376#p11376 <![CDATA[Re: wifi_softap_get_station_num]]>
void wifiEventHandler(System_Event_t *event) {
switch (event->event) {
case WIFI_EVENT_SOFTAPMODE_STACONNECTED:
case WIFI_EVENT_SOFTAPMODE_STADISCONNECTED: {
char mac[32] = {0};
snprintf(mac, 32, MACSTR ", aid: %d" , MAC2STR(event->event_info.sta_connected.mac), event->event_info.sta_connected.aid);
Serial.println(mac);
}
break;
}

Per the source code, this is the way the events get generated anyhow:
WiFiEventHandler ESP8266WiFiGenericClass::onSoftAPModeStationConnected(std::function<void(const WiFiEventSoftAPModeStationConnected&)> f)
{
WiFiEventHandler handler = std::make_shared<WiFiEventHandlerOpaque>(WIFI_EVENT_SOFTAPMODE_STACONNECTED, [f](System_Event_t* e){
auto& src = e->event_info.sta_connected;
WiFiEventSoftAPModeStationConnected dst;
memcpy(dst.mac, src.mac, 6);
dst.aid = src.aid;
f(dst);
});
sCbEventList.push_back(handler);
return handler;
}

Ewald

Statistics: Posted by ewald — Sun Feb 26, 2017 6:49 pm


]]>
2016-07-17T23:33:50+08:00 2016-07-17T23:33:50+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1927&p=8000#p8000 <![CDATA[Re: wifi_softap_get_station_num]]> Statistics: Posted by Marco — Sun Jul 17, 2016 11:33 pm


]]>
2016-03-22T21:01:30+08:00 2016-03-22T21:01:30+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1927&p=6190#p6190 <![CDATA[Re: wifi_softap_get_station_num]]>
Most people will check for number of clients connected then immediately get their IP so they can deal with the incoming connection ?

Think this needs changing asap as at the moment its telling you a client is connected when its not yet connected ....

Or even better just have a wifi_connected_on_dhcp_num... which would be much more preferable, is there any point knowing a client has connected but hasnt got its IP yet, as you cant do anything with it ?

Sometimes wifi_softap_get_station_info(); never gets updated when a client has got its IP, at the moment in my code I have to start searching the common IP addresses that the DHCP Server gives out to find a connection, horribly slow and a bad way of doing it, but I have no other options?


Thanks

Statistics: Posted by Fugazi — Tue Mar 22, 2016 9:01 pm


]]>
2016-03-22T10:19:10+08:00 2016-03-22T10:19:10+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1927&p=6185#p6185 <![CDATA[Re: wifi_softap_get_station_num]]>
Yes, wifi_softap_get_station_num is faster than wifi_softap_get_station_info.

wifi_softap_get_station_num will turn to be 1, if a station connected to the ESP8266 softAP.
wifi_softap_get_station_info depends on DHCP. After DHCP done, the station got IP address from ESP8266 softAP, the API will return the information, not null. And so if the DHCP is disable, wifi_softap_get_station_info will always be null.

Statistics: Posted by ESP_Faye — Tue Mar 22, 2016 10:19 am


]]>
2016-03-21T21:57:03+08:00 2016-03-21T21:57:03+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1927&p=6181#p6181 <![CDATA[wifi_softap_get_station_num]]>
Sometimes wifi_softap_get_station_info will stay null with a client connected permanently.

Should wifi_softap_get_station_num be updated after the wifi_softap_get_station_info!=null ?


Total connected_client are = 0
Total connected_client are = 0
Total connected_client are = 1 ->wifi_softap_get_station_info should not be null from here?
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
Total connected_client are = 1
client= 1 ip address is = 192.168.4.2 with mac adress is = 106675E0DB9
Total connected_client are = 1
client= 1 ip address is = 192.168.4.2 with mac adress is = 106675E0DB9
Total connected_client are = 1
client= 1 ip address is = 192.168.4.2 with mac adress is = 106675E0DB9
Total connected_client are = 1


#include <ESP8266WiFi.h>

extern "C" {
#include <user_interface.h>
}

void client_status( )
{

unsigned char number_client;
struct station_info *stat_info;

struct ip_addr *IPaddress;
IPAddress address;
int i=1;

number_client= wifi_softap_get_station_num();
yield();
delay(100);
stat_info = wifi_softap_get_station_info();

Serial.print("Total connected_client are = ");
Serial.println(number_client);

while (stat_info != NULL)
{
IPaddress = &stat_info->ip;
address = IPaddress->addr;

Serial.print("client= ");

Serial.print(i);
Serial.print(" ip address is = ");
Serial.print((address));
Serial.print(" with mac address is = ");

Serial.print(stat_info->bssid[0],HEX);
Serial.print(stat_info->bssid[1],HEX);
Serial.print(stat_info->bssid[2],HEX);
Serial.print(stat_info->bssid[3],HEX);
Serial.print(stat_info->bssid[4],HEX);
Serial.println(stat_info->bssid[5],HEX);

stat_info = STAILQ_NEXT(stat_info, next);
i++;
}
delay(100);
}

void setup() {
Serial.begin(115200);
delay(10);
WiFi.mode(WIFI_AP);
WiFi.softAP("testAP","12345678");
WiFi.printDiag(Serial);
}

void loop ()
{
client_status();
}

Statistics: Posted by Fugazi — Mon Mar 21, 2016 9:57 pm


]]>