Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By KrAfLo
#89093 Hello friends,
I use:

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


//------------------------------------------------------------------------------------------------------

Serial.println("-------------Connected Clients List-----------------------");
Serial.print(wifi_softap_get_station_num()); Serial.println(" clients.");

struct station_info *station_list = wifi_softap_get_station_info();
while (station_list != NULL) {
char station_mac[18] = {0}; sprintf(station_mac, "%02X:%02X:%02X:%02X:%02X:%02X", MAC2STR(station_list->bssid));
String station_ip = IPAddress((&station_list->ip)->addr).toString();

Serial.print(station_mac); Serial.print(" "); Serial.println(station_ip);

station_list = STAILQ_NEXT(station_list, next);
}
wifi_softap_free_station_info();
Serial.println();

//------------------------------------------------------------------------------------------------------

This works mostly fine for me, but has a problem!
If connect android device, serial print: connected station numbers and IPs.
When disconnect the info gone (normal).
If connect other NodeMCU (as station), serial print: connected station numbers and IPs.,
but when disconnect the info stay on serial print!?

Please for some help.
Regards
User avatar
By nuprosto4uvak
#90048 Hi!
I try this code.

it works well enough with any device (except esp8266) connected.
with the ESP8266, it "remembers" the device and after disconnecting it all the same shows that the device is connected. This does not happen if you connect your phone, computer, etc.

Any ideas what might be the reason for this?

sohialsadiq wrote:Hi,
solved the problem of getting clients ip address & mac info!


Take care

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(); // Count of stations which are connected to ESP8266 soft-AP
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 adress is = ");
Serial.print((address));
Serial.print(" with mac adress 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.print(stat_info->bssid[5],HEX);

stat_info = STAILQ_NEXT(stat_info, next);
i++;
Serial.println();

}



delay(500);



}