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

Moderator: igrr

User avatar
By dynio
#30091 Hello,
I have a problem with wifi_softap_get_station_info().
I use Arduino studio with esp8266 library, Board->Generic ESP8266 Module and try to create AP and get connected clients to this AP using your code listed above.

My code:
Code: Select all#include <ESP8266WiFi.h>
#include<user_interface.h>

const char* APSSID = "AP";
const char* PASSWORD = "password";

void setup() {
  Serial.begin(115200);
  delay(10);
  WiFi.mode(WIFI_AP);
  WiFi.softAP(APSSID,PASSWORD);
}

void loop() {
   // put your main code here, to run repeatedly:
  uint8 softap_stations_cnt;
  struct station_info *stat_info;
  struct ip_addr *IPaddress;
  uint32 uintaddress;
 
  softap_stations_cnt = wifi_softap_get_station_num(); // Count of stations which are connected to ESP8266 soft-AP
  stat_info = wifi_softap_get_station_info();
  Serial.write(softap_stations_cnt);
  while (stat_info != NULL)
  {
    IPaddress = &stat_info->ip;
    uintaddress = IPaddress->addr;
    Serial.write((uintaddress>>24));
    stat_info = STAILQ_NEXT(stat_info, next);
  }
}

And get compile error:
Code: Select alltest.ino.cpp.o: In function `setup':
C:\Program Files (x86)\Arduino/test.ino.ino:17: undefined reference to `wifi_softap_get_station_num()'
C:\Program Files (x86)\Arduino/test.ino.ino:17: undefined reference to `wifi_softap_get_station_info()'
C:\Program Files (x86)\Arduino/test.ino.ino:17: undefined reference to `wifi_softap_get_station_num()'
C:\Program Files (x86)\Arduino/test.ino.ino:17: undefined reference to `wifi_softap_get_station_info()'
collect2.exe: error: ld returned 1 exit status

When I comment #include<user_interface.h> :
Code: Select alltest.ino:23: error: 'wifi_softap_get_station_num' was not declared in this scope
test.ino:24: error: 'wifi_softap_get_station_info' was not declared in this scope
test.ino:28: error: invalid use of incomplete type 'struct loop()::station_info'
...

Could you help me with it ? What i'am doing wrong ?

Regards,
Hubert
User avatar
By sohialsadiq
#31509 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);



}
User avatar
By TridentTD
#37439 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();

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