Nfc: add field testing (#1027)

* Nfc: add field cli command
* Nfc: add field test in debug menu
* Nfc: warning message for field tests
* Format sources
This commit is contained in:
あく
2022-03-16 15:57:13 +07:00
committed by GitHub
parent 76b737f411
commit 28888b0a22
6 changed files with 123 additions and 4 deletions

View File

@@ -11,6 +11,9 @@ static void nfc_cli_print_usage() {
printf("Cmd list:\r\n");
printf("\tdetect\t - detect nfc device\r\n");
printf("\temulate\t - emulate predefined nfca card\r\n");
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
printf("\tfield\t - turn field on\r\n");
}
}
void nfc_cli_detect(Cli* cli, string_t args) {
@@ -76,6 +79,27 @@ void nfc_cli_emulate(Cli* cli, string_t args) {
furi_hal_nfc_deactivate();
}
void nfc_cli_field(Cli* cli, string_t args) {
// Check if nfc worker is not busy
if(furi_hal_nfc_is_busy()) {
printf("Nfc is busy\r\n");
return;
}
furi_hal_nfc_exit_sleep();
furi_hal_nfc_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)) {
osDelay(50);
}
furi_hal_nfc_field_off();
furi_hal_nfc_deactivate();
}
static void nfc_cli(Cli* cli, string_t args, void* context) {
string_t cmd;
string_init(cmd);
@@ -94,6 +118,13 @@ static void nfc_cli(Cli* cli, string_t args, void* context) {
break;
}
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
if(string_cmp_str(cmd, "field") == 0) {
nfc_cli_field(cli, args);
break;
}
}
nfc_cli_print_usage();
} while(false);