2021-06-10 15:01:48 +03:00
|
|
|
#include <furi.h>
|
2022-01-05 19:10:18 +03:00
|
|
|
#include <furi_hal.h>
|
2022-02-16 14:15:40 +03:00
|
|
|
#include <cli/cli.h>
|
2022-07-26 18:30:49 +03:00
|
|
|
#include <lib/toolbox/args.h>
|
2023-03-15 16:52:32 +03:00
|
|
|
#include <lib/toolbox/hex.h>
|
2021-06-10 15:01:48 +03:00
|
|
|
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
#include <furi_hal_nfc.h>
|
|
|
|
|
|
|
|
#define FLAG_EVENT (1 << 10)
|
2022-02-16 14:15:40 +03:00
|
|
|
|
|
|
|
static void nfc_cli_print_usage() {
|
|
|
|
printf("Usage:\r\n");
|
|
|
|
printf("nfc <cmd>\r\n");
|
|
|
|
printf("Cmd list:\r\n");
|
2022-03-16 11:57:13 +03:00
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
printf("\tfield\t - turn field on\r\n");
|
|
|
|
}
|
2021-06-10 15:01:48 +03:00
|
|
|
}
|
|
|
|
|
2022-10-05 18:15:23 +03:00
|
|
|
static void nfc_cli_field(Cli* cli, FuriString* args) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(args);
|
2022-03-16 11:57:13 +03:00
|
|
|
// Check if nfc worker is not busy
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
if(furi_hal_nfc_is_hal_ready() != FuriHalNfcErrorNone) {
|
|
|
|
printf("NFC chip failed to start\r\n");
|
2022-03-16 11:57:13 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
furi_hal_nfc_acquire();
|
|
|
|
furi_hal_nfc_low_power_mode_stop();
|
|
|
|
furi_hal_nfc_poller_field_on();
|
2022-03-16 11:57:13 +03:00
|
|
|
|
|
|
|
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)) {
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_delay_ms(50);
|
2022-03-16 11:57:13 +03:00
|
|
|
}
|
|
|
|
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
furi_hal_nfc_low_power_mode_start();
|
|
|
|
furi_hal_nfc_release();
|
2023-03-15 16:52:32 +03:00
|
|
|
}
|
|
|
|
|
2022-10-05 18:15:23 +03:00
|
|
|
static void nfc_cli(Cli* cli, FuriString* args, void* context) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(context);
|
2022-10-05 18:15:23 +03:00
|
|
|
FuriString* cmd;
|
|
|
|
cmd = furi_string_alloc();
|
2022-02-16 14:15:40 +03:00
|
|
|
|
|
|
|
do {
|
|
|
|
if(!args_read_string_and_trim(args, cmd)) {
|
|
|
|
nfc_cli_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
2022-03-16 11:57:13 +03:00
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
2022-10-05 18:15:23 +03:00
|
|
|
if(furi_string_cmp_str(cmd, "field") == 0) {
|
2022-03-16 11:57:13 +03:00
|
|
|
nfc_cli_field(cli, args);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-16 14:15:40 +03:00
|
|
|
nfc_cli_print_usage();
|
|
|
|
} while(false);
|
|
|
|
|
2022-10-05 18:15:23 +03:00
|
|
|
furi_string_free(cmd);
|
2022-02-16 14:15:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nfc_on_system_start() {
|
|
|
|
#ifdef SRV_CLI
|
2022-07-26 15:21:51 +03:00
|
|
|
Cli* cli = furi_record_open(RECORD_CLI);
|
2022-02-16 14:15:40 +03:00
|
|
|
cli_add_command(cli, "nfc", CliCommandFlagDefault, nfc_cli, NULL);
|
2022-07-26 15:21:51 +03:00
|
|
|
furi_record_close(RECORD_CLI);
|
2022-04-13 23:50:25 +03:00
|
|
|
#else
|
|
|
|
UNUSED(nfc_cli);
|
2022-02-16 14:15:40 +03:00
|
|
|
#endif
|
|
|
|
}
|