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.
65 lines
1.7 KiB
65 lines
1.7 KiB
#include <sdkconfig.h>
|
|
|
|
#include <console/console.h>
|
|
#include <console/console_ioimpl.h>
|
|
|
|
#include "esp_wifi.h"
|
|
#include "esp_event.h"
|
|
#include "esp_log.h"
|
|
#include "esp_system.h"
|
|
#include "nvs_flash.h"
|
|
|
|
#include "driver/adc.h"
|
|
#include "application.h"
|
|
#include "settings.h"
|
|
|
|
#include "console/console_server.h"
|
|
|
|
#include "web/websrv.h"
|
|
#include "wifi_conn.h"
|
|
|
|
#include "console/register_cmds.h"
|
|
#include "irblast.h"
|
|
|
|
static const char *TAG = "main";
|
|
|
|
void app_main(void) {
|
|
ESP_ERROR_CHECK(nvs_flash_init());
|
|
ESP_ERROR_CHECK(esp_register_shutdown_handler(cspemu_run_shutdown_handlers));
|
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
|
|
|
settings_init();
|
|
settings_load();
|
|
|
|
// Start IDF service for pin change interrupts
|
|
ESP_ERROR_CHECK(gpio_install_isr_service(0));
|
|
|
|
ESP_LOGD(TAG, "initing netif");
|
|
ESP_ERROR_CHECK(esp_netif_init());
|
|
if (g_Settings.wifi_enabled && (g_Settings.sta_enabled || g_Settings.ap_enabled)) {
|
|
initialise_wifi();
|
|
|
|
websrv_init();
|
|
g_State.wifi_inited = true;
|
|
} else {
|
|
// initialise the bare minimum so wifi config can be changed
|
|
ESP_LOGD(TAG, "initing wifi");
|
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
|
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
|
|
|
ESP_LOGD(TAG, "set storage, set sta");
|
|
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_FLASH));
|
|
g_State.wifi_inited = true;
|
|
}
|
|
|
|
irblast_setup();
|
|
|
|
console_init(NULL);
|
|
register_console_commands();
|
|
|
|
console_setup_uart_stdio();
|
|
ESP_ERROR_CHECK(console_start_stdio(NULL, NULL));
|
|
|
|
telnetsrv_start(CONSOLE_TELNET_PORT);
|
|
ESP_LOGI(TAG, "Startup finished, free heap = %u, cmds %"PRIu32, esp_get_free_heap_size(), console_count_commands());
|
|
}
|
|
|