-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCApp.cpp
More file actions
60 lines (44 loc) · 1.45 KB
/
CApp.cpp
File metadata and controls
60 lines (44 loc) · 1.45 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "CApp.h"
#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
#include "esp_log.h"
#include "nvs_flash.h"
#include "esp_netif.h"
#include "esp_event.h"
const char *CApp::TAGAPP = "tag:App";
void CApp::add_message_to_que(uint16_t msg, uint16_t data)
{
uint32_t m = ((data << 16) + msg);
// RTOS https://www.freertos.org/a00119.html
xQueueSendFromISR(_gpio_evt_queue, (void *)&m, NULL);
}
CApp::CApp()
{
//---------------- log and basic parameters -------//
ESP_LOGI(TAGAPP, "[APP] Startup..");
ESP_LOGI(TAGAPP, "[APP] Free memory: %lu bytes", esp_get_free_heap_size());
ESP_LOGI(TAGAPP, "[APP] IDF version: %s", esp_get_idf_version());
// levels NONE, ERROR, WARN, INFO, DEBUG, VERBOSE
#ifdef BUILD_FOR_RELEASE
esp_log_level_set("*", ESP_LOG_NONE);
#else
esp_log_level_set("*", ESP_LOG_DEBUG);
#endif
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);
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
_gpio_evt_queue = xQueueCreate(/*MAX_QUE_SIZE*/ 10, sizeof(uint32_t));
}
CApp::~CApp()
{
vQueueDelete(_gpio_evt_queue);
}
bool CApp::get_message(uint32_t &message_id)
{
return (xQueueReceive(_gpio_evt_queue, &message_id, portMAX_DELAY));
}