You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
#include "freertos/FreeRTOS.h" |
|
#include "esp_system.h" |
|
|
|
#include "nx/firmware/Storage.h" |
|
#include "nx/firmware/Wifi.h" |
|
#include "nx/firmware/MqTriggerHttpServer.h" |
|
#include "nx/software/nxSystemSettings.h" |
|
|
|
#include "esp_log.h" |
|
|
|
#include <string.h> |
|
|
|
#define TAG "MAIN" |
|
|
|
static const char* DEVICE_NAME_PREFIX = "mqtrigger-"; |
|
|
|
static SystemSettings* systemSettings = NULL; |
|
static WifiSettings wifiSettings; |
|
|
|
void app_main(void) |
|
{ |
|
nxInitStorage(); |
|
|
|
nxInitSystemSettings(nxStorageWrite, nxStorageRead, esp_restart); |
|
ESP_LOGI(TAG, "System settings initialized"); |
|
systemSettings = nxGetSystemSettings(); |
|
|
|
strcpy(systemSettings->wifiSsid, "cintra"); |
|
strcpy(systemSettings->wifiPassword, "fffefdfcfb"); |
|
systemSettings->useStaticAddr = true; |
|
systemSettings->ip4addr[3] = 91; |
|
|
|
wifiSettings = (struct WifiSettings){ |
|
.wname = systemSettings->wifiSsid, |
|
.wpass = systemSettings->wifiPassword, |
|
.devicePrefix = DEVICE_NAME_PREFIX, |
|
.usePowerSave = &(systemSettings->wifiPowerSave), |
|
.useStaticAddr = &(systemSettings->useStaticAddr), |
|
.ip4addr = systemSettings->ip4addr, |
|
.ip4gw = systemSettings->ip4gw, |
|
.ip4mask = systemSettings->ip4mask |
|
}; |
|
|
|
ESP_LOGI(TAG, "Initializing WiFi"); |
|
nxInitWifi(&wifiSettings); |
|
nxStartMqTriggerHttpServer(); |
|
} |
|
|
|
|