Created
November 15, 2019 01:11
-
-
Save gustavosinbandera1/c58706ccd29d6996b939bfdee40ba82f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file main.cpp | |
* @author Locha Mesh Developers ([email protected]) | |
* @brief | |
* @version 0.1 | |
* @date 2019-09-11 | |
* | |
* @copyright Copyright (c) 2019 | |
* | |
*/ | |
#include <sstream> | |
#include <cstdio> | |
#include <freertos/FreeRTOS.h> | |
#include <freertos/task.h> | |
#include "sdkconfig.h" | |
#include <Arduino.h> | |
#include "WiFiMode.h" | |
#include "testRTOSCPP/Hello.hpp" | |
#include "Namespace.h" | |
#include "defaults.h" | |
esp_err_t readWiFiParams(wifi::DTOConfig& wifi_params) { | |
ESP_LOGD(__func__, "Reading WiFi configuration from NVS"); | |
nvs::Namespace wifi_nvs; | |
auto err = wifi_nvs.open("wifi", NVS_READWRITE); | |
if (err != ESP_OK) { | |
return err; | |
} | |
std::stringstream blob; | |
err = wifi_nvs.get_blob("wifi_dto_config", blob); | |
if (err != ESP_OK) { | |
return err; | |
} | |
wifi_params.deserialize(blob); | |
return ESP_OK; | |
} | |
void setDefaultWiFiParams(wifi::DTOConfig& wifi_params) { | |
wifi_params.apChannel = WAP_CHANNEL; | |
wifi_params.apMaxConn = WAP_MAXCONN; | |
wifi_params.WAP_enabled = WAP_ENABLED; | |
wifi_params.WST_enabled = WST_ENABLED; | |
wifi_params.isOpen = false; | |
wifi_params.apSSID = tinystring::String(WAP_SSID); | |
wifi_params.apPassword = tinystring::String(WAP_PASS); | |
} | |
extern "C" void app_main() | |
{ | |
// Initialize arduino as a component | |
initArduino(); | |
// Set logging level for all tags. | |
esp_log_level_set("*", ESP_LOG_VERBOSE); | |
// Initialize NVS. | |
auto nvs_err = nvs::begin(); | |
wifi::DTOConfig wifi_params; | |
nvs::Namespace wifi_nvs; | |
wifi_nvs.open("wifi",NVS_READWRITE); | |
wifi::DTOConfig wifi_params2; | |
setDefaultWiFiParams(wifi_params); | |
std::stringstream blob; | |
std::stringstream blob2; | |
auto err = wifi_nvs.get_blob("wifi", blob2); | |
wifi_params2.deserialize(blob2); | |
/*wifi::mode::begin(wifi_params); */ | |
// TODO: app loop | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment