app type cleanup and improvements
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "nanobake.h"
|
||||
#include "nb_hardwarei.h"
|
||||
#include "nb_lvgli.h"
|
||||
#include "nb_appi.h"
|
||||
#include "applications/nb_applications.h"
|
||||
#include <esp_log.h>
|
||||
#include <m-list.h>
|
||||
@@ -8,7 +9,6 @@
|
||||
#include <thread.h>
|
||||
#include <kernel.h>
|
||||
#include <record.h>
|
||||
#include <check.h>
|
||||
|
||||
M_LIST_DEF(thread_ids, FuriThreadId);
|
||||
|
||||
@@ -34,69 +34,53 @@ size_t nanobake_get_app_thread_count() {
|
||||
return thread_ids_size(prv_thread_ids);
|
||||
}
|
||||
|
||||
static void prv_start_app(const nb_app_t _Nonnull* app) {
|
||||
ESP_LOGI(TAG, "Starting %s app \"%s\"",
|
||||
nb_app_type_to_string(app->type),
|
||||
app->name
|
||||
);
|
||||
|
||||
FuriThread* thread = furi_thread_alloc_ex(
|
||||
app->name,
|
||||
app->stack_size,
|
||||
app->entry_point,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (app->type == SERVICE) {
|
||||
furi_thread_mark_as_service(thread);
|
||||
}
|
||||
|
||||
furi_thread_set_appid(thread, app->id);
|
||||
furi_thread_start(thread);
|
||||
|
||||
FuriThreadId thread_id = furi_thread_get_id(thread);
|
||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||
}
|
||||
|
||||
extern void nanobake_start(nb_config_t _Nonnull* config) {
|
||||
prv_furi_init();
|
||||
|
||||
nb_hardware_t hardware = nb_hardware_create(config);
|
||||
nb_lvgl_t lvgl = nb_lvgl_init(&hardware);
|
||||
/*nb_lvgl_t lvgl =*/ nb_lvgl_init(&hardware);
|
||||
|
||||
thread_ids_init(prv_thread_ids);
|
||||
|
||||
ESP_LOGI(TAG, "Starting services");
|
||||
ESP_LOGI(TAG, "Starting apps");
|
||||
|
||||
for(size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) {
|
||||
ESP_LOGI(TAG, "Starting system service \"%s\"", FLIPPER_SERVICES[i]->name);
|
||||
|
||||
FuriThread* thread = furi_thread_alloc_ex(
|
||||
FLIPPER_SERVICES[i]->name,
|
||||
FLIPPER_SERVICES[i]->stack_size,
|
||||
FLIPPER_SERVICES[i]->entry_point,
|
||||
NULL
|
||||
);
|
||||
furi_thread_mark_as_service(thread);
|
||||
furi_thread_set_appid(thread, FLIPPER_SERVICES[i]->id);
|
||||
furi_thread_start(thread);
|
||||
|
||||
FuriThreadId thread_id = furi_thread_get_id(thread);
|
||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||
// Services
|
||||
for (size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) {
|
||||
prv_start_app(FLIPPER_SERVICES[i]);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Starting system apps");
|
||||
|
||||
for(size_t i = 0; i < FLIPPER_SYSTEM_APPS_COUNT; i++) {
|
||||
ESP_LOGI(TAG, "Starting system app \"%s\"", FLIPPER_SYSTEM_APPS[i]->name);
|
||||
|
||||
FuriThread* thread = furi_thread_alloc_ex(
|
||||
FLIPPER_SYSTEM_APPS[i]->name,
|
||||
FLIPPER_SYSTEM_APPS[i]->stack_size,
|
||||
FLIPPER_SYSTEM_APPS[i]->entry_point,
|
||||
NULL
|
||||
);
|
||||
furi_thread_mark_as_service(thread);
|
||||
furi_thread_set_appid(thread, FLIPPER_SYSTEM_APPS[i]->id);
|
||||
furi_thread_start(thread);
|
||||
|
||||
FuriThreadId thread_id = furi_thread_get_id(thread);
|
||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||
// System
|
||||
for (size_t i = 0; i < FLIPPER_SYSTEM_APPS_COUNT; i++) {
|
||||
prv_start_app(FLIPPER_SYSTEM_APPS[i]);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Starting external apps");
|
||||
|
||||
for(size_t i = 0; i < config->apps_count; i++) {
|
||||
const nb_app_t* app = config->apps[i];
|
||||
ESP_LOGI(TAG, "Starting external app \"%s\"", app->name);
|
||||
|
||||
FuriThread* thread = furi_thread_alloc_ex(
|
||||
app->name,
|
||||
app->stack_size,
|
||||
app->entry_point,
|
||||
NULL
|
||||
);
|
||||
furi_thread_set_appid(thread, app->id);
|
||||
furi_thread_start(thread);
|
||||
|
||||
FuriThreadId thread_id = furi_thread_get_id(thread);
|
||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||
// User
|
||||
for (size_t i = 0; i < config->apps_count; i++) {
|
||||
prv_start_app(config->apps[i]);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Startup complete");
|
||||
|
||||
Reference in New Issue
Block a user