iperf_example_main.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
  25. repl_config.prompt = "iperf>";
  26. // init console REPL
  27. ESP_ERROR_CHECK(esp_console_repl_init(&repl_config));
  28. /* Register commands */
  29. register_system();
  30. register_wifi();
  31. printf("\n ==================================================\n");
  32. printf(" | Steps to test WiFi throughput |\n");
  33. printf(" | |\n");
  34. printf(" | 1. Print 'help' to gain overview of commands |\n");
  35. printf(" | 2. Configure device to station or soft-AP |\n");
  36. printf(" | 3. Setup WiFi connection |\n");
  37. printf(" | 4. Run iperf to test UDP/TCP RX/TX throughput |\n");
  38. printf(" | |\n");
  39. printf(" =================================================\n\n");
  40. // start console REPL
  41. ESP_ERROR_CHECK(esp_console_repl_start());
  42. }