2021-06-10 12:01:48 +00:00
|
|
|
#include <furi.h>
|
2022-01-05 16:10:18 +00:00
|
|
|
#include <furi_hal.h>
|
2022-02-16 11:15:40 +00:00
|
|
|
#include <cli/cli.h>
|
2022-07-26 15:30:49 +00:00
|
|
|
#include <lib/toolbox/args.h>
|
2023-03-15 13:52:32 +00:00
|
|
|
#include <lib/toolbox/hex.h>
|
2021-06-10 12:01:48 +00: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 03:08:09 +00:00
|
|
|
#include <furi_hal_nfc.h>
|
|
|
|
|
|
|
|
#define FLAG_EVENT (1 << 10)
|
2022-02-16 11:15:40 +00:00
|
|
|
|
|
|
|
static void nfc_cli_print_usage() {
|
|
|
|
printf("Usage:\r\n");
|
|
|
|
printf("nfc <cmd>\r\n");
|
|
|
|
printf("Cmd list:\r\n");
|
2022-03-16 08:57:13 +00:00
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
printf("\tfield\t - turn field on\r\n");
|
|
|
|
}
|
2021-06-10 12:01:48 +00:00
|
|
|
}
|
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
static void nfc_cli_field(Cli* cli, FuriString* args) {
|
2022-05-06 13:37:10 +00:00
|
|
|
UNUSED(args);
|
2022-03-16 08:57:13 +00: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 03:08:09 +00:00
|
|
|
if(furi_hal_nfc_is_hal_ready() != FuriHalNfcErrorNone) {
|
|
|
|
printf("NFC chip failed to start\r\n");
|
2022-03-16 08:57:13 +00: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 03:08:09 +00:00
|
|
|
furi_hal_nfc_acquire();
|
|
|
|
furi_hal_nfc_low_power_mode_stop();
|
|
|
|
furi_hal_nfc_poller_field_on();
|
2022-03-16 08:57:13 +00: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 10:56:33 +00:00
|
|
|
furi_delay_ms(50);
|
2022-03-16 08:57:13 +00: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 03:08:09 +00:00
|
|
|
furi_hal_nfc_low_power_mode_start();
|
|
|
|
furi_hal_nfc_release();
|
2023-03-15 13:52:32 +00:00
|
|
|
}
|
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
static void nfc_cli(Cli* cli, FuriString* args, void* context) {
|
2022-05-06 13:37:10 +00:00
|
|
|
UNUSED(context);
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* cmd;
|
|
|
|
cmd = furi_string_alloc();
|
2022-02-16 11:15:40 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
if(!args_read_string_and_trim(args, cmd)) {
|
|
|
|
nfc_cli_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
2022-03-16 08:57:13 +00:00
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
2022-10-05 15:15:23 +00:00
|
|
|
if(furi_string_cmp_str(cmd, "field") == 0) {
|
2022-03-16 08:57:13 +00:00
|
|
|
nfc_cli_field(cli, args);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-16 11:15:40 +00:00
|
|
|
nfc_cli_print_usage();
|
|
|
|
} while(false);
|
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_free(cmd);
|
2022-02-16 11:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void nfc_on_system_start() {
|
|
|
|
#ifdef SRV_CLI
|
2022-07-26 12:21:51 +00:00
|
|
|
Cli* cli = furi_record_open(RECORD_CLI);
|
2022-02-16 11:15:40 +00:00
|
|
|
cli_add_command(cli, "nfc", CliCommandFlagDefault, nfc_cli, NULL);
|
2022-07-26 12:21:51 +00:00
|
|
|
furi_record_close(RECORD_CLI);
|
2022-04-13 20:50:25 +00:00
|
|
|
#else
|
|
|
|
UNUSED(nfc_cli);
|
2022-02-16 11:15:40 +00:00
|
|
|
#endif
|
|
|
|
}
|