Author SHA1 Message Date
dxl f597e18ab3 Rollback LF Emulate. 2024-01-17 18:26:13 +08:00
Philippe TeuwenandGitHub fefcde542b Merge pull request #189 from p-l-/enh-hf-mf-elog-skip-used-items
CLI: skip already used items in `hf mf elog --decrypt`
2023-12-20 23:20:37 +01:00
Pierre Lalet e3cbd598ec CLI: skip already used items in hf mf elog --decrypt
This (often largely) improves the speed of the decrypt process. On my
laptop, with the same logs (37 records for one block and 37 records
for another block), here are the performances, as measuerd using a
simple command:

```bash
time echo -e "hw connect\nhf mf elog --decrypt\nhw disconnect" | ./chameleon_cli_main.py
```

- Before parallelisation (#187): 14m59,277s
- With parallelisation (current main): 6m13,513s
- With item skipping (this PR): 2m42,491s
2023-12-20 22:37:47 +01:00
Philippe TeuwenandGitHub 0124709067 Merge pull request #187 from p-l-/enh-hf-mf-elog-parallel
CLI: parallelize mfkey32v2 processes
2023-12-20 16:29:08 +01:00
Pierre Lalet cc674f1669 CLI: fix mfkey32v2 call for Windows 2023-12-20 16:20:12 +01:00
Pierre Lalet 42317a7bc4 CLI: parallelize mfkey32v2 processes 2023-12-20 16:20:12 +01:00
GameTec-liveandGitHub 05ea03d31c doc: Add box net and vectortraced boxart and troubleshooting entry (#186)
* doc: Add box net and vectortraced boxart
* doc: add troubleshooting entry and python notice
* fix: compress images
2023-12-05 16:06:56 +08:00
dxl 7fdb358e8b Merge branch 'main' of https://github.com/RfidResearchGroup/ChameleonUltra 2023-11-15 18:53:42 +08:00
dxl 3b14270976 Staticnested results quite poor compared to pm3 implem #183 2023-11-15 18:53:02 +08:00
Philippe Teuwen af91ddcda9 CLI: Do not execute a command if help is printed
Previously, for example `hf 14a raw -b 7 -d 26 -h` was printing help but it was also executing the command.
2023-11-15 09:44:37 +01:00
Philippe TeuwenandGitHub 5b67a895eb Merge pull request #180 from taichunmin/taichunmin
Added support for mifare classic value block operations
2023-11-15 09:38:45 +01:00
Philippe TeuwenandGitHub 494735a07d Merge pull request #184 from GameTec-live/main
doc: Add CUGUI troubleshooting entry
2023-11-15 08:35:55 +01:00
GameTec_live 12fd5f23f7 doc: Add CUGUI troubleshooting entry 2023-11-14 19:43:55 +01:00
taichunmin e79568298f Added support for mifare classic value block operations 2023-11-13 23:38:56 +08:00
Philippe Teuwen 4d670f051a Be robust to some argparse string variants 2023-11-06 22:45:48 +01:00
Philippe Teuwen ecf3c06886 add regression tests 2023-10-25 00:32:31 +02:00
Philippe Teuwen 7d851d2a22 reorganize a bit cli to allow autotests 2023-10-24 23:46:34 +02:00
Philippe Teuwen d973ee6671 add hw disconnect (for autotests) 2023-10-24 23:45:42 +02:00
Philippe Teuwen ece5e79060 typechecking fixes 2023-10-24 23:44:56 +02:00
Philippe Teuwen d77e166249 pep287 2023-10-24 00:57:44 +02:00
Philippe Teuwen ff3df15278 misc lint 2023-10-23 23:57:23 +02:00
Philippe Teuwen 55cd19f0db Move bins to simplify pyinstaller paths 2023-10-23 22:54:37 +02:00
Philippe Teuwen bb47bd5159 make style 2023-10-23 19:16:42 +02:00
Philippe Teuwen 7ea8cc1f98 check_file_encoding 2023-10-23 19:12:42 +02:00
Philippe Teuwen 55228d1489 fix encoding 2023-10-23 17:40:25 +02:00
Philippe Teuwen 299562bbdd changelog 2023-10-21 10:55:39 +02:00
Philippe TeuwenandGitHub c2f0f0d408 Merge pull request #178 from taichunmin/taichunmin
Change git version to version tag instead of dev tag.
2023-10-21 10:55:05 +02:00
taichunmin c91514efa1 Change git version to version tag instead of dev tag. 2023-10-21 16:40:15 +08:00
dxl 74f4eb8822 Changelog updated. 2023-10-19 22:54:47 +08:00
dxl f04943f59b Merge remote-tracking branch 'origin/main' 2023-10-19 22:51:55 +08:00
dxl 771e6ded54 Fixed a bug that will not reset the state machine after DEC. 2023-10-19 22:51:02 +08:00
dxl ab07dff904 Function has been renamed 2023-10-19 22:50:08 +08:00
dxl 980960c43d Fixed a bug that affected 14A simulation. 2023-10-19 22:48:53 +08:00
Philippe Teuwen 6e19d078f4 oops, missed sth when solving the merge conflicts 2023-10-17 23:56:28 +02:00
Philippe TeuwenandGitHub eac246fc0c Merge pull request #174 from augustozanellato/ats_error_fixes
Fix ATS handling in tags that NAK RATS
2023-10-17 23:52:50 +02:00
Philippe TeuwenandGitHub 83583075c4 Merge branch 'main' into ats_error_fixes 2023-10-17 23:52:35 +02:00
Philippe Teuwen fa0754aed2 cli: make status an enum. rename some status for consistency 2023-10-17 23:43:25 +02:00
Augusto Zanellato aa3fe711af Fix hf 14a raw always raising AttributeError 2023-10-17 23:33:19 +02:00
Augusto Zanellato cb1878440d Fix ATS handling in tags that NAK RATS
pcd_14a_reader_ats_request didn't check for NAK so in case the tag NAKd
the RATS it would return a zero length ATS which would cause an
underflow in pcd_14a_reader_scan_once, that in turn resulted in
HF_ERR_ATS being returned due to an invalid ATS length.
2023-10-17 23:32:51 +02:00
Philippe Teuwen 2beb8f74a3 cli: check if helper tools are available 2023-10-17 22:08:34 +02:00
Philippe Teuwen 82fcc76286 Changed battery level curves based on experimental measures, thanks @spp2000 ! 2023-10-17 21:25:16 +02:00
Philippe Teuwen 652ee4768d doc 2023-10-17 21:19:23 +02:00
dxl 1e134f1bcd ChangeLog update 2023-10-17 16:34:47 +08:00
dxl 15698fb338 Nested(And StaticNested) multithreaded decryption. 2023-10-17 16:34:22 +08:00
dxl 1ec025a24b Merge remote-tracking branch 'origin/main' 2023-10-17 16:30:47 +08:00
dxl 0e3144c994 Fixed bug where the 'i' variable was incorrectly used on printf 2023-10-17 16:25:48 +08:00
Philippe TeuwenandGitHub 363ff4f345 Merge pull request #172 from GameTec-live/main
doc: finally add linux
2023-10-16 21:16:17 +02:00
GameTec_live 070db3d773 fix: escape sequence 2023-10-16 21:09:26 +02:00
GameTec_live 3456d4c15d doc: remove unnescesary cp 2023-10-16 21:09:14 +02:00
GameTec_live d5187d3017 doc: finally add linux 2023-10-16 20:01:42 +02:00
Philippe TeuwenandGitHub 372bcf2460 technical_whitepaper : prevent github hallucinating email addresses 2023-10-15 23:34:51 +02:00
Philippe Teuwen 324dc578e5 cli: prepare comm debug 2023-10-15 01:39:00 +02:00
Philippe Teuwen 830ba98721 cli: move enums to new file 2023-10-15 01:17:34 +02:00
Philippe Teuwen 8ef42c705c cli: hw slot list: avoid unnecessary slot changes 2023-10-15 01:17:34 +02:00
Philippe Teuwen 43a6e822e6 cli: move color shortcuts to chameleon_util 2023-10-15 01:17:29 +02:00
Philippe TeuwenandGitHub f9be867029 Merge pull request #170 from augustozanellato/fix_factory_reset
Fix factory reset hang/wdt reset
2023-10-13 09:13:15 +02:00
Augusto Zanellato b35c1fadd9 Add changelog entry 2023-10-13 00:28:44 +02:00
Augusto Zanellato c1c10e9ba3 Fix factory reset hang/wdt reset
fds_util event handler was ignoring all the events related to
peer_manager files and that was causing a deadlock while waiting for
record deletion that in turn caused a wdt reset, usually this resulted in
a partially done factory reset.
The fix adds a `ignore_pm` flag to op_info struct that gets cleared by
fds_wipe allowing for a true reset to happen.
2023-10-13 00:26:32 +02:00
Philippe Teuwen 15bcae78be cli: atqa disambiguation 2023-10-12 20:39:18 +02:00
Philippe Teuwen 446b57e89f Changed fds_write_sync to take length in bytes instead of next multiple of 4 2023-10-11 23:08:25 +02:00
Philippe Teuwen 6236fdd4cf just in case, turn tag field off on exiting reader mode 2023-10-11 19:32:37 +02:00
Philippe Teuwen bac3552d85 fix field LED in LF reading and in HF cloning 2023-10-11 19:22:29 +02:00
Philippe Teuwen ea6576c567 renaming of slot into cloned when having cloned an ID/UID with a button, cf issue #166. Removed the goto 2023-10-11 18:49:59 +02:00
Philippe Teuwen 4fe9e1ea5b docs 2023-10-11 10:28:45 +02:00
Philippe Teuwen ffb6e00f1e fix spurious LED in battery level, assign battery level to long press B 2023-10-10 20:25:17 +02:00
Philippe Teuwen c4aef7e373 Changed hw slot list to display LF ID & HF anticol data, and names in the --short version too 2023-10-10 20:10:18 +02:00
Philippe Teuwen f512cbdbee cli: fix hw slot init 2023-10-10 10:57:53 +02:00
Philippe Teuwen f93418b7d8 cli: skip empty lines when several cmd lines are copy/pasted 2023-10-10 10:57:26 +02:00
Philippe Teuwen 89aa8c48f1 remove NRF_LOG_UART_ON_SWO_ENABLED committed by mistake 2023-10-10 10:56:49 +02:00
Philippe TeuwenandGitHub ab7592e7be Merge pull request #168 from RfidResearchGroup/rework_cli
Rework cli
2023-10-10 02:03:37 +02:00
dxl c9e4507d8f Use fastselect to improve the success rate of decryption. 2023-10-09 15:18:59 +08:00
dxl a9f775ff19 14443-a fast select implemented. 2023-10-09 15:17:54 +08:00
82 changed files with 17592 additions and 1617 deletions
+16
View File
@@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased]
- Skip already used items `hf mf elog --decrypt` (@p-l-)
- Parallelize mfkey32v2 processes called from CLI (@p-l-)
- Added support for mifare classic value block operations (@taichunmin)
- Added regression tests (@doegox)
- Changed git version to version tag instead of dev tag (@taichunmin)
- Fixed 14A emulate bug and MF1 emulate bug (@spp2000 and @xianglin1998)
- Fixed `hf 14a raw` command raising `AttributeError` (@augustozanellato)
- Fixed ATS handling in tags that NAK RATS (@augustozanellato)
- Changed battery level curves based on experimental measures (@spp2000)
- Added multithreading on Nested and StaticNested (@xianglin1998)
- Fixed factory reset hanging (@augustozanellato)
- Changed fds_write_sync to take length in bytes instead of next multiple of 4 (@doegox)
- Fixed field LED when LF reading and HF cloning (@doegox)
- Added renaming of slot into "cloned" when having cloned an ID/UID with a button (@doegox)
- Fixed spurious LED in battery level, assigned battery level to long press B (@doegox)
- Changed `hw slot list` to display LF ID & HF anticol data, and names in the --short version too (@doegox)
- Added colors to CLI help (@doegox)
- Changed massively CLI, cf https://github.com/RfidResearchGroup/ChameleonUltra/issues/164#issue-1930580576 (@doegox)
- Changed CLI help: lists display and now all commands support `-h` (@doegox)
+8 -2
View File
@@ -15,7 +15,8 @@ Starting from the top left, you find
- the *Device Name*: `Chameleon Ultra` or `Chameleon Lite` depending on the device connected ;
- the *Disconnect* button: pressing this icon cleanly disconnects the Chameleon. It is recommended to use this button whenever possible ;
- the *Connected Port*: it tells you where and how the chameleon is connected, followed by how it is connected (*Connection Method*), which displays a USB or Bluetooth icon. Last in that row is the *Battery Charge* display ;
- the *Connected Port*: it tells you where and how the chameleon is connected, followed by how it is connected (*Connection Method*), which displays a USB or Bluetooth icon ;
- the *Battery Charge* icon: you can press it long to get more details. Note that it is refreshed only when reopening the Homepage ;
- the *Used Slots*: it displays how many out of the 8 slots are used ;
- the *Slot Changer*: the currently selected slot is highlighted with a red circle, while enabled slots are filled in. Everything else is a hollow circle. The arrows left and right allow you to change the currently selected slot ;
- the *Firmware version*: the version is pulled from the device displayed, as well as git commit information ;
@@ -141,4 +142,9 @@ GDK_SCALE=2 GDK_DPI_SCALE=0.5 /usr/local/lib/chameleonultragui/chameleonultragui
### Key recovery from this card is not yet supported
This error may occur when the card you are trying to recovery keys from is requiring a not yet supported recovery technology. You cannot tell the required recovery method from the outside.
You may be able to solve this issue by dumping the card with a Proxmark3 or Mifare Classic Tool (Mobile App) and then importing a bin file.
You may be able to solve this issue by dumping the card with a Proxmark3 or Mifare Classic Tool (Mobile App) and then importing a bin file.
### Error: Invalid data length
This error may occur on windows devices and seems to be a deeper bug in the serial library.
Reconnecting the device may solve it, also make sure that the App and Firmware are up to date.
+75 -30
View File
@@ -40,13 +40,11 @@ Using ProxSpace to build the CLI is the easiest and most comfortable way to get
12. And the binaries with `cmake --build .`
13. Copy the binaries by running `cp -r ~/ChameleonUltra/software/bin/* ~/ChameleonUltra/software/script/`
13. Go into the script folder with `cd ~/ChameleonUltra/software/script/`
14. Go into the script folder with `cd ~/ChameleonUltra/software/script/`
14. Install python requirements with `pip install -r requirements.txt`
15. Install python requirements with `pip install -r requirements.txt`
16. Finally run the CLI with `python chameleon_cli_main.py`
15. Finally run the CLI with `python chameleon_cli_main.py`
To use after installing, just do the following:
@@ -76,7 +74,7 @@ Building natively is a bit more advanced and not recommended for beginners
4. Download and install [cmake](https://cmake.org/download/). Again, when asked, add to your path
5. Download and install [python](https://www.python.org/downloads/). When asked, add to your path (small checkbox in the bottom left)
5. Download and install [python](https://www.python.org/downloads/). When asked, add to your path (small checkbox in the bottom left). Python 3.9 or above is required.
6. Choose a suitable location and open a terminal. Clone the repository with `git clone https://github.com/RfidResearchGroup/ChameleonUltra.git`
@@ -106,7 +104,46 @@ To run again after installing, just do the following:
### Linux
*Coming Soon*
Install the dependencies
- Ubuntu / Debian:
`sudo apt install git cmake build-essential python3-venv`
- Arch:
`sudo pacman -S git cmake base-devel python3`
Python 3.9 or above is required.
Run the following script to clone the Repository, compile the tools and install Python dependencies in a virtual environment.
```sh
#!/bin/bash
git clone https://github.com/RfidResearchGroup/ChameleonUltra.git
(
cd ChameleonUltra/software/src
mkdir -p out
(
cd out
cmake ..
cmake --build . --config Release
)
)
(
cd ChameleonUltra/software/script
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
deactivate
)
```
To run the client after installing, do the following:
```sh
cd ChameleonUltra/software/script
source venv/bin/activate
python3 chameleon_cli_main.py
deactivate
```
### MacOS
@@ -116,31 +153,42 @@ To run again after installing, just do the following:
When in the CLI, plug in your Chameleon and connect with `hw connect`. If autodetection fails, get the Serial Port used by your Chameleon and run `hw connect -p COM11` (Replace `COM11` with your serial port, on Linux it may be `/dev/ttyACM0`)
### Common activities
- Connect to the CLI: `hw connect`
- Change slot: `hw slot change -s [1-8]`
*More examples coming soon*
### MFKEY32v2 walk-through
Make sure to be in the `software/` directory and run the Python CLI from there.
- Connect to the CLI: `hw connect`
- Check which slot can be used: `hw slot list`
- Change the slot type, here using slot 8 for a MFC 1k emulation: `hw slot type -s8 -t3`
- Init the slot content: `hw slot init -s8 -t3`
- or load an existing dump and set UID and anticollision data, cf `hf mf eload -h` and `hf mf sim -h`
- Enable the slot: `hw slot enable -s8 -e1`
- Change to the new slot: `hw slot change -s8`
- Activate the detection: `hf detection enable -e1`
```sh
# Connect to the CLI
hw connect
# Check which slot can be used
hw slot list
# Change the slot type, here using slot 8 for a MFC 1k emulation
hw slot type -s 8 -t MIFARE_1024
# Init the slot content
hw slot init -s 8 -t MIFARE_1024
# or load an existing dump and set UID and anticollision data,
# cf 'hf mf eload' and 'hf mf econfig'
# Enable the slot
hw slot enable -s 8 --hf
# Change to the new slot
hw slot change -s 8
# Activate the authentication logs
hf mf econfig --enable-log
```
Now disconnect, go to a reader and swipe it a few times
- Come back and connect to the CLI: `hw connect`
- See if nonces were collected: `hf detection count`
- We need 2 nonces per key to recover
- Recover the key(s) based on the collected nonces: `hf detection decrypt`. Output example:
Come back
```sh
# connect to the CLI
hw connect
# See if nonces were collected. We need 2 nonces per key to recover
hf mf elog
# Recover the key(s) based on the collected nonces
hf mf elog --decrypt
# Clean the logged detection nonces
hf mf econfig --disable-log
```
Output example:
```
- MF1 detection log count = 6, start download.
- Download done (144bytes), start parse and decrypt
@@ -153,8 +201,5 @@ Now disconnect, go to a reader and swipe it a few times
```
- To clean the logged detection nonces: `hf detection enable -e0` then `hf detection enable -e1`
*More examples coming soon*
+2 -2
View File
@@ -65,7 +65,7 @@ The Chameleon can be awaken:
The white LED labeled RF lights up when it detects a field, again only if the active slot supports it.
In some situations, it can be cumbersome to wait for the boot-up animation. This is configurable, cf e.g. the CLI command `hw settings animation set -h`.
In some situations, it can be cumbersome to wait for the boot-up animation. This is configurable, cf e.g. the CLI command `hw settings animation -h`.
On a new Chameleon (or after a factory reset), 3 slots are defined, slot 1 holding both a HF and a LF:
@@ -116,5 +116,5 @@ We are using the [SoftDevice S140](https://infocenter.nordicsemi.com/index.jsp?t
## The User Data
The Chameleon has a reserved space of memory and flash where it stores application settings, active slot and slots configurations and data. This will not be overwritten by DFU updates and the data will only be reset by either issuing `hw factory_reset --i-know-what-im-doing` in the CLI or clicking `Factory reset` in a GUI.
The Chameleon has a reserved space of memory and flash where it stores application settings, active slot and slots configurations and data. This will not be overwritten by DFU updates and the data will only be reset by either issuing `hw factory_reset --force` in the CLI or clicking `Factory reset` in a GUI.
*Warning:* Settings and/or data might be reset to defaults if you downgrade the firmware version up to a version not supporting the newer format.
Binary file not shown.
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 32 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 176 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 200 KiB

+42 -37
View File
@@ -50,7 +50,7 @@ E.g. LRC3(DATA) == LRC3(whole frame)
Each command and response have their own payload formats.
Standard response status is `STATUS_DEVICE_SUCCESS` for general commands, `HF_TAG_OK` for HF commands and `LF_TAG_OK` for LF commands.
Standard response status is `STATUS_SUCCESS` for general commands, `STATUS_HF_TAG_OK` for HF commands and `STATUS_LF_TAG_OK` for LF commands.
See [Guidelines](#new-data-payloads-guidelines-for-developers) for more info.
Beware, slots in protocol count from 0 to 7 (and from 1 to 8 in the CLI...).
@@ -64,11 +64,11 @@ In the following list, "CLI" refers to one typical CLI command using the describ
### 1001: CHANGE_DEVICE_MODE
* Command: 1 byte. `0x00`=emulator mode, `0x01`=reader mode
* Response: no data
* CLI: cf `hw mode set`
* CLI: cf `hw mode`
### 1002: GET_DEVICE_MODE
* Command: no data
* Response: data: 1 byte. `0x00`=emulator mode, `0x01`=reader mode
* CLI: cf `hw mode get`
* CLI: cf `hw mode`
### 1003: SET_ACTIVE_SLOT
* Command: 1 byte. `slot_number` between 0 and 7
* Response: no data
@@ -84,19 +84,19 @@ In the following list, "CLI" refers to one typical CLI command using the describ
### 1006: SET_SLOT_ENABLE
* Command: 3 bytes. `slot_number|sense_type|enable` with `slot_number` between 0 and 7, `sense_type` according to `tag_sense_type_t` enum and `enable` = `0x01` to enable, `0x00` to disable
* Response: no data
* CLI: cf `hw slot enable`
* CLI: cf `hw slot enable`/`hw slot disable`
### 1007: SET_SLOT_TAG_NICK
* Command: 2+N bytes. `slot_number|sense_type|name[N]` with `slot_number` between 0 and 7, `sense_type` according to `tag_sense_type_t` enum and `name` a UTF-8 encoded string of max 32 bytes, no null terminator.
* Response: no data
* CLI: cf `hw slot nick set`
* CLI: cf `hw slot nick`
### 1008: GET_SLOT_TAG_NICK
* Command: 2 bytes. `slot_number|sense_type` with `slot_number` between 0 and 7 and `sense_type` according to `tag_sense_type_t` enum.
* Response: a UTF-8 encoded string of max 32 bytes, no null terminator. If no nick name has been recorded in Flash, response status is `STATUS_FLASH_READ_FAIL`.
* CLI: cf `hw slot nick get`
* CLI: cf `hw slot nick`
### 1009: SLOT_DATA_CONFIG_SAVE
* Command: no data
* Response: no data
* CLI: cf `hw slot update`
* CLI: cf `hw slot store`
### 1010: ENTER_BOOTLOADER
* Command: no data
* Response: this special command does not return and will interrupt the communication link while rebooting in bootloader mode, needed for DFU.
@@ -104,11 +104,11 @@ In the following list, "CLI" refers to one typical CLI command using the describ
### 1011: GET_DEVICE_CHIP_ID
* Command: no data
* Response: 8 bytes. nRF `DEVICEID[8]` U64 in Network byte order.
* CLI: cf `hw chipid get`
* CLI: cf `hw chipid`
### 1012: GET_DEVICE_ADDRESS
* Command: no data
* Response: 6 bytes. nRF `DEVICEADDR[6]` U48 in Network byte order. First 2 MSBits forced to `0b11` to match BLE static address.
* CLI: cf `hw address get`
* CLI: cf `hw address`
### 1013: SAVE_SETTINGS
* Command: no data
* Response: no data
@@ -120,17 +120,17 @@ In the following list, "CLI" refers to one typical CLI command using the describ
### 1015: SET_ANIMATION_MODE
* Command: 1 byte, according to `settings_animation_mode_t` enum.
* Response: no data
* CLI: cf `hw settings animation set`
* CLI: cf `hw settings animation`
### 1016: GET_ANIMATION_MODE
* Command: no data
* Response: 1 byte, according to `settings_animation_mode_t` enum.
* CLI: cf `hw settings animation get`
* CLI: cf `hw settings animation`
### 1017: GET_GIT_VERSION
* Command: no data
* Response: n bytes, a UTF-8 encoded string, no null terminator.
* CLI: cf `hw version`
Notes: the returned string is the output of `git describe --abbrev=7 --dirty --always --tags` so, depending on the status of the repo it can be
Notes: the returned string is the output of `git describe --abbrev=7 --dirty --always --tags --match "v*.*"` so, depending on the status of the repo it can be
* a short tag, e.g. `v2.0.0` if the firmware is built from the tagged commit
* a longer tag indicating how far it is from the latest tag and 7 nibbles of its commit hash, prepended with `g`, e.g. 5 commits away from v2.0.0: `v2.0.0-5-g617d6d0`
* a long tag finishing with `-dirty` if the local repo contains changes not yet committed, e.g. `v2.0.0-5-g617d6d0-dirty`
@@ -144,19 +144,20 @@ Notes: the returned string is the output of `git describe --abbrev=7 --dirty --a
* CLI: cf `hw slot list`
### 1020: WIPE_FDS
* Command: no data
* Response: no data. Status is `STATUS_DEVICE_SUCCESS` or `STATUS_FLASH_WRITE_FAIL`. The device will reboot shortly after this command.
* Response: no data. Status is `STATUS_SUCCESS` or `STATUS_FLASH_WRITE_FAIL`. The device will reboot shortly after this command.
* CLI: cf `hw factory_reset`
### 1021: DELETE_SLOT_TAG_NICK
* Command: 2 bytes. `slot_number|sense_type` with `slot_number` between 0 and 7 and `sense_type` according to `tag_sense_type_t` enum.
* Response: no data
* CLI: cf `hw slot nick delete`
* CLI: cf `hw slot nick`
### 1023: GET_ENABLED_SLOTS
* Command: no data
* Response: 16 bytes, 8*2 bool = `0x00` or `0x01`, 2 bytes for each slot from 0 to 7, as `enabled_hf|enabled_lf`
* CLI: cf `hw slot list`
### 1024: DELETE_SLOT_SENSE_TYPE
* Command: 2 bytes. `slot_number|sense_type` with `slot_number` between 0 and 7 and `sense_type` according to `tag_sense_type_t` enum.
* Response: no data
* CLI: cf `hw factory_reset`
* CLI: cf `hw slot delete`
### 1025: GET_BATTERY_INFO
* Command: no data
* Response: 3 bytes, `voltage[2]|percentage`. Voltage: U16 in Network byte order.
@@ -166,19 +167,19 @@ Notes: wait about 5 seconds after wake-up, before querying the battery status, e
### 1026: GET_BUTTON_PRESS_CONFIG
* Command: 1 byte. Char `A` or `B` (`a`/`b` tolerated too)
* Response: 1 byte, `button_function` according to `settings_button_function_t` enum.
* CLI: cf `hw settings btnpress get`
* CLI: cf `hw settings btnpress`
### 1027: SET_BUTTON_PRESS_CONFIG
* Command: 2 bytes. `button|button_function` with `button` char `A` or `B` (`a`/`b` tolerated too) and `button_function` according to `settings_button_function_t` enum.
* Response: no data
* CLI: cf `hw settings btnpress set`
* CLI: cf `hw settings btnpress`
### 1028: GET_LONG_BUTTON_PRESS_CONFIG
* Command: 1 byte. Char `A` or `B` (`a`/`b` tolerated too)
* Response: 1 byte, `button_function` according to `settings_button_function_t` enum.
* CLI: cf `hw settings btnpress get`
* CLI: cf `hw settings btnpress`
### 1029: SET_LONG_BUTTON_PRESS_CONFIG
* Command: 2 bytes. `button|button_function` with `button` char `A` or `B` (`a`/`b` tolerated too) and `button_function` according to `settings_button_function_t` enum.
* Response: no data
* CLI: cf `hw settings btnpress set`
* CLI: cf `hw settings btnpress`
### 1030: SET_BLE_PAIRING_KEY
* Command: 6 bytes. 6 ASCII-encoded digits.
* Response: no data
@@ -190,7 +191,7 @@ Notes: wait about 5 seconds after wake-up, before querying the battery status, e
### 1032: DELETE_ALL_BLE_BONDS
* Command: no data
* Response: no data
* CLI: cf `hw ble bonds clear`
* CLI: cf `hw settings bleclearbonds`
### 1033: GET_DEVICE_MODEL
* Command: no data
* Response: 1 byte. `hw_version` aka `NRF_DFU_HW_VERSION` according to `chameleon_device_type_t` enum (0=Ultra, 1=Lite)
@@ -225,7 +226,7 @@ Notes: wait about 5 seconds after wake-up, before querying the battery status, e
* CLI: cf `hf 14a scan`
Notes:
* remind that if no tag is present, status will be `HF_TAG_NO` and Response empty.
* remind that if no tag is present, status will be `STATUS_HF_TAG_NO` and Response empty.
* at the moment, the firmware supports only one tag, but get your client ready for more!
* `atslen` must not be confused with `ats[0]`==`TL`. So `atslen|ats` = `00` means no ATS while `0100` would be an empty ATS.
### 2001: MF1_DETECT_SUPPORT
@@ -268,7 +269,7 @@ Notes:
### 2007: MF1_AUTH_ONE_KEY_BLOCK
* Command: 8 bytes: `type|block|key[6]`. Key as 6 bytes. Type=0x60 for key A, 0x61 for key B.
* Response: no data
* Status will be `HF_TAG_OK` if auth succeeded, else `MF_ERR_AUTH`
* Status will be `STATUS_HF_TAG_OK` if auth succeeded, else `STATUS_MF_ERR_AUTH`
* CLI: cf `hf mf nested`
### 2008: MF1_READ_ONE_BLOCK
* Command: 8 bytes: `type|block|key[6]`. Key as 6 bytes. Type=0x60 for key A, 0x61 for key B.
@@ -289,14 +290,18 @@ Notes:
* `reserved`:2
* Response: data sent by the card
* CLI: cf `hf 14a raw`
### 2011: MF1_MANIPULATE_VALUE_BLOCK
* Command: 21 bytes: `src_type|src_block|src_key[6]|operator|operand[4]|dst_type|dst_block|dst_key[6]`. Key as 6 bytes. Type=`0x60` for key A, `0x61` for key B. Operator=`0xC0` for decrement, `0xC1` for increment, `0xC2` for restore. Operand as I32 in Network byte order.
* Response: no data
* CLI: cf `hf mf value`
### 3000: EM410X_SCAN
* Command: no data
* Response: 5 bytes. `id[5]`. ID as 5 bytes.
* CLI: cf `lf em read`
* CLI: cf `lf em 410x read`
### 3001: EM410X_WRITE_TO_T55XX
* Command: 9+N*4 bytes: `id[5]|new_key[4]|old_key1[4]|old_key2[4]|...` (N>=1). . ID as 5 bytes. Keys as 4 bytes.
* Response: no data
* CLI: cf `lf em write`
* CLI: cf `lf em 410x write`
### 4000: MF1_WRITE_EMU_BLOCK_DATA
* Command: 1+N*16 bytes: `block_start|block_data1[16]|block_data2[16]|...` (1<=N<=31)
* Response: no data
@@ -304,15 +309,15 @@ Notes:
### 4001: HF14A_SET_ANTI_COLL_DATA
* Command: N bytes: `uidlen|uid[uidlen]|atqa[2]|sak|atslen|ats[atslen]`. UID, ATQA, SAK and ATS as bytes.
* Response: no data
* CLI: cf `hf mf sim`
* CLI: cf `hf mf econfig`/`hf mfu econfig`
### 4004: MF1_SET_DETECTION_ENABLE
* Command: 1 byte, bool = `0x00` or `0x01`
* Response: no data
* CLI: cf `hf detection enable`
* CLI: cf `hf mf econfig`
### 4005: MF1_GET_DETECTION_COUNT
* Command: no data
* Response: 4 bytes, `count[4]`, U32 in Network byte order.
* CLI: cf `hf detection count`
* CLI: cf `hf mf elog`
### 4006: MF1_GET_DETECTION_LOG
* Command: 4 bytes, `index`, U32 in Network byte order.
* Response: N*18 bytes. 0<=N<=28
@@ -322,7 +327,7 @@ Notes:
* `nt[4]` ?
* `nr[4]` ?
* `ar[4]` ?
* CLI: cf `hf detection decrypt`
* CLI: cf `hf mf elog`
### 4007: MF1_GET_DETECTION_ENABLE
* Command: no data
* Response: 1 byte, bool = `0x00` or `0x01`
@@ -339,7 +344,7 @@ Notes:
* `gen2_mode`, cf [MF1_GET_GEN2_MODE](#4012-mf1_get_gen2_mode)
* `block_anti_coll_mode`, cf [MF1_GET_BLOCK_ANTI_COLL_MODE](#4014-mf1_get_block_anti_coll_mode)
* `write_mode`, cf [MF1_GET_WRITE_MODE](#4016-mf1_get_write_mode)
* CLI: cf `hw slot list`
* CLI: cf `hf mf econfig`
### 4010: MF1_GET_GEN1A_MODE
* Command: no data
* Response: 1 byte, bool = `0x00` or `0x01`
@@ -347,7 +352,7 @@ Notes:
### 4011: MF1_SET_GEN1A_MODE
* Command: 1 byte, bool = `0x00` or `0x01`
* Response: no data
* CLI: cf `hf mf settings`
* CLI: cf `hf mf econfig`
### 4012: MF1_GET_GEN2_MODE
* Command: no data
* Response: 1 byte, bool = `0x00` or `0x01`
@@ -355,7 +360,7 @@ Notes:
### 4013: MF1_SET_GEN2_MODE
* Command: 1 byte, bool = `0x00` or `0x01`
* Response: no data
* CLI: cf `hf mf settings`
* CLI: cf `hf mf econfig`
### 4014: MF1_GET_BLOCK_ANTI_COLL_MODE
* Command: no data
* Response: 1 byte, bool = `0x00` or `0x01`
@@ -363,7 +368,7 @@ Notes:
### 4015: MF1_SET_BLOCK_ANTI_COLL_MODE
* Command: 1 byte, bool = `0x00` or `0x01`
* Response: no data
* CLI: cf `hf mf settings`
* CLI: cf `hf mf econfig`
### 4016: MF1_GET_WRITE_MODE
* Command: no data
* Response: 1 byte, according to `nfc_tag_mf1_write_mode_t` aka `MifareClassicWriteMode` enum
@@ -371,19 +376,19 @@ Notes:
### 4017: MF1_SET_WRITE_MODE
* Command: 1 byte, according to `nfc_tag_mf1_write_mode_t` aka `MifareClassicWriteMode` enum
* Response: no data
* CLI: cf `hf mf settings`
* CLI: cf `hf mf econfig`
### 4018: HF14A_GET_ANTI_COLL_DATA
* Command: no data
* Response: no data or N bytes: `uidlen|uid[uidlen]|atqa[2]|sak|atslen|ats[atslen]`. UID, ATQA, SAK and ATS as bytes.
* CLI: cf `hf mf info`
* CLI: cf `hw slot list`/`hf mf econfig`/`hf mfu econfig`
### 5000: EM410X_SET_EMU_ID
* Command: 5 bytes. `id[5]`. ID as 5 bytes.
* Response: no data
* CLI: cf `lf em sim set`
* CLI: cf `lf em 410x econfig`
### 5001: EM410X_GET_EMU_ID
* Command: no data
* Response: 5 bytes. `id[5]`. ID as 5 bytes.
* CLI: cf `lf em sim get`
* CLI: cf `lf em 410x econfig`
## New data payloads: guidelines for developers
@@ -396,7 +401,7 @@ Be verbose, explicit and reuse conventions, in order to enhance code maintainabi
- Avoid hardcoding offsets, use `sizeof()`, `offsetof(struct, field)` in C and `struct.calcsize()` in Python
- For complex bitfield structs, exceptionally you can use ctypes in Python. Beware ctypes.BigEndianStructure bitfield will be parsed in the firmware in the reverse order, from LSB to MSB.
### Guideline: Status
If single byte of data to return, still use a 1-byte `data`, not `status`. Standard response status is `STATUS_DEVICE_SUCCESS` for general commands, `HF_TAG_OK` for HF commands and `LF_TAG_OK` for LF commands. If the response status is different than those, the response data is empty. Response status are generic and cover things like tag disappearance or tag non-conformities with the ISO standard. If a command needs more specific response status, it is added in the first byte of the data, to avoid cluttering the 1-byte general status enum with command-specific statuses. See e.g. [MF1_DARKSIDE_ACQUIRE](#2004-mf1_darkside_acquire).
If single byte of data to return, still use a 1-byte `data`, not `status`. Standard response status is `STATUS_SUCCESS` for general commands, `STATUS_HF_TAG_OK` for HF commands and `STATUS_LF_TAG_OK` for LF commands. If the response status is different than those, the response data is empty. Response status are generic and cover things like tag disappearance or tag non-conformities with the ISO standard. If a command needs more specific response status, it is added in the first byte of the data, to avoid cluttering the 1-byte general status enum with command-specific statuses. See e.g. [MF1_DARKSIDE_ACQUIRE](#2004-mf1_darkside_acquire).
### Guideline: unambiguous types
- Use unambiguous types such as `uint16_t`, not `int` or `enum`. Cast explicitly `int` and `enum` to `uint_t` of proper size
- Use Network byte order for 16b and 32b integers
+3 -3
View File
@@ -135,10 +135,10 @@ functions have been realized with it!
# Ultra-low power consumption
It integrates a high-performance and low-power NFC module inside. When the NFC unit is turned on, the total current of
the chip is only 5mA@3.3V.
the chip is only 5mA @3.3V.
The underlying interaction is done independently by the NFC unit and does not occupy the CPU.
In addition, the nRF52840 itself is a high-performance low-power BLE chip, and the encryption and calculation process is
only 7mA@3.3V. It can greatly reduce the battery volume and prolong the working time. That is to say, the 35mAh 10mm*
only 7mA @3.3V. It can greatly reduce the battery volume and prolong the working time. That is to say, the 35mAh 10mm*
40mm button lithium battery can guarantee to be charged once every half a year under the working condition of swiping
the card 8 times a day for 3 seconds each time. Full potential for everyday use.
@@ -196,4 +196,4 @@ When the project got open-sourced, DXL shared a few notes in [issue #1](https://
**Firmware:** Chameleon Ultra is a very powerful platform. We can develop various 14A protocol card simulations based on this platform. In terms of high-frequency card simulation, DXL has completed the development of high-performance MifareClassic Mini ->S50 ->S70 card. However, the development of cards for other technologies has not been completed, such as UL, UL-C, NTAG, etc. In terms of low-frequency card simulation, DXL has completed the development of EM410x, but the development of other technology cards has not been completed, such as FSK and PSK-related technology cards. For card reader, DXL has completed the reading, writing and decryption of M1 card, reading EM410x and writing to T5577. Others, such as the reading and writing of UL card and NTAG card, are not completed yet.
**Client:** At present, ChameleonUltra uses python to develop the CLI, cooperate with independent exe to perform the decryption task, and complete the decoupling of the business logic of the CLI and the decryption algorithm logic. Due to time reasons, DXL only completes commands such as device connection, M1 card data upload, M1 card detection log download and decryption, M1 card read and write block, and so on. The complete nested, rdsc, and autopwn instructions like PM3 have not yet been implemented, which may require our joint efforts. Finally, I believe that Chameleon Ultra is definitely not limited to CLI as a way of device interaction. Perhaps we can further develop PC-side GUI, and develop IOS and Android APP. USB+BLE support makes everything possible.
**Client:** At present, ChameleonUltra uses python to develop the CLI, cooperate with independent exe to perform the decryption task, and complete the decoupling of the business logic of the CLI and the decryption algorithm logic. Due to time reasons, DXL only completes commands such as device connection, M1 card data upload, M1 card detection log download and decryption, M1 card read and write block, and so on. The complete nested, rdsc, and autopwn instructions like PM3 have not yet been implemented, which may require our joint efforts. Finally, I believe that Chameleon Ultra is definitely not limited to CLI as a way of device interaction. Perhaps we can further develop PC-side GUI, and develop IOS and Android APP. USB+BLE support makes everything possible.
+34 -1
View File
@@ -22,7 +22,7 @@ On Android make sure your location is turned, as that allows for scanning of blu
After BLE pairing, both the phone and ChameleonUltra will save a secret key for encrypted communication. If either party deletes the pairing record, it will result in communication failure. If Bluetooth cannot be connected, clearing the pairing information on the other side can solve the problem:
* Find the Bluetooth settings in the phone's system settings and cancel pairing with the ChameleonUltra.
* In the CLI of ChameleonUltra, execute the `hw ble bonds clear` command to clear all pairing records.
* In the CLI of ChameleonUltra, execute the `hw settings bleclearbonds` command to clear all pairing records.
Default BLE connect key(passkey) is `123456`
@@ -82,6 +82,39 @@ pacman -R ninja --noconfirm
pacman -S mingw-w64-x86_64-ninja --noconfirm
```
## cmake: Undefined reference to "pthread_create"
It has been reported that on some Linux systems cmake doesnt find pthread.
Make sure to have libpthread installed, the package may be named differently on your distro.
On ubuntu and same based systems it is the following command:
```
sudo apt install libpthread-stubs0-dev
```
If this doesnt fix it, you may need to set pthread in the LDFLAGS enviroment variable, this can be done by running the command with the enviroment variable at the beginning:
```
LDFLAGS=-pthread cmake ..
```
If the error still persists you may also need to provide a specific compiler version, you do that by adding the -DCMAKE_C_COMPILER argument:
```
LDFLAGS=-pthread cmake -DCMAKE_C_COMPILER=gcc-11 ..
```
The compiler needs to be installed too ofcourse, the package name may be differently on your distro.
On ubuntu and same based systems its the following command:
```
sudo apt install gcc-11 g++-11
```
The following ```cmake --build . --config Release``` should work again without modification.
# CLI usage
## InvalidException: Device unsupported cmd
+2 -2
View File
@@ -26,13 +26,13 @@ CHAMELEON_LITE := lite
CURRENT_DEVICE_TYPE ?= ${CHAMELEON_ULTRA}
# Versioning information
GIT_VERSION := $(shell git describe --abbrev=7 --dirty --always --tags)
GIT_VERSION := $(shell git describe --abbrev=7 --dirty --always --tags --match "v*.*")
APP_FW_SEMVER := $(subst v,,$(shell git describe --tags --abbrev=0 --match "v*.*"))
APP_FW_VER_MAJOR := $(word 1,$(subst ., ,$(APP_FW_SEMVER)))
APP_FW_VER_MINOR := $(word 2,$(subst ., ,$(APP_FW_SEMVER)))
# Enable NRF_LOG on SWO pin as UART TX
NRF_LOG_UART_ON_SWO_ENABLED := 1
NRF_LOG_UART_ON_SWO_ENABLED := 0
# Enable SDK validation checks
SDK_VALIDATION := 0
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -5,7 +5,7 @@
//#define APP_FW_VER_MAJOR 2
//#define APP_FW_VER_MINOR 0
#if !(defined APP_FW_VER_MAJOR && defined APP_FW_VER_MINOR)
#error You need to define APP_FW_VER_MAJOR and APP_FW_VER_MINOR
#error You need to define APP_FW_VER_MAJOR and APP_FW_VER_MINOR
#endif
// Merge major and minor version code to U16 value.
+51 -30
View File
@@ -38,7 +38,7 @@ NRF_LOG_MODULE_REGISTER();
#include "tag_emulation.h"
#include "usb_main.h"
#include "rgb_marquee.h"
#include "tag_persistence.h"
#include "settings.h"
// Defining soft timers
@@ -533,6 +533,7 @@ static void cycle_slot(bool dec) {
}
static void show_battery(void) {
rgb_marquee_stop();
uint32_t *led_pins = hw_get_led_array();
// if still in the first 4s after boot, blink red while waiting for battery info
while (percentage_batt_lvl == 0) {
@@ -595,6 +596,8 @@ static void offline_status_ok(void) {
// fast detect a 14a tag uid to sim
static void btn_fn_copy_ic_uid(void) {
bool lf_copy_succeeded = false;
bool hf_copy_succeeded = false;
uint8_t status;
uint8_t id_buffer[5] = { 0x00 };
// get 14a tag res buffer;
@@ -602,7 +605,7 @@ static void btn_fn_copy_ic_uid(void) {
tag_slot_specific_type_t tag_types;
tag_emulation_get_specific_types_by_slot(slot_now, &tag_types);
nfc_tag_14a_coll_res_entity_t *antres;
nfc_tag_14a_coll_res_entity_t *antres = NULL;
bool is_reader_mode_now = get_device_mode() == DEVICE_MODE_READER;
// first, we need switch to reader mode.
@@ -617,11 +620,12 @@ static void btn_fn_copy_ic_uid(void) {
case TAG_TYPE_EM410X:
status = PcdScanEM410X(id_buffer);
if (status == LF_TAG_OK) {
if (status == STATUS_LF_TAG_OK) {
tag_data_buffer_t *buffer = get_buffer_by_tag_type(TAG_TYPE_EM410X);
memcpy(buffer->buffer, id_buffer, LF_EM410X_TAG_ID_SIZE);
tag_emulation_load_by_buffer(TAG_TYPE_EM410X, false);
NRF_LOG_INFO("Offline LF uid copied")
lf_copy_succeeded = true;
offline_status_ok();
} else {
NRF_LOG_INFO("No LF tag found");
@@ -657,42 +661,59 @@ static void btn_fn_copy_ic_uid(void) {
case TAG_TYPE_UNDEFINED:
// empty HF slot, nothing to do
goto exit;
break;
default:
NRF_LOG_ERROR("Unsupported HF tag type")
offline_status_error();
goto exit;
break;
}
if (!is_reader_mode_now) {
// finish HF reader initialization
pcd_14a_reader_reset();
if (antres != NULL) {
if (!is_reader_mode_now) {
// finish HF reader initialization
pcd_14a_reader_reset();
}
pcd_14a_reader_antenna_on();
bsp_delay_ms(8);
}
// select a tag
picc_14a_tag_t tag;
// select a tag
picc_14a_tag_t tag;
status = pcd_14a_reader_scan_auto(&tag);
if (status == HF_TAG_OK) {
// copy uid
antres->size = tag.uid_len;
memcpy(antres->uid, tag.uid, tag.uid_len);
// copy atqa
memcpy(antres->atqa, tag.atqa, 2);
// copy sak
antres->sak[0] = tag.sak;
// copy ats
antres->ats.length = tag.ats_len;
memcpy(antres->ats.data, tag.ats, tag.ats_len);
NRF_LOG_INFO("Offline HF uid copied")
offline_status_ok();
} else {
NRF_LOG_INFO("No HF tag found");
offline_status_error();
status = pcd_14a_reader_scan_auto(&tag);
pcd_14a_reader_antenna_off();
if (status == STATUS_HF_TAG_OK) {
// copy uid
antres->size = tag.uid_len;
memcpy(antres->uid, tag.uid, tag.uid_len);
// copy atqa
memcpy(antres->atqa, tag.atqa, 2);
// copy sak
antres->sak[0] = tag.sak;
// copy ats
antres->ats.length = tag.ats_len;
memcpy(antres->ats.data, tag.ats, tag.ats_len);
NRF_LOG_INFO("Offline HF uid copied")
hf_copy_succeeded = true;
offline_status_ok();
} else {
NRF_LOG_INFO("No HF tag found");
offline_status_error();
}
}
if (lf_copy_succeeded || hf_copy_succeeded) {
fds_slot_record_map_t map_info;
char *nick = "cloned";
uint8_t buffer[36];
buffer[0] = strlen(nick);
memcpy(buffer + 1, nick, buffer[0]);
if (lf_copy_succeeded) {
get_fds_map_by_slot_sense_type_for_nick(slot_now, TAG_SENSE_LF, &map_info);
fds_write_sync(map_info.id, map_info.key, sizeof(buffer), buffer);
}
if (hf_copy_succeeded) {
get_fds_map_by_slot_sense_type_for_nick(slot_now, TAG_SENSE_HF, &map_info);
fds_write_sync(map_info.id, map_info.key, sizeof(buffer), buffer);
}
}
exit:
// keep reader mode or exit reader mode.
if (!is_reader_mode_now) {
tag_mode_enter();
+12 -12
View File
@@ -5,21 +5,21 @@
/////////////////////////////////////////////////////////////////////
// 14a status
/////////////////////////////////////////////////////////////////////
#define HF_TAG_OK (0x00) // IC card operation successful
#define HF_TAG_NO (0x01) // No IC card found
#define HF_ERR_STAT (0x02) // IC Card communication error
#define HF_ERR_CRC (0x03) // IC Card communication verification error
#define HF_COLLISION (0x04) // IC card conflict
#define HF_ERR_BCC (0x05) // IC card BCC error
#define MF_ERR_AUTH (0x06) // MF card verification failed
#define HF_ERR_PARITY (0x07) // IC card parity error
#define HF_ERR_ATS (0x08) // ATS should be present but card NAKed
#define STATUS_HF_TAG_OK (0x00) // IC card operation successful
#define STATUS_HF_TAG_NO (0x01) // No IC card found
#define STATUS_HF_ERR_STAT (0x02) // IC Card communication error
#define STATUS_HF_ERR_CRC (0x03) // IC Card communication verification error
#define STATUS_HF_COLLISION (0x04) // IC card conflict
#define STATUS_HF_ERR_BCC (0x05) // IC card BCC error
#define STATUS_MF_ERR_AUTH (0x06) // MF card verification failed
#define STATUS_HF_ERR_PARITY (0x07) // IC card parity error
#define STATUS_HF_ERR_ATS (0x08) // ATS should be present but card NAKed
/////////////////////////////////////////////////////////////////////
// lf status
/////////////////////////////////////////////////////////////////////
#define LF_TAG_OK (0x40) // Some of the low -frequency cards are successful!
#define EM410X_TAG_NO_FOUND (0x41) // Can't search for valid EM410X tags
#define STATUS_LF_TAG_OK (0x40) // Some of the low -frequency cards are successful!
#define STATUS_EM410X_TAG_NO_FOUND (0x41) // Can't search for valid EM410X tags
/////////////////////////////////////////////////////////////////////
@@ -28,7 +28,7 @@
#define STATUS_PAR_ERR (0x60) // The parameter errors transferred by the BLE instruction, or call the parameter error transmitted by certain functions
#define STATUS_DEVICE_MODE_ERROR (0x66) // The mode of the current device is wrong, and the corresponding API cannot be called
#define STATUS_INVALID_CMD (0x67) // Invalid instruction
#define STATUS_DEVICE_SUCCESS (0x68) // Device -related operations successfully executed
#define STATUS_SUCCESS (0x68) // Device -related operations successfully executed
#define STATUS_NOT_IMPLEMENTED (0x69) // Calling some unrealized operations, which belongs to the missed error of the developer
#define STATUS_FLASH_WRITE_FAIL (0x70) // Flash writing failed
#define STATUS_FLASH_READ_FAIL (0x71) // Flash read failed
+17 -36
View File
@@ -226,44 +226,25 @@ __INLINE uint32_t map(uint32_t x, uint32_t in_min, uint32_t in_max, uint32_t out
//Battery voltage to percentage calculation
uint32_t BATVOL2PERCENT(uint16_t VOL) {
//100% 4.20V 1
//90 % 4.06V 80%-100% white
//80 % 3.98V 1
//70 % 3.92V 60%-80% white
//60 % 3.87V 1
//50 % 3.82V 40%-60% white
//40 % 3.79V 1
//30 % 3.77V 20%-40% white
//20 % 3.74V 1
//10 % 3.68V 5%-20% red
//5 % 3.45V 1 Turn off
//0 % 3.00V
//#define P100VOL 4200
//#define P80VOL 3980
//#define P60VOL 3870
//#define P40VOL 3790
//#define P20VOL 3740
//#define P5VOL 3450
// Based on https://github.com/RfidResearchGroup/ChameleonUltra/issues/167#issuecomment-1766908799
//100% 4.20V 1
//90 % 4.00V 80%-100% white
//80 % 3.89V 1
//70 % 3.79V 60%-80% white
//60 % 3.70V 1
//50 % 3.62V 40%-60% white
//40 % 3.57V 1
//30 % 3.53V 20%-40% white
//20 % 3.51V 1
//10 % 3.46V 5%-20% red
//5 % 3.43V 1 Turn off
//0 % 3.00V
#if defined(PROJECT_CHAMELEON_ULTRA)
// Ultra
#define P100VOL 4200
#define P80VOL 3890
#define P60VOL 3700
#define P40VOL 3570
#define P20VOL 3510
#define P5VOL 3230
#define P80VOL 4034
#define P60VOL 3904
#define P40VOL 3824
#define P20VOL 3754
#define P5VOL 3644
#else
// Lite
#define P100VOL 4200
#define P80VOL 3934
#define P60VOL 3844
#define P40VOL 3784
#define P20VOL 3744
#define P5VOL 3644
#endif
if (VOL > P80VOL) {
//80-100
+1
View File
@@ -66,6 +66,7 @@
#define DATA_CMD_MF1_READ_ONE_BLOCK (2008)
#define DATA_CMD_MF1_WRITE_ONE_BLOCK (2009)
#define DATA_CMD_HF14A_RAW (2010)
#define DATA_CMD_MF1_MANIPULATE_VALUE_BLOCK (2011)
//
// ******************************************************************
@@ -125,7 +125,7 @@ inline void nfc_tag_14a_append_bcc(uint8_t *pbtData, size_t szLen) {
*
*/
inline void nfc_tag_14a_append_crc(uint8_t *pbtData, size_t szLen) {
calc_14a_crc_lut(pbtData, szLen, pbtData + szLen);
calc_14a_crc_lut(pbtData, szLen, &pbtData[szLen]);
}
/**
@@ -134,10 +134,10 @@ inline void nfc_tag_14a_append_crc(uint8_t *pbtData, size_t szLen) {
*/
bool nfc_tag_14a_checks_crc(uint8_t *pbtData, size_t szLen) {
//if (szLen < 3) return false;
uint8_t c1 = pbtData[szLen - 2];
uint8_t c2 = pbtData[szLen - 1];
nfc_tag_14a_append_crc(pbtData, szLen - 2);
return pbtData[szLen - 2] == c1 && pbtData[szLen - 1] == c2;
uint8_t crc_calc[2];
calc_14a_crc_lut(pbtData, szLen - 2, crc_calc);
// NRF_LOG_INFO("%02x%02x , %02x%02x", pbtData[szLen - 2], pbtData[szLen - 1], crc_calc[0], crc_calc[1]);
return pbtData[szLen - 2] == crc_calc[0] && pbtData[szLen - 1] == crc_calc[1];
}
/**
@@ -298,16 +298,6 @@ void nfc_tag_14a_tx_bytes(uint8_t *data, uint32_t bytes, bool appendCrc) {
NFC_14A_TX_BYTE_CORE(data, bytes, appendCrc, NRF_NFCT_FRAME_DELAY_MODE_WINDOWGRID);
}
/**@brief The function of sending the byte flow, this implementation automatically sends SOF
*
* @param[in] data The byte flow data to be sent
* @param[in] bytes The length of the byte flow to be sent
* @param[in] appendCrc Whether to send the byte flow, automatically send the CRC16 verification automatically
*/
void nfc_tag_14a_tx_bytes_delay_freerun(uint8_t *data, uint32_t bytes, bool appendCrc) {
NFC_14A_TX_BYTE_CORE(data, bytes, appendCrc, NRF_NFCT_FRAME_DELAY_MODE_FREERUN);
}
/**
* @brief: Function for response reader core implemented
* @param[in] bits Send bits length
@@ -344,18 +334,7 @@ void nfc_tag_14a_tx_bits(uint8_t *data, uint32_t bits) {
void nfc_tag_14a_tx_nbit(uint8_t data, uint32_t bits) {
m_is_responded = true;
m_nfc_tx_buffer[0] = data;
NFC_14A_TX_BITS_CORE(bits, NRF_NFCT_FRAME_DELAY_MODE_FREERUN);
}
/**@brief The function of sending n bits is implemented, and this implementation is automatically sent SOF
*
* @param[in] data BIT data to be sent
* @param[in] bits To send a few bites
*/
void nfc_tag_14a_tx_nbit_delay_window(uint8_t data, uint32_t bits) {
m_is_responded = true;
m_nfc_tx_buffer[0] = data;
NFC_14A_TX_BITS_CORE(bits, NRF_NFCT_FRAME_DELAY_MODE_WINDOW);
NFC_14A_TX_BITS_CORE(bits, NRF_NFCT_FRAME_DELAY_MODE_WINDOWGRID);
}
/**
@@ -564,7 +543,7 @@ void nfc_tag_14a_data_process(uint8_t *p_data) {
// Back to ATS data according to FSD, FSD is the largest frame size supported by PCD. After removing CRC, it is the actual data frame size support
nfc_tag_14a_tx_bytes(auto_coll_res->ats->data, len, true);
} else {
nfc_tag_14a_tx_nbit_delay_window(NAK_INVALID_OPERATION_TBIV, 4);
nfc_tag_14a_tx_nbit(NAK_INVALID_OPERATION_TBIV, 4);
}
// After handling the explicitly sending RATS instructions outside the outside, wait directly for the next round of communication
return;
@@ -579,23 +558,6 @@ void nfc_tag_14a_data_process(uint8_t *p_data) {
}
}
static inline void nfc_core_reset(void) {
uint32_t int_enabled = nrf_nfct_int_enable_get();
// Reset the NFCT peripheral.
*(volatile uint32_t *)0x40005FFC = 0;
*(volatile uint32_t *)0x40005FFC;
*(volatile uint32_t *)0x40005FFC = 1;
// Restore parameter settings after the reset of the NFCT peripheral.
nrf_nfct_frame_delay_max_set(0x00001000UL);
// Use Window Grid frame delay mode.
nrf_nfct_frame_delay_mode_set(NRF_NFCT_FRAME_DELAY_MODE_WINDOWGRID);
// Restore interrupts.
nrf_nfct_int_enable(int_enabled);
}
static inline void nfc_fdt_reset(void) {
// STOP TX
*(volatile uint32_t *)0x40005010 = 0x01;
@@ -644,8 +606,6 @@ void nfc_tag_14a_event_callback(nrfx_nfct_evt_t const *p_event) {
TAG_FIELD_LED_OFF()
m_tag_state_14a = NFC_TAG_STATE_14A_IDLE;
// nfc_core_reset();
NRF_LOG_INFO("HF FIELD LOST");
break;
}
@@ -109,9 +109,7 @@ void nfc_tag_14a_sense_switch(bool enable);
void nfc_tag_14a_set_handler(nfc_tag_14a_handler_t *handler);
void nfc_tag_14a_set_state(nfc_tag_14a_state_t state);
void nfc_tag_14a_tx_bytes(uint8_t *data, uint32_t bytes, bool appendCrc);
void nfc_tag_14a_tx_bytes_delay_freerun(uint8_t *data, uint32_t bytes, bool appendCrc);
void nfc_tag_14a_tx_bits(uint8_t *data, uint32_t bits);
void nfc_tag_14a_tx_nbit_delay_window(uint8_t data, uint32_t bits);
void nfc_tag_14a_tx_nbit(uint8_t data, uint32_t bits);
// Determine whether it is an effective UID length

Some files were not shown because too many files have changed in this diff Show More