[FL-1546, FL-1534, FL-1550] Drop F5, Certification preparation, Global application start lock (#585)

* Firmware: drop F5 target
* Rename app-loader to loader
* Update code owners file
* Loader: global application start lock API, minor refactoring
* Archive: update loader usage
* Cli: Command flags, global application start lock
* Apps: update cli API usage
* Bootloader: minor refactoring
* Firmware: minor build refactoring
* SubGhz: GUI packet test
* SubGhz: drop packet transmission and unused presets
* Github: drop F5 from build
* Archive: favorites
* Archive: a little bit more of Favorites
This commit is contained in:
あく
2021-07-18 21:09:00 +03:00
committed by GitHub
parent fbb81483ae
commit 421a0f6b97
235 changed files with 763 additions and 26959 deletions

View File

@@ -1,7 +1,9 @@
#include "cli_i.h"
#include "cli_commands.h"
#include <version.h>
#include <api-hal-version.h>
#include <loader/loader.h>
Cli* cli_alloc() {
Cli* cli = furi_alloc(sizeof(Cli));
@@ -166,10 +168,26 @@ static void cli_handle_enter(Cli* cli) {
CliCommand* cli_command = CliCommandTree_get(cli->commands, command);
if(cli_command) {
cli_nl(cli);
// Execute command
cli_command->callback(cli, args, cli_command->context);
// Clear line
cli_reset(cli);
// Ensure that we running alone
if(!(cli_command->flags & CliCommandFlagParallelSafe)) {
Loader* loader = furi_record_open("loader");
bool safety_lock = loader_lock(loader);
if(safety_lock) {
// Execute command
cli_command->callback(cli, args, cli_command->context);
loader_unlock(loader);
// Clear line
cli_reset(cli);
} else {
printf("Other application is running, close it first");
}
furi_record_close("loader");
} else {
// Execute command
cli_command->callback(cli, args, cli_command->context);
// Clear line
cli_reset(cli);
}
} else {
cli_nl(cli);
printf(
@@ -310,7 +328,12 @@ void cli_process_input(Cli* cli) {
}
}
void cli_add_command(Cli* cli, const char* name, CliCallback callback, void* context) {
void cli_add_command(
Cli* cli,
const char* name,
CliCommandFlag flags,
CliCallback callback,
void* context) {
string_t name_str;
string_init_set_str(name_str, name);
string_strim(name_str);
@@ -323,6 +346,7 @@ void cli_add_command(Cli* cli, const char* name, CliCallback callback, void* con
CliCommand c;
c.callback = callback;
c.context = context;
c.flags = flags;
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
CliCommandTree_set_at(cli->commands, name_str, c);

View File

@@ -20,6 +20,12 @@ typedef enum {
CliSymbolAsciiDel = 0x7F,
} CliSymbols;
typedef enum {
CliCommandFlagDefault = 0, /** Default, loader lock is used */
CliCommandFlagParallelSafe =
(1 << 0), /** Safe to run in parallel with other apps, loader lock is not used */
} CliCommandFlag;
/* Cli type
* Anonymous structure. Use cli_i.h if you need to go deeper.
*/
@@ -39,7 +45,12 @@ typedef void (*CliCallback)(Cli* cli, string_t args, void* context);
* @param callback - callback function
* @param context - pointer to whatever we need to pass to callback
*/
void cli_add_command(Cli* cli, const char* name, CliCallback callback, void* context);
void cli_add_command(
Cli* cli,
const char* name,
CliCommandFlag flags,
CliCallback callback,
void* context);
/* Print unified cmd usage tip
* @param cmd - cmd name

View File

@@ -376,17 +376,18 @@ void cli_command_free(Cli* cli, string_t args, void* context) {
}
void cli_commands_init(Cli* cli) {
cli_add_command(cli, "!", cli_command_device_info, NULL);
cli_add_command(cli, "device_info", cli_command_device_info, NULL);
cli_add_command(cli, "!", CliCommandFlagParallelSafe, cli_command_device_info, NULL);
cli_add_command(cli, "device_info", CliCommandFlagParallelSafe, cli_command_device_info, NULL);
cli_add_command(cli, "?", cli_command_help, NULL);
cli_add_command(cli, "help", cli_command_help, NULL);
cli_add_command(cli, "?", CliCommandFlagParallelSafe, cli_command_help, NULL);
cli_add_command(cli, "help", CliCommandFlagParallelSafe, cli_command_help, NULL);
cli_add_command(cli, "date", cli_command_date, NULL);
cli_add_command(cli, "log", cli_command_log, NULL);
cli_add_command(cli, "vibro", cli_command_vibro, NULL);
cli_add_command(cli, "led", cli_command_led, NULL);
cli_add_command(cli, "gpio_set", cli_command_gpio_set, NULL);
cli_add_command(cli, "ps", cli_command_ps, NULL);
cli_add_command(cli, "free", cli_command_free, NULL);
cli_add_command(cli, "date", CliCommandFlagParallelSafe, cli_command_date, NULL);
cli_add_command(cli, "log", CliCommandFlagParallelSafe, cli_command_log, NULL);
cli_add_command(cli, "ps", CliCommandFlagParallelSafe, cli_command_ps, NULL);
cli_add_command(cli, "free", CliCommandFlagParallelSafe, cli_command_free, NULL);
cli_add_command(cli, "vibro", CliCommandFlagDefault, cli_command_vibro, NULL);
cli_add_command(cli, "led", CliCommandFlagDefault, cli_command_led, NULL);
cli_add_command(cli, "gpio_set", CliCommandFlagDefault, cli_command_gpio_set, NULL);
}

View File

@@ -15,6 +15,7 @@
typedef struct {
CliCallback callback;
void* context;
uint32_t flags;
} CliCommand;
BPTREE_DEF2(