iperf_example_main.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Wi-Fi iperf Example
  2. This example code is in the Public Domain (or CC0 licensed, at your option.)
  3. Unless required by applicable law or agreed to in writing, this
  4. software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  5. CONDITIONS OF ANY KIND, either express or implied.
  6. */
  7. #include <errno.h>
  8. #include <string.h>
  9. #include "esp_wifi.h"
  10. #include "esp_log.h"
  11. #include "esp_err.h"
  12. #include "nvs_flash.h"
  13. #include "esp_console.h"
  14. #include "cmd_decl.h"
  15. void app_main(void)
  16. {
  17. esp_err_t ret = nvs_flash_init();
  18. if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
  19. ESP_ERROR_CHECK(nvs_flash_erase());
  20. ret = nvs_flash_init();
  21. }
  22. ESP_ERROR_CHECK( ret );
  23. initialise_wifi();
  24. esp_console_repl_t *repl = NULL;
  25. esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
  26. esp_console_dev_uart_config_t uart_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();
  27. repl_config.prompt = "iperf>";
  28. // init console REPL environment
  29. ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &repl));
  30. /* Register commands */
  31. register_system();
  32. register_wifi();
  33. printf("\n ==================================================\n");
  34. printf(" | Steps to test WiFi throughput |\n");
  35. printf(" | |\n");
  36. printf(" | 1. Print 'help' to gain overview of commands |\n");
  37. printf(" | 2. Configure device to station or soft-AP |\n");
  38. printf(" | 3. Setup WiFi connection |\n");
  39. printf(" | 4. Run iperf to test UDP/TCP RX/TX throughput |\n");
  40. printf(" | |\n");
  41. printf(" =================================================\n\n");
  42. // start console REPL
  43. ESP_ERROR_CHECK(esp_console_start_repl(repl));
  44. }