co2-firmware/main/CO2_Sense.c
2022-03-21 23:32:00 +01:00

50 lines
1.2 KiB
C

#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <stdio.h>
#include "nvs_flash.h"
#include "lwip/err.h"
#include "lwip/sys.h"
#include "esp_wifi.h"
#include "esp_log.h"
#include "esp_vfs_fat.h"
#include "APlib.h"
#include "HTTPServe.h"
void app_main(void)
{
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
wifi_config_t wifi_config = wifi_config_generator("CO2Sense","testtest",1);
wifi_init_softap(wifi_config);
const esp_vfs_fat_mount_config_t mount_config = {
.max_files = 10,
.format_if_mount_failed = false,
.allocation_unit_size = CONFIG_WL_SECTOR_SIZE
};
esp_err_t err;
err = esp_vfs_fat_rawflash_mount("/http", "http", &mount_config);
if (err != ESP_OK) {
ESP_LOGE("MAIN", "Failed to mount FATFS (%s)", esp_err_to_name(err));
return;
}
HTTP_serve_config_t serv_config = {
.mountpoint = "/http",
.getUri = "/*",
.postUri = "/*",
};
ESP_ERROR_CHECK(start_server(serv_config));
}