examples/protocols/asio: use common network component

* Original commit: espressif/esp-idf@aa4a7804ec
This commit is contained in:
Ivan Grokhotkov
2018-11-21 00:44:31 +08:00
committed by gabsuren
parent de830e51d4
commit 3e7591e92a
36 changed files with 161 additions and 850 deletions

View File

@ -17,6 +17,11 @@
#include <utility>
#include "asio.hpp"
#include "chat_message.hpp"
#include "protocol_examples_common.h"
#include "esp_event.h"
#include "tcpip_adapter.h"
#include "nvs_flash.h"
using asio::ip::tcp;
@ -197,8 +202,21 @@ private:
//----------------------------------------------------------------------
int asio_main()
extern "C" void app_main()
{
ESP_ERROR_CHECK(nvs_flash_init());
tcpip_adapter_init();
ESP_ERROR_CHECK(esp_event_loop_create_default());
/* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.
* Read "Establishing Wi-Fi or Ethernet Connection" section in
* examples/protocols/README.md for more information about this function.
*/
ESP_ERROR_CHECK(example_connect());
/* This helper function configures blocking UART I/O */
ESP_ERROR_CHECK(example_configure_stdin_stdout());
asio::io_context io_context;
std::list<chat_server> servers;
@ -209,6 +227,4 @@ int asio_main()
}
io_context.run();
return 0;
}