uart_interface.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * IdeasX UART Interface
  3. * Author: Tyler Berezowsky
  4. * Date: 20170518
  5. */
  6. #include "uart_interface.h"
  7. //#include "uart.h"
  8. static void show_info(void)
  9. {
  10. printf("SDK: v%s\n", system_get_sdk_version());
  11. printf("Free Heap: %d\n", system_get_free_heap_size());
  12. printf("CPU Frequency: %d MHz\n", system_get_cpu_freq());
  13. printf("System Chip ID: 0x%x\n", system_get_chip_id());
  14. printf("SPI Flash ID: 0x%x\n", spi_flash_get_id());
  15. printf("SPI Flash Size: %d\n", (1 << ((spi_flash_get_id() >> 16) & 0xff)));
  16. }
  17. static void show_IP(void)
  18. {
  19. struct ip_info ipconfig;
  20. wifi_get_ip_info(STATION_IF, &ipconfig);
  21. if (wifi_station_get_connect_status() == STATION_GOT_IP && ipconfig.ip.addr != 0) {
  22. printf("IP: %d.%d.%d.%d, MASK: %d.%d.%d.%d, GW: %d.%d.%d.%d\n",
  23. IP2STR(&ipconfig.ip), IP2STR(&ipconfig.netmask), IP2STR(&ipconfig.gw));
  24. } else {
  25. printf("Network Status: %d\n", wifi_station_get_connect_status());
  26. }
  27. }
  28. void process_command(uint8_t *str)
  29. {
  30. if (!strcmp(str, "help"))
  31. {
  32. printf("available commands\n");
  33. printf(" help - display this message\n");
  34. printf(" ip - show current ip\n");
  35. printf(" wifi - show current and stored configurations\n");
  36. printf(" setup - add new wifi AP\n");
  37. printf(" restart - restart the esp8266\n");
  38. printf(" switch - switch to the other rom and reboot\n");
  39. printf(" info - show device info\n");
  40. printf(" ota - force ota update, switch rom and reboot\n");
  41. printf(" shutdown - force shutdown of module\n");
  42. printf("\n");
  43. }
  44. else if (!strcmp(str, "restart"))
  45. {
  46. printf("Restarting...\n");
  47. system_restart();
  48. }
  49. else if (!strcmp(str, "info"))
  50. {
  51. show_info();
  52. }
  53. else if (!strcmp(str, "ip"))
  54. {
  55. show_IP();
  56. }
  57. }