|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <nvs_flash.h>
#include "display.h"
#include "https_request.h"
#include "stock.h"
#include "wifi.h"
esp_err_t init_nvs() {
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();
}
return ret;
}
void init() {
ESP_ERROR_CHECK(init_display());
ESP_ERROR_CHECK(init_nvs());
ESP_ERROR_CHECK(init_wifi());
ESP_ERROR_CHECK(init_https());
ESP_ERROR_CHECK(init_stock());
}
extern "C" void app_main() {
// TODO: Get internet with GUEST_WLAN
const char* TAG = "app_main";
init();
ESP_LOGI(TAG, "Init finished");
ESP_ERROR_CHECK(connect_wifi(WIFI_SSID, WIFI_PASSWORD));
ESP_LOGI(TAG, "Wifi finished");
xTaskCreate(display_stock_task, "display_stock_task", 1024*4, NULL, configMAX_PRIORITIES-1, NULL);
xTaskCreate(fetch_stock_task, "fetch_stock_task", 1024*4, NULL, configMAX_PRIORITIES-1, NULL);
/*
for(;;) {
ESP_LOGI("mem", "Free heap=%lu", esp_get_free_heap_size());
vTaskDelay(60000 / portTICK_PERIOD_MS);
}
*/
ESP_LOGI(TAG, "main task finished");
}
|