|
21 | 21 | from pathlib import Path |
22 | 22 | from platform import uname |
23 | 23 | from datetime import datetime |
24 | | -from pn532_enum import MfcKeyType, MifareCommand, PN532KillerMode, PN532KillerTagType |
| 24 | +from pn532_enum import MfcKeyType, MifareCommand, PN532KillerMode, PN532KillerTagType, Status |
25 | 25 |
|
26 | 26 | from pn532_utils import CLITree |
27 | 27 |
|
@@ -123,6 +123,7 @@ def check_tools(): |
123 | 123 |
|
124 | 124 | root = CLITree(root=True) |
125 | 125 | hw = root.subgroup("hw", "Hardware-related commands") |
| 126 | +hw_led = hw.subgroup("led", "LED control commands") |
126 | 127 | hw_mode = hw.subgroup("mode", "Mode-related commands") |
127 | 128 | hf = root.subgroup("hf", "High-frequency commands") |
128 | 129 | hf_14a = hf.subgroup("14a", "ISO 14443-A commands") |
@@ -1342,6 +1343,38 @@ def on_exec(self, args: argparse.Namespace): |
1342 | 1343 | print("Failed to get firmware version") |
1343 | 1344 |
|
1344 | 1345 |
|
| 1346 | +@hw_led.command("on") |
| 1347 | +class HWLedOn(DeviceRequiredUnit): |
| 1348 | + def args_parser(self) -> ArgumentParserNoExit: |
| 1349 | + parser = ArgumentParserNoExit() |
| 1350 | + parser.description = "Turn on PN532Killer LED" |
| 1351 | + return parser |
| 1352 | + |
| 1353 | + def on_exec(self, args: argparse.Namespace): |
| 1354 | + if self.device_com.get_device_name() != "PN532Killer": |
| 1355 | + print("LED control is only supported on PN532Killer.") |
| 1356 | + return |
| 1357 | + resp = self.cmd.led_on() |
| 1358 | + ok = resp.parsed if hasattr(resp, "parsed") else (resp.status == Status.SUCCESS) |
| 1359 | + print(f"LED on: {'Success' if ok else 'Fail'}") |
| 1360 | + |
| 1361 | + |
| 1362 | +@hw_led.command("off") |
| 1363 | +class HWLedOff(DeviceRequiredUnit): |
| 1364 | + def args_parser(self) -> ArgumentParserNoExit: |
| 1365 | + parser = ArgumentParserNoExit() |
| 1366 | + parser.description = "Turn off PN532Killer LED" |
| 1367 | + return parser |
| 1368 | + |
| 1369 | + def on_exec(self, args: argparse.Namespace): |
| 1370 | + if self.device_com.get_device_name() != "PN532Killer": |
| 1371 | + print("LED control is only supported on PN532Killer.") |
| 1372 | + return |
| 1373 | + resp = self.cmd.led_off() |
| 1374 | + ok = resp.parsed if hasattr(resp, "parsed") else (resp.status == Status.SUCCESS) |
| 1375 | + print(f"LED off: {'Success' if ok else 'Fail'}") |
| 1376 | + |
| 1377 | + |
1345 | 1378 | @hf_sniff.command("setuid") |
1346 | 1379 | class HfSniffSetUid(DeviceRequiredUnit): |
1347 | 1380 | def args_parser(self) -> ArgumentParserNoExit: |
|
0 commit comments