/* * IdeasX UART Interface * Author: Tyler Berezowsky * Date: 20170518 */ #include "uart_interface.h" //#include "uart.h" static void show_info(void) { printf("SDK: v%s\n", system_get_sdk_version()); printf("Free Heap: %d\n", system_get_free_heap_size()); printf("CPU Frequency: %d MHz\n", system_get_cpu_freq()); printf("System Chip ID: 0x%x\n", system_get_chip_id()); printf("SPI Flash ID: 0x%x\n", spi_flash_get_id()); printf("SPI Flash Size: %d\n", (1 << ((spi_flash_get_id() >> 16) & 0xff))); } static void show_IP(void) { struct ip_info ipconfig; wifi_get_ip_info(STATION_IF, &ipconfig); if (wifi_station_get_connect_status() == STATION_GOT_IP && ipconfig.ip.addr != 0) { printf("IP: %d.%d.%d.%d, MASK: %d.%d.%d.%d, GW: %d.%d.%d.%d\n", IP2STR(&ipconfig.ip), IP2STR(&ipconfig.netmask), IP2STR(&ipconfig.gw)); } else { printf("Network Status: %d\n", wifi_station_get_connect_status()); } } void process_command(uint8_t *str) { if (!strcmp(str, "help")) { printf("available commands\n"); printf(" help - display this message\n"); printf(" ip - show current ip\n"); printf(" wifi - show current and stored configurations\n"); printf(" setup - add new wifi AP\n"); printf(" restart - restart the esp8266\n"); printf(" switch - switch to the other rom and reboot\n"); printf(" info - show device info\n"); printf(" ota - force ota update, switch rom and reboot\n"); printf(" shutdown - force shutdown of module\n"); printf("\n"); } else if (!strcmp(str, "restart")) { printf("Restarting...\n"); system_restart(); } else if (!strcmp(str, "info")) { show_info(); } else if (!strcmp(str, "ip")) { show_IP(); } }