Files
Momentum-Firmware/applications/main/nfc/nfc_cli.c
WillyJL 2e7eedf291 CLI: More commands as plugins on SD -6KB DFU, refactor plugin wrapper, (#276)
* Unused icons to check later

* Exclude disabled icons from firmware

* Format

* CLI: Test moving more cmds to plugins

* CLI: Macro template for plugin wrapper

* Fix plugin filenames

* Retrofit older cli wrappers

* Fix unused

* Fix manifests

* Add explanation

* Revert "Unused icons to check later"

This reverts commit b7f98e344c.

* Revert "Exclude disabled icons from firmware"

This reverts commit ab62e99898.

* Add back toplevel chat command

* Add DFU size to github comment

* Fix build

* Fix BT CLI preload fail

* Add these back

* Fix CLI command gpio preload fail

* Fix input command

* These can stay

* Fix negative size rounding

* Update changelog

* Fix DFU size calc
2024-11-04 09:42:25 +01:00

78 lines
1.8 KiB
C

#include <furi.h>
#include <furi_hal.h>
#include <cli/cli.h>
#include <lib/toolbox/args.h>
#include <lib/toolbox/hex.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(Cli* cli, 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_cmd_interrupt_received(cli)) {
furi_delay_ms(50);
}
furi_hal_nfc_low_power_mode_start();
furi_hal_nfc_release();
}
static void nfc_cli(Cli* cli, 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(cli, args);
break;
}
}
nfc_cli_print_usage();
} while(false);
furi_string_free(cmd);
}
#include <cli/cli_i.h>
CLI_PLUGIN_WRAPPER("nfc", nfc_cli)
void nfc_on_system_start(void) {
#ifdef SRV_CLI
Cli* cli = furi_record_open(RECORD_CLI);
cli_add_command(cli, "nfc", CliCommandFlagDefault, nfc_cli_wrapper, NULL);
furi_record_close(RECORD_CLI);
#else
UNUSED(nfc_cli);
#endif
}