/** * @brief Execution commad of get module ip. * @param id: commad id number * @retval None */ void ICACHE_FLASH_ATTR GetIpConfig(char * data)//add get station ip and ap ip { struct ip_info pTempIp; os_printf("-%s-%s Wifi mode 1= %d\r\n", __FILE__, __func__, GetWifiMode()); if((GetWifiMode() == 2)||(GetWifiMode() == 3)) { wifi_get_ip_info(0x01, &pTempIp); os_sprintf(data, "%d.%d.%d.%d\r\n", IP2STR(&pTempIp.ip)); } if((GetWifiMode() == 1)||(GetWifiMode() == 3)) { wifi_get_ip_info(0x00, &pTempIp); os_sprintf(data, "%s %d.%d.%d.%d\r\n", data, IP2STR(&pTempIp.ip)); } }
int main() { // Create a socket to communicate with the kernel. skfd = socket( AF_INET, SOCK_DGRAM, 0 ); if( 0 > skfd ) { perror( "Error: Failed to create socket.\n" ); return -1; } char wireless_mode[WIRELESS_MODE_LEN + 1] = ""; if( !( GetWifiMode( wireless_mode ) ) ) { printf( "Error: Failed to get Wireless mode.\n" ); return -1; } printf( "Wireless mode = %s \n", wireless_mode ); unsigned short wireless_channel = 0; if( !( GetWifiChannel( wireless_channel ) ) ) { printf( "Error: Failed to get Wireless channel.\n" ); return -1; } printf( "Wireless channel = %u \n", wireless_channel ); char bssid[MAC_ADDR_LEN] = ""; if( !( GetWifiBssid( bssid ) ) ) { printf( "Error: Failed to get BSSID.\n" ); return -1; } printf( "BSSID = " MACADDR "\n", DEREF_MACADDR( bssid ) ); unsigned int link_speed = 0; if( !( GetWifiLinkSpeed( link_speed ) ) ) { printf( "Error: Failed to get Link speed.\n" ); return -1; } printf( "Link speed = %u \n", link_speed ); unsigned short link_qual = 0; int rssi = 0; if( !( GetWifiLinkQual( link_qual, rssi ) ) ) { printf( "Error: Failed to get Link quality.\n" ); return -1; } printf( "Link quality = %u, Rssi = %d \n", link_qual, rssi ); char protocol[WIRELESS_MODE_LEN + 1 ] = ""; if( !( GetWifiProtocol( protocol ) ) ) { printf( "Error: Failed to get Wireless protocol.\n" ); return -1; } printf( "Wireless protocol = %s \n", protocol ); char ap_mode[WIRELESS_MODE_LEN + 1] = ""; if( !( GetAPMode( ap_mode ) ) ) { printf( "Error: Failed to get AP mode.\n" ); return -1; } printf( "AP mode = %s \n", ap_mode ); char mode[WIRELESS_MODE_LEN + 1] = ""; if( !( GetPhyMode( mode ) ) ) { printf( "Error: Failed to get WiFi mode.\n" ); return -1; } printf( "WiFi mode = %s \n", mode ); // Work done, now close the socket. close( skfd ); return 0; }