Remote_Wifi_Switch/main/main.c
2025-02-27 16:23:45 +05:30

62 lines
1.1 KiB
C

#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include "esp_log.h"
#include "nvm.h"
#include "port.h"
#include "uart_ifx.h"
#include "wifi_webServer.h"
#include "comms.h"
#include "main.h"
#include "ota.h"
#include "MCP39F501.h"
#include "wifi_OTA.h"
#define IMEI "353165803930522"
static const char* TAG = "MAIN";
uint8_t comms_mode = DEFAULT_COMMS_MODE;
void app_main(void)
{
ESP_LOGI(TAG,"*** Starting app_main ***");
/* Initialize the dedicated NVS partition */
nvm_init();
port_init();
uart_ifx_init();
/* Create the UART tasks for both UART0 and UART1 */
uart_create_rx_tasks();
/* read the comms-mode from the NVS (if any) */
comms_mode = nvm_read_comms_mode();
if((COMMS_OVER_CELL != comms_mode))
{
/* Start On-Boarding process */
webserver_start();
/* Wait till the onboarding process is completed */
while(!webserver_get_status())
{
vTaskDelay(750/portTICK_PERIOD_MS);
port_red_led_toggle();
}
}
ESP_LOGI(TAG," -------------> Wifi Connected ... :)");
port_blue_led_on();
// wifi_ota_start_firmware_update(IMEI);
while(1){
vTaskDelay(100 / portTICK_PERIOD_MS);
}
vTaskDelete(NULL);
}