From 6e8b6506634bedc474ef3c5a7c8bee5bc70abd64 Mon Sep 17 00:00:00 2001 From: Brian Campuzano Date: Mon, 20 Feb 2017 22:48:56 -0800 Subject: [PATCH] Added wifi component --- {main => components}/wifi/.gitignore | 0 components/wifi/component.mk | 0 components/wifi/limbo_wifi.c | 25 +++++++++++++++++++++++++ components/wifi/limbo_wifi.h | 4 ++++ 4 files changed, 29 insertions(+) rename {main => components}/wifi/.gitignore (100%) create mode 100644 components/wifi/component.mk create mode 100644 components/wifi/limbo_wifi.c create mode 100644 components/wifi/limbo_wifi.h diff --git a/main/wifi/.gitignore b/components/wifi/.gitignore similarity index 100% rename from main/wifi/.gitignore rename to components/wifi/.gitignore diff --git a/components/wifi/component.mk b/components/wifi/component.mk new file mode 100644 index 0000000..e69de29 diff --git a/components/wifi/limbo_wifi.c b/components/wifi/limbo_wifi.c new file mode 100644 index 0000000..033f75c --- /dev/null +++ b/components/wifi/limbo_wifi.c @@ -0,0 +1,25 @@ + +#include "esp_wifi.h" + +#include "limbo_wifi.h" +#include "skynet.h" + +void limbo_wifi_init(void) +{ + tcpip_adapter_init(); + ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); + ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); + ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); + wifi_config_t sta_config = { + .sta = { + .ssid = LIMBO_SSID, + .password = LIMBO_PASSWORD, + .bssid_set = false + } + }; + ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) ); + ESP_ERROR_CHECK( esp_wifi_start() ); + ESP_ERROR_CHECK( esp_wifi_connect() ); +} diff --git a/components/wifi/limbo_wifi.h b/components/wifi/limbo_wifi.h new file mode 100644 index 0000000..5dfb76d --- /dev/null +++ b/components/wifi/limbo_wifi.h @@ -0,0 +1,4 @@ + + +// Initializes wifi settings for project +void limbo_wifi_init(void);