立个标志位监测热点状态
static volatile int g_hotspotStarted = 0;
static void OnHotspotStateChanged(int state)
{
printf("OnHotspotStateChanged: %d.\r\n", state);
if (state == WIFI_HOTSPOT_ACTIVE) {
g_hotspotStarted = 1;
} else {
g_hotspotStarted = 0;
}
}
打印连上的设备的MAC地址
static void PrintStationInfo(StationInfo* info)
{
if (!info) return;
static char macAddress[32] = {0};
unsigned char* mac = info->macAddress;
snprintf(macAddress, sizeof(macAddress), "%02X:%02X:%02X:%02X:%02X:%02X",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
printf(" PrintStationInfo: mac=%s, reason=%d.\r\n", macAddress, info->disconnectedReason);
}
监听有设备加入和离开
static volatile int g_joinedStations = 0;
static void OnHotspotStaJoin(StationInfo* info)
{
g_joinedStations++;
PrintStationInfo(info);