Added error check codes.
This commit is contained in:
parent
f51897532c
commit
780baa4f78
|
@ -32,7 +32,7 @@ jobs:
|
||||||
working-directory: "build"
|
working-directory: "build"
|
||||||
|
|
||||||
- name: "Run CodeChecker"
|
- name: "Run CodeChecker"
|
||||||
run: "codechecker analyze compile_commands.json -o results --ignore ../.codechecker-skip.txt"
|
run: "codechecker analyze compile_commands.json -o results -i ../.codechecker-skip.txt --ctu"
|
||||||
working-directory: "build"
|
working-directory: "build"
|
||||||
|
|
||||||
- name: "Generate HTML reports"
|
- name: "Generate HTML reports"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __USER_CONFIG_DRIVER_H
|
#define __USER_CONFIG_DRIVER_H
|
||||||
|
|
||||||
#include <libconfig.h>
|
#include <libconfig.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
config_t *libconfig_cfg;
|
config_t *libconfig_cfg;
|
||||||
|
@ -11,6 +12,7 @@ int user_config_init(user_config_t *config, char *config_file);
|
||||||
char *user_config_lookup_string(user_config_t *config, char *path);
|
char *user_config_lookup_string(user_config_t *config, char *path);
|
||||||
int user_config_lookup_int(user_config_t *config, char *path, int *value);
|
int user_config_lookup_int(user_config_t *config, char *path, int *value);
|
||||||
int user_config_lookup_double(user_config_t *config, char *path, double *value);
|
int user_config_lookup_double(user_config_t *config, char *path, double *value);
|
||||||
|
int user_config_lookup_bool(user_config_t *config, char *path, bool *value);
|
||||||
int user_config_deinit(user_config_t *config);
|
int user_config_deinit(user_config_t *config);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
|
|
||||||
void user_lvgl_impl_init(void);
|
int user_lvgl_impl_init(void);
|
||||||
|
|
||||||
void user_lvgl_impl_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area,
|
void user_lvgl_impl_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area,
|
||||||
lv_color_t *color_p);
|
lv_color_t *color_p);
|
||||||
|
|
|
@ -54,7 +54,7 @@ ccs811_ret_t _ccs811_app_start(ccs811_t *ccs) {
|
||||||
if(ccs->cb.read_register_cb(ccs->user_data, 0x00, &status, 0x01) == CCS_FAIL) {
|
if(ccs->cb.read_register_cb(ccs->user_data, 0x00, &status, 0x01) == CCS_FAIL) {
|
||||||
return CCS_FAIL;
|
return CCS_FAIL;
|
||||||
}
|
}
|
||||||
if(status & 0x10 == 0) {
|
if((status & 0x10) == 0) {
|
||||||
return CCS_FAIL;
|
return CCS_FAIL;
|
||||||
}
|
}
|
||||||
return ccs->cb.write_register_cb(ccs->user_data, 0xF4, (uint8_t *)0x00, 0x00);
|
return ccs->cb.write_register_cb(ccs->user_data, 0xF4, (uint8_t *)0x00, 0x00);
|
||||||
|
|
|
@ -17,9 +17,12 @@ static int concat_string(char *dest, int dest_length, char *append) {
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
mqtt_influx_ret_t mqtt_influx_init(mqtt_influx_t *influx) {
|
mqtt_influx_ret_t mqtt_influx_init(mqtt_influx_t *influx) {
|
||||||
|
if(influx == (void *)0) return MQTT_INFLUX_ERROR;
|
||||||
return MQTT_INFLUX_OK;
|
return MQTT_INFLUX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ agent: {
|
||||||
libraries: {
|
libraries: {
|
||||||
lvgl: {
|
lvgl: {
|
||||||
fs_base = ""; # This will be used as LVGL base file system and will be mounted at drive A:
|
fs_base = ""; # This will be used as LVGL base file system and will be mounted at drive A:
|
||||||
|
logging_enabled = true;
|
||||||
};
|
};
|
||||||
mqtt: {
|
mqtt: {
|
||||||
client: {
|
client: {
|
||||||
|
|
|
@ -70,6 +70,7 @@ agent: {
|
||||||
libraries: {
|
libraries: {
|
||||||
lvgl: {
|
lvgl: {
|
||||||
fs_base = "lvgl_fs";
|
fs_base = "lvgl_fs";
|
||||||
|
logging_enabled = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ agent: {
|
||||||
libraries: {
|
libraries: {
|
||||||
lvgl: {
|
lvgl: {
|
||||||
fs_base = "lvgl_fs";
|
fs_base = "lvgl_fs";
|
||||||
|
logging_enabled = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,13 @@ int user_config_lookup_double(user_config_t *config, char *path,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int user_config_lookup_bool(user_config_t *config, char *path, bool *value) {
|
||||||
|
if(config_lookup_bool(config->libconfig_cfg, path, (int *)value) == 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int user_config_deinit(user_config_t *config) {
|
int user_config_deinit(user_config_t *config) {
|
||||||
config_destroy(config->libconfig_cfg);
|
config_destroy(config->libconfig_cfg);
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,7 @@ int user_gpio_intr_poll(user_gpio_t *gpio, uint32_t timeout_ms,
|
||||||
int ret = gpiod_line_event_wait(gpio->line, &ts);
|
int ret = gpiod_line_event_wait(gpio->line, &ts);
|
||||||
if(ret > 0) {
|
if(ret > 0) {
|
||||||
ret = gpiod_line_event_read(gpio->line, &ev);
|
ret = gpiod_line_event_read(gpio->line, &ev);
|
||||||
}
|
} else return ret;
|
||||||
|
|
||||||
if(ret < 0) return ret;
|
|
||||||
|
|
||||||
if(ev.event_type == GPIOD_LINE_EVENT_RISING_EDGE) {
|
if(ev.event_type == GPIOD_LINE_EVENT_RISING_EDGE) {
|
||||||
*event = USER_GPIO_INTR_RISING;
|
*event = USER_GPIO_INTR_RISING;
|
||||||
|
|
|
@ -33,11 +33,31 @@ st7789_lcd_t g_lcd = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static user_stick_key_t s_previous_key = USER_STICK_NONE;
|
static user_stick_key_t s_previous_key = USER_STICK_NONE;
|
||||||
|
static bool s_lv_log_enabled = false;
|
||||||
|
|
||||||
void user_lvgl_impl_init(void) {
|
int user_lvgl_impl_init(void) {
|
||||||
user_st7789_impl_init(&g_lcd_impl);
|
if(user_st7789_impl_init(&g_lcd_impl) != 0) {
|
||||||
user_stick_impl_init(&g_stick_impl);
|
USER_LOG(USER_LOG_ERROR,
|
||||||
st7789_lcd_init(&g_lcd);
|
"ST7789 support library initialization failed");
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
if(user_stick_impl_init(&g_stick_impl) != 0) {
|
||||||
|
USER_LOG(USER_LOG_ERROR,
|
||||||
|
"Control stick support library initialization failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(st7789_lcd_init(&g_lcd) != ST7789_OK) {
|
||||||
|
USER_LOG(USER_LOG_ERROR, "ST7789 driver initialization failed.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(user_config_lookup_bool(&g_config, "agent.libraries.lvgl.logging_enabled",
|
||||||
|
&s_lv_log_enabled) != 0) {
|
||||||
|
USER_LOG(USER_LOG_WARN,
|
||||||
|
"LVGL log level not found, fallback to default(off).");
|
||||||
|
};
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void user_lvgl_impl_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area,
|
void user_lvgl_impl_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area,
|
||||||
|
@ -79,12 +99,13 @@ void user_lvgl_impl_indev_read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s_previous_key = key;
|
s_previous_key = key;
|
||||||
USER_LOG(USER_LOG_INFO, "Stick event: %d, key: %d", data->state, data->key);
|
USER_LOG(USER_LOG_INFO, "Stick event: %d, key: %d", data->state,
|
||||||
|
data->key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void user_lvgl_impl_log_cb(const char *buf) {
|
void user_lvgl_impl_log_cb(const char *buf) {
|
||||||
USER_LOG(USER_LOG_INFO, "LVGL: %s", buf);
|
if(s_lv_log_enabled) USER_LOG(USER_LOG_INFO, "LVGL: %s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *user_lvgl_impl_fs_open_cb(lv_fs_drv_t *drv, const char *path,
|
void *user_lvgl_impl_fs_open_cb(lv_fs_drv_t *drv, const char *path,
|
||||||
|
|
39
src/main.c
39
src/main.c
|
@ -48,23 +48,48 @@ int main(int argc, const char *argv[]) {
|
||||||
user_system_get_systemd_unique_id(system_uuid);
|
user_system_get_systemd_unique_id(system_uuid);
|
||||||
USER_LOG(USER_LOG_INFO, "System UUID: %s", system_uuid);
|
USER_LOG(USER_LOG_INFO, "System UUID: %s", system_uuid);
|
||||||
|
|
||||||
user_mqtt_task_init();
|
int rc;
|
||||||
user_lvgl_task_init();
|
if((rc = user_mqtt_task_init()) != 0) {
|
||||||
user_base_task_init();
|
USER_LOG(USER_LOG_FATAL, "MQTT task initialization failed(%d).", rc);
|
||||||
user_clock_task_init();
|
goto mqtt_task_init_failed;
|
||||||
user_dht_task_init();
|
}
|
||||||
user_tvoc_task_init();
|
if((rc = user_lvgl_task_init()) != 0) {
|
||||||
|
USER_LOG(USER_LOG_FATAL, "LVGL task initialization failed(%d).", rc);
|
||||||
|
goto lvgl_task_init_failed;
|
||||||
|
}
|
||||||
|
if((rc = user_base_task_init()) != 0) {
|
||||||
|
USER_LOG(USER_LOG_FATAL, "BASE task initialization failed(%d).", rc);
|
||||||
|
goto base_task_init_failed;
|
||||||
|
}
|
||||||
|
if((rc = user_clock_task_init()) != 0) {
|
||||||
|
USER_LOG(USER_LOG_FATAL, "CLOCK task initialization failed(%d).", rc);
|
||||||
|
goto clock_task_init_failed;
|
||||||
|
}
|
||||||
|
if((rc = user_dht_task_init()) != 0) {
|
||||||
|
USER_LOG(USER_LOG_FATAL, "DHT task initialization failed(%d).", rc);
|
||||||
|
goto dht_task_init_failed;
|
||||||
|
}
|
||||||
|
if((rc = user_tvoc_task_init()) != 0) {
|
||||||
|
USER_LOG(USER_LOG_FATAL, "TVOC task initialization failed(%d).", rc);
|
||||||
|
goto tvoc_task_init_failed;
|
||||||
|
}
|
||||||
|
|
||||||
USER_LOG(USER_LOG_INFO, "Initialized, main thread sleeping.");
|
USER_LOG(USER_LOG_INFO, "Initialized, main thread now going to sleep.");
|
||||||
while(g_running) {
|
while(g_running) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tvoc_task_init_failed:
|
||||||
user_tvoc_task_deinit();
|
user_tvoc_task_deinit();
|
||||||
|
dht_task_init_failed:
|
||||||
user_dht_task_deinit();
|
user_dht_task_deinit();
|
||||||
|
clock_task_init_failed:
|
||||||
user_clock_task_deinit();
|
user_clock_task_deinit();
|
||||||
|
base_task_init_failed:
|
||||||
user_base_task_deinit();
|
user_base_task_deinit();
|
||||||
|
lvgl_task_init_failed:
|
||||||
user_lvgl_task_deinit();
|
user_lvgl_task_deinit();
|
||||||
|
mqtt_task_init_failed:
|
||||||
user_mqtt_task_deinit();
|
user_mqtt_task_deinit();
|
||||||
|
|
||||||
user_config_deinit(&g_config);
|
user_config_deinit(&g_config);
|
||||||
|
|
|
@ -40,6 +40,7 @@ int user_lvgl_task_init(void) {
|
||||||
s_disp_drv.ver_res = 240;
|
s_disp_drv.ver_res = 240;
|
||||||
s_disp_drv.flush_cb = user_lvgl_impl_flush_cb;
|
s_disp_drv.flush_cb = user_lvgl_impl_flush_cb;
|
||||||
lv_disp_t *disp = lv_disp_drv_register(&s_disp_drv);
|
lv_disp_t *disp = lv_disp_drv_register(&s_disp_drv);
|
||||||
|
if(disp == NULL) return -2;
|
||||||
|
|
||||||
lv_indev_drv_init(&s_indev_drv);
|
lv_indev_drv_init(&s_indev_drv);
|
||||||
s_indev_drv.type = LV_INDEV_TYPE_KEYPAD;
|
s_indev_drv.type = LV_INDEV_TYPE_KEYPAD;
|
||||||
|
|
Loading…
Reference in New Issue