2020-08-17 12:45:53 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
extern "C" {
|
2020-10-10 13:32:06 +03:00
|
|
|
#include "flipper.h"
|
|
|
|
#include "furi.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "startup.h"
|
|
|
|
#include "tty_uart.h"
|
2020-08-17 12:45:53 +03:00
|
|
|
}
|
2020-08-07 09:58:20 +03:00
|
|
|
|
2020-10-10 13:32:06 +03:00
|
|
|
// for testing purpose
|
|
|
|
uint32_t exitcode = 0;
|
|
|
|
extern "C" void set_exitcode(uint32_t _exitcode) {
|
|
|
|
exitcode = _exitcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" int app() {
|
2020-08-26 21:32:22 +03:00
|
|
|
register_tty_uart();
|
|
|
|
|
|
|
|
FuriRecordSubscriber* log = get_default_log();
|
|
|
|
fuprintf(log, "\n=== Welcome to Flipper Zero! ===\n\n");
|
|
|
|
|
2020-08-24 18:31:22 +03:00
|
|
|
// FURI startup
|
2020-10-05 13:17:34 +03:00
|
|
|
const size_t flipper_app_count = sizeof(FLIPPER_STARTUP) / sizeof(FLIPPER_STARTUP[0]);
|
|
|
|
FuriApp* handlers[flipper_app_count];
|
2020-08-17 12:45:53 +03:00
|
|
|
|
2020-10-05 13:17:34 +03:00
|
|
|
for(size_t i = 0; i < flipper_app_count; i++) {
|
|
|
|
// TODO create a dependency tree and run tasks in the desired order
|
2020-10-08 17:37:19 +03:00
|
|
|
furiac_wait_libs(&FLIPPER_STARTUP[i].libs);
|
2020-08-24 18:31:22 +03:00
|
|
|
handlers[i] = furiac_start(FLIPPER_STARTUP[i].app, FLIPPER_STARTUP[i].name, NULL);
|
2020-08-07 09:58:20 +03:00
|
|
|
}
|
2020-08-24 18:31:22 +03:00
|
|
|
|
|
|
|
bool is_alive = false;
|
|
|
|
do {
|
|
|
|
is_alive = false;
|
2020-10-05 13:17:34 +03:00
|
|
|
for(size_t i = 0; i < flipper_app_count; i++) {
|
2020-08-24 18:31:22 +03:00
|
|
|
if(handlers[i]->handler != NULL) {
|
|
|
|
is_alive = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delay(500);
|
|
|
|
} while(is_alive);
|
2020-10-05 13:17:34 +03:00
|
|
|
|
|
|
|
fuprintf(log, "\n=== Bye from Flipper Zero! ===\n\n");
|
2020-10-10 13:32:06 +03:00
|
|
|
|
|
|
|
return (int)exitcode;
|
2020-08-07 09:58:20 +03:00
|
|
|
}
|