mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
* cli_shell: separate into toolbox * fix: cmd flags * fix formatting * cli: increase default stack depth * cli_shell: fix loader lock logic * cli: fix command flags * fix f18 * speaker_debug: fix * cli_registry: fix docs * ufbt: rename cli target back * cli: rename app and record * cli: fix and simplify help command * cli_master_shell: fix ext commands * fix formatting * cli: rename master to main * fix formatting --------- Co-authored-by: hedger <hedger@users.noreply.github.com>
68 lines
1.7 KiB
C
68 lines
1.7 KiB
C
#include <furi.h>
|
|
#include <furi_hal.h>
|
|
#include <cli/cli_main_commands.h>
|
|
#include <lib/toolbox/args.h>
|
|
#include <lib/toolbox/hex.h>
|
|
#include <toolbox/pipe.h>
|
|
|
|
#include <furi_hal_nfc.h>
|
|
|
|
#define FLAG_EVENT (1 << 10)
|
|
|
|
static void nfc_cli_print_usage(void) {
|
|
printf("Usage:\r\n");
|
|
printf("nfc <cmd>\r\n");
|
|
printf("Cmd list:\r\n");
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
printf("\tfield\t - turn field on\r\n");
|
|
}
|
|
}
|
|
|
|
static void nfc_cli_field(PipeSide* pipe, FuriString* args) {
|
|
UNUSED(args);
|
|
// Check if nfc worker is not busy
|
|
if(furi_hal_nfc_is_hal_ready() != FuriHalNfcErrorNone) {
|
|
printf("NFC chip failed to start\r\n");
|
|
return;
|
|
}
|
|
|
|
furi_hal_nfc_acquire();
|
|
furi_hal_nfc_low_power_mode_stop();
|
|
furi_hal_nfc_poller_field_on();
|
|
|
|
printf("Field is on. Don't leave device in this mode for too long.\r\n");
|
|
printf("Press Ctrl+C to abort\r\n");
|
|
|
|
while(!cli_is_pipe_broken_or_is_etx_next_char(pipe)) {
|
|
furi_delay_ms(50);
|
|
}
|
|
|
|
furi_hal_nfc_low_power_mode_start();
|
|
furi_hal_nfc_release();
|
|
}
|
|
|
|
static void execute(PipeSide* pipe, FuriString* args, void* context) {
|
|
UNUSED(context);
|
|
FuriString* cmd;
|
|
cmd = furi_string_alloc();
|
|
|
|
do {
|
|
if(!args_read_string_and_trim(args, cmd)) {
|
|
nfc_cli_print_usage();
|
|
break;
|
|
}
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
if(furi_string_cmp_str(cmd, "field") == 0) {
|
|
nfc_cli_field(pipe, args);
|
|
break;
|
|
}
|
|
}
|
|
|
|
nfc_cli_print_usage();
|
|
} while(false);
|
|
|
|
furi_string_free(cmd);
|
|
}
|
|
|
|
CLI_COMMAND_INTERFACE(nfc, execute, CliCommandFlagDefault, 1024, CLI_APPID);
|