mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Merge branch 'main' into software-capabilities
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
***Things to try before submitting a bug report***
|
||||
|
||||
* read the [troubleshooting guide](https://github.com/RfidResearchGroup/ChameleonUltra/blob/main/docs/troubleshooting.md)
|
||||
* check existing [issues](https://github.com/RfidResearchGroup/ChameleonUltra/issues)
|
||||
* use the latest firmware and CLI
|
||||
* for issues specific to another client than the Python CLI, use the corresponding issue tracker. E.g. [here](https://github.com/GameTec-live/ChameleonUltraGUI/issues) for the ChameleonUltraGUI
|
||||
|
||||
***Compilation problems***
|
||||
Try compiling with verbose. Use `make VERBOSE=1` for the firmware and the software/src tools.
|
||||
Include the verbose compilation logs.
|
||||
|
||||
***flashing problems***
|
||||
Have you followed the instructions properly?
|
||||
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior.
|
||||
Explain it as you would do to someone not familiar with the problematic feature.
|
||||
What is the abnormal behavior you observed?
|
||||
E.g.
|
||||
1. Connect '....'
|
||||
2. Execute '....'
|
||||
3. Press button '....'
|
||||
4. See error '....'
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem. For console text and logs, better to dump them as text than image. Attach files if too long.
|
||||
|
||||
**Host (please complete the following information):**
|
||||
- OS and version
|
||||
- for compilation issues, the toolchain version
|
||||
- inside CLI run `hw version` and paste the output here
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Official channels Chameleon Ultra Community
|
||||
url: https://github.com/RfidResearchGroup/ChameleonUltra#official-channels
|
||||
about: Got questions? Ask in *official channels*, not in an issue
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[idea]"
|
||||
labels: Request, enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Please keep in mind we are still at the infancy of the project and a lot has still to be done.
|
||||
|
||||
Have first a look at the [Whitepaper](https://github.com/RfidResearchGroup/ChameleonUltra/blob/main/docs/technical_whitepaper.md), the Wiki [Roadmap](https://github.com/RfidResearchGroup/ChameleonUltra/wiki/Public-Roadmap) and [Wishlist](https://github.com/RfidResearchGroup/ChameleonUltra/wiki/Wishlist).
|
||||
No need for creating issues for well known missing supports, we are already aware :)
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
+4
-1
@@ -3,6 +3,9 @@ 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]
|
||||
- ChameleonLite emulation bug fixed (@spp2000)
|
||||
- Fixed MFC emulation issues with OEM readers, also temporarily disabling NFC_MF1_FAST_SIM (@xianglin1998)
|
||||
- Fixed Chameleon crash during BLE pairing (@Foxushka)
|
||||
- Fixed CLI takes into account Lite refusing to enter Reader mode (@doegox)
|
||||
- Security BLE implemented (@xianglin1998)
|
||||
- Added `hw settings blekey` to get and set ble connect key (@xianglin1998)
|
||||
@@ -19,7 +22,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
|
||||
- Added offline copy EM card uid for btnpress (@nemanjan00)
|
||||
- Added offline copy ic card uid for btnpress (@xianglin1998)
|
||||
- Added `hw settings btnpress` to get and set button press function (@xianglin1998)
|
||||
- Added `hw battery` to get battery informartion (@xianglin1998)
|
||||
- Added `hw battery` to get battery information (@xianglin1998)
|
||||
- Added `hw slot delete` to delete HF or LF out of a HF+LF slot (@augustozanellato)
|
||||
- Changed CLI prompt autocompletion, saved history and internal cmd registration (@szymex73)
|
||||
- Fixed SDK NFC IRQ handler busy loop (@doegox)
|
||||
|
||||
@@ -20,9 +20,15 @@ Read the [available documentation](docs/README.md).
|
||||
|
||||
# Videos
|
||||
|
||||
*Beware some of the instructions might have changed since recording, theck the current documentation in doubt!*
|
||||
*Beware some of the instructions might have changed since recording, check the current documentation when in doubt!*
|
||||
|
||||
* [Downloading and compiling the official CLI](https://www.youtube.com/watch?v=VGpAeitNXH0)
|
||||
* [Downloading ChameleonUltraGUI](https://www.youtube.com/watch?v=rHH7iqbX3nY)
|
||||
|
||||
# Official channels
|
||||
|
||||
Where do you find the community?
|
||||
|
||||
* [RFID Hacking community discord server](https://t.ly/d4_C)
|
||||
* Software/chameleon-dev for firmware and clients development discussions
|
||||
* Devices/chameleon-ultra for usage discussions
|
||||
|
||||
+20
-10
@@ -4,22 +4,32 @@ This guide goal is to guide you through setting up and using your Chameleon Ultr
|
||||
|
||||
This Guide is split up into multiple "subguides":
|
||||
|
||||
- ["Whitepaper"](./technical_whitepaper.md): Discover what the Chameleon Ultra is capable of
|
||||
### About the device
|
||||
|
||||
- ["Hardware"](./hardware.md): Learn to know the hardware of your Chameleon
|
||||
- [Whitepaper](./technical_whitepaper.md): Discover what the Chameleon Ultra is capable of.
|
||||
|
||||
- ["Firmware"](./firmware.md): Your Chameleon runs a firmware, learn what it can do and how to use it
|
||||
- [Hardware](./hardware.md): Learn to know the hardware of your Chameleon.
|
||||
|
||||
- ["CLI"](./cli.md): The official way to control your Chameleon is via the **C**ommand **L**ine **I**nterface (CLI) . Learn how to install and master the CLI.
|
||||
- [Firmware](./firmware.md): Your Chameleon runs a firmware, learn what it can do and how to use it.
|
||||
|
||||
- ["GUIs"](./gui.md): Some people also develop **G**raphical **U**ser **I**nterfaces (GUIs), these may be a good start for people that do not want to deal with a CLI.
|
||||
### Interacting with the device
|
||||
|
||||
- ["Troubleshooting"](./troubleshooting.md): For when things go wrong, here are some common tips to maybe fix whatever issue you might have.
|
||||
- [Quickstart](./quickstart.md): For the impatient people to just get you up and running with anything.
|
||||
|
||||
- ["FAQ"](./faq.md): Frequently asked questions, if you have a question, it might already be answered here.
|
||||
- [CLI](./cli.md): The official way to control your Chameleon is via the **C**ommand **L**ine **I**nterface (CLI). Learn how to install and master the CLI.
|
||||
|
||||
- ["Quickstart"](./quickstart.md): for the impatient people to just get you up and running with anything.
|
||||
- [GUIs](./gui.md): Some people also develop **G**raphical **U**ser **I**nterfaces (GUIs), these may be a good start for people that do not want to deal with a CLI.
|
||||
|
||||
- ["Development"](./development.md): for all developers. This covers how to build firmware from source and set up a development environment.
|
||||
- [Troubleshooting](./troubleshooting.md): For when things go wrong, here are some common tips to maybe fix whatever issue you might have.
|
||||
|
||||
- ["Protocol"](./protocol.md): the gory details of the communication protocol, useful if you want to develop your own client.
|
||||
### For developers
|
||||
|
||||
- [Development](./development.md): For all developers. This covers how to build firmware from source and set up a development environment.
|
||||
|
||||
- [Protocol](./protocol.md): The gory details of the communication protocol, useful if you want to develop your own client.
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- [Modding](./modding.md): Third party moddings worth mentioning.
|
||||
|
||||
- [FAQ](./faq.md): **F**requently **A**sked **Q**uestions, if you have a question, it might already be answered here.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
## Get ChameleonUltraGUI
|
||||
|
||||
- [on Google Play](https://play.google.com/store/apps/details?id=io.chameleon.ultra) / [APK](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/apk.zip)
|
||||
- [on iOS](https://apps.apple.com/dk/app/chameleon-ultra-gui/id6462919364)
|
||||
- [on Windows](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/windows-installer.zip) ([or without installer](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/windows.zip))
|
||||
- [on Linux](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/linux.zip)
|
||||
- [on macOS](https://apps.apple.com/app/chameleon-ultra-gui/id6462919364)
|
||||
|
||||
|
||||
## How to use MFKEY32
|
||||
|
||||
- set slot to mifare classic (by uploading an empty dump)
|
||||
- enable mfkey32 for that slot (toggle in slot settings)
|
||||
- select slot and present ultra repeatedly to the reader in order to collect nonces
|
||||
- after collecting some nonces, go back into slot settings and click recover keys
|
||||
|
||||
+36
-9
@@ -32,7 +32,7 @@ Using ProxSpace to build the CLI is the easiest and most comfortable way to get
|
||||
|
||||
8. Now go into the newly created folder with `cd ChameleonUltra/software/src`
|
||||
|
||||
9. Prepare for package installation with `pacman-key --init; pacman-key --populate; pacman -S msys2-keyring --noconfirm`
|
||||
9. Prepare for package installation with `pacman-key --init; pacman-key --populate; pacman -S msys2-keyring --noconfirm; pacman-key --refresh`
|
||||
|
||||
10. Proceed by installing Ninja with `pacman -S ninja --noconfirm`
|
||||
|
||||
@@ -118,16 +118,43 @@ When in the CLI, plug in your Chameleon and connect with `hw connect`. If autode
|
||||
|
||||
### Common activities
|
||||
|
||||
- Change slot: hw slot change -s [1-8]
|
||||
- Connect to the CLI: `hw connect`
|
||||
- Change slot: `hw slot change -s [1-8]`
|
||||
|
||||
*More examples coming soon*
|
||||
|
||||
### Available Commands
|
||||
### MFKEY32v2 walk-through
|
||||
Make sure to be in the `software/` directory and run the Python CLI from there.
|
||||
|
||||
In `()` is the argument description, `[]` are possible entries for that argument (eg `[1-8]`)
|
||||
- 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`
|
||||
|
||||
| Command | Arguments | Description |
|
||||
|:----------------:|:-------------------------------------------------------------------------:|:-----------------------------------------:|
|
||||
| `hw factory_reset` | `--i-know-what-im-doing` (Make sure you really want to wipe your Chameleon) | Returns the Chameleon to factory settings |
|
||||
| | | |
|
||||
| | | |
|
||||
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:
|
||||
```
|
||||
- MF1 detection log count = 6, start download.
|
||||
- Download done (144bytes), start parse and decrypt
|
||||
- Detection log for uid [DEADBEEF]
|
||||
> Block 0 detect log decrypting...
|
||||
> Block 1 detect log decrypting...
|
||||
> Result ---------------------------
|
||||
> Block 0, A key result: ['a0a1a2a3a4a5', 'aabbccddeeff']
|
||||
> Block 1, A key result: ['010203040506']
|
||||
|
||||
```
|
||||
|
||||
- To clean the logged detection nonces: `hf detection enable -e0` then `hf detection enable -e1`
|
||||
|
||||
|
||||
|
||||
*More examples coming soon*
|
||||
|
||||
@@ -102,6 +102,11 @@ The Chameleon also shows the following LED effects:
|
||||
|
||||
The device enters sleep mode after about 5s unless it is plugged in USB or if a client is connected over BLE. You can use the buttons to wake it up again. You can also press quickly a button during the sleep animation to keep the device awake.
|
||||
|
||||
## Write Modes
|
||||
- **Normal**: Behaves like any normal card
|
||||
- **Denied**: Read-only card, send NACK to write attempts
|
||||
- **Deceive**: Accepts write commands but don't change any data (reader thinks write was successful but when reading back, nothing changed)
|
||||
- **Shadow**: Accepts writes but reverts changes when device goes to sleep (reader can read and write like a normal card but changes are kept in RAM and are lost when the chameleon goes to sleep)
|
||||
|
||||
## The SoftDevice
|
||||
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ There are multiple GUIs to control your Chameleon, two are featured in this docu
|
||||
|
||||
- [Chameleon Ultra GUI](./chameleonultragui.md) ([github](https://github.com/GameTec-live/ChameleonUltraGUI))
|
||||
|
||||
- [MTools](https://shop.mtoolstec.com/mifare-classic-tool-for-ios)
|
||||
- [MTools for iOS](https://shop.mtoolstec.com/mifare-classic-tool-for-ios)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,4 @@
|
||||
# Third party moddings
|
||||
|
||||
* [ChameleonUltra Keyring](https://www.printables.com/model/552739-chameleonultra-keyring), an extended frame for ChameleonUltra with a sturdy keyring loop.
|
||||
* [ChameleonUltra Wristband](https://www.thingiverse.com/thing:6153027), allows the user to wear the ChameleonUltra as a wristband.
|
||||
+10
-3
@@ -6,11 +6,18 @@
|
||||
|
||||
The communication with the application is not the easiest but is structured as follows:
|
||||
|
||||
`MAGIC BYTE(0x11) LRC(Magic Byte) COMMAND STATUS(0x00) DATA LRC(COMMAND + STATUS + DATA)`
|
||||

|
||||
|
||||
You build the Packet by first adding 0x11, this is the "Magic Byte" to say that there is something coming. This is followed by the LRC ([**L**ongitudinal **R**edundancy **C**heck](https://en.wikipedia.org/wiki/Longitudinal_redundancy_check)) of the "Magic Byte". Then you put in the command in [Big Endian](https://en.wikipedia.org/wiki/Endianness). Each command gets assigned a unique number (e.g. `factoryReset(1020)`), this is what you are sending to the device. Append the status, also in Big Endian. The status is always 0x00. Then you add your Data, this could be anything, for example sending the card keys when reading a block.
|
||||
- **SOF**: `1 Byte`, the "Magic Byte" represent the start of a packet, must be `0x11`.
|
||||
- **LRC1**: `1 Byte`, the LRC ([**L**ongitudinal **R**edundancy **C**heck](https://en.wikipedia.org/wiki/Longitudinal_redundancy_check)) of the `SOF`, must be `0xEF`.
|
||||
- **CMD**: `2 Bytes` in unsigned [Big Endian](https://en.wikipedia.org/wiki/Endianness) format, each command have been assigned a unique number (e.g. `factoryReset(1020)`), this is what you are sending to the device.
|
||||
- **STATUS**: `2 Bytes` in unsigned [Big Endian](https://en.wikipedia.org/wiki/Endianness) format. If the direction is from APP to hardware, the status is always `0x0000`. If the direction is from hardware to APP, the status is the result of the command.
|
||||
- **LEN**: `2 Bytes` in unsigned [Big Endian](https://en.wikipedia.org/wiki/Endianness) format, the length of the data, maximum is `512`.
|
||||
- **LRC2**: `1 Byte`, the LRC ([**L**ongitudinal **R**edundancy **C**heck](https://en.wikipedia.org/wiki/Longitudinal_redundancy_check)) of the `CMD`, `STATUS` and `LEN`.
|
||||
- **DATA**: `LEN Bytes`, the data to send or receive, maximum is `512 Bytes`. This could be anything, for example you should sending key type, block number, and the card keys when reading a block.
|
||||
- **LRC3**: `1 Byte`, the LRC ([**L**ongitudinal **R**edundancy **C**heck](https://en.wikipedia.org/wiki/Longitudinal_redundancy_check)) of the `DATA`.
|
||||
|
||||
For receiving, it is the exact same in reverse.
|
||||
The total length of the packet is `LEN + 10` Bytes. For receiving, it is the exact same format.
|
||||
|
||||
## Packet payloads
|
||||
|
||||
|
||||
+9
-12
@@ -2,20 +2,17 @@
|
||||
|
||||
Quickly get up and running with your Chameleon and no technical skill
|
||||
|
||||
1. Download GUI
|
||||
1. Download any of those applications
|
||||
|
||||
- [Playstore ](https://play.google.com/store/apps/details?id=io.chameleon.ultra)/ [APK](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/apk.zip)
|
||||
|
||||
- [Windows](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/windows-installer.zip)
|
||||
|
||||
- [Linux](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/linux.zip)
|
||||
|
||||
- [IOS](https://apps.apple.com/at/app/mtools-ble-rfid-reader/id1531345398)(MTools)
|
||||
- [ChameleonUltraGUI on Google Play](https://play.google.com/store/apps/details?id=io.chameleon.ultra) / [APK](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/apk.zip)
|
||||
- [ChameleonUltraGUI on iOS](https://apps.apple.com/dk/app/chameleon-ultra-gui/id6462919364)
|
||||
- [ChameleonUltraGUI on Windows](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/windows-installer.zip) ([or without installer](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/windows.zip))
|
||||
- [ChameleonUltraGUI on Linux](https://nightly.link/GameTec-live/ChameleonUltraGUI/workflows/buildapp/main/linux.zip)
|
||||
- [ChameleonUltraGUI on macOS](https://apps.apple.com/app/chameleon-ultra-gui/id6462919364)
|
||||
- [MTools on iOS](https://apps.apple.com/app/mtools-ble-rfid-reader/id1531345398)
|
||||
|
||||
2. Plug in or connect via Bluetooth your Chameleon
|
||||
2. Connect your Chameleon via USB or BLE
|
||||
|
||||
3. Open GUI
|
||||
3. Open application
|
||||
|
||||
4. Enjoy
|
||||
|
||||
|
||||
|
||||
+21
-2
@@ -1,12 +1,31 @@
|
||||
# Hardware
|
||||
|
||||
## Difficulties to get emulation working properly
|
||||
|
||||
Try with waking up the Chameleon by pressing a button before presenting it to the reader. Try with keeping some 2-3 cm distance to the reader.
|
||||
|
||||
## Difficulties to get the LF working properly
|
||||
|
||||
The LF antenna is on a second PCB attached to the main PCB via little screws which also serve as electric connection.
|
||||
It has reported that on some devices the electric connection is not good, some glue or resin residues mai interfere.
|
||||
It has reported that on some devices the electric connection is not good, some glue or resin residues may interfere.
|
||||
You can try to dismantle very gently the screws and PCB, clean them and put them back in place.
|
||||
Be very careful the screws have been reported to be quite fragile so be gentle with them!
|
||||
|
||||
# BLE
|
||||
|
||||
## Difficulties connecting using BLE
|
||||
|
||||
On Android make sure your location is turned, as that allows for scanning of bluetooth devices.
|
||||
|
||||
## Difficulties to use BLE
|
||||
|
||||
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.
|
||||
|
||||
Default BLE connect key(passkey) is `123456`
|
||||
|
||||
# DFU
|
||||
|
||||
## Communication issues between CLI and Chameleon
|
||||
@@ -54,5 +73,5 @@ pacman -S mingw-w64-x86_64-ninja --noconfirm
|
||||
|
||||
## InvalidException: Device unsupported cmd
|
||||
|
||||
You need to update the firmware of you Chameleon.
|
||||
You need to update the firmware of your Chameleon.
|
||||
|
||||
|
||||
@@ -233,23 +233,6 @@ data_frame_tx_t *cmd_processor_mf1_darkside_acquire(uint16_t cmd, uint16_t statu
|
||||
return data_frame_make(cmd, status, length, data);
|
||||
}
|
||||
|
||||
data_frame_tx_t *cmd_processor_detect_nested_dist(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
NestedDist nd;
|
||||
if (length == 8) {
|
||||
status = nested_distance_detect(data[1], data[0], &data[2], &nd);
|
||||
if (status == HF_TAG_OK) {
|
||||
length = sizeof(NestedDist);
|
||||
data = (uint8_t *)(&nd);
|
||||
} else {
|
||||
length = 0;
|
||||
}
|
||||
} else {
|
||||
status = STATUS_PAR_ERR;
|
||||
length = 0;
|
||||
}
|
||||
return data_frame_make(cmd, status, 0, NULL);
|
||||
}
|
||||
|
||||
data_frame_tx_t *cmd_processor_mf1_nt_distance(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
NestedDist nd;
|
||||
if (length == 8) {
|
||||
|
||||
@@ -776,7 +776,7 @@ int main(void) {
|
||||
power_management_init(); // Power management initialization
|
||||
usb_cdc_init(); // USB cdc emulation initialization
|
||||
ble_slave_init(); // Bluetooth protocol stack initialization
|
||||
|
||||
|
||||
rng_drv_and_srand_init(); // Random number generator initialization
|
||||
bsp_timer_init(); // Initialize timeout timer
|
||||
bsp_timer_start(); // Start BSP TIMER and prepare it for processing business logic
|
||||
|
||||
@@ -105,7 +105,7 @@ static ble_opt_t m_static_pin_option;
|
||||
*
|
||||
* @details This function will set up the ble connect passkey.
|
||||
*/
|
||||
void set_ble_connect_key(uint8_t* key) {
|
||||
void set_ble_connect_key(uint8_t *key) {
|
||||
static uint8_t passkey[BLE_CONNECT_KEY_LEN_MAX];
|
||||
memcpy(passkey, key, BLE_CONNECT_KEY_LEN_MAX);
|
||||
m_static_pin_option.gap_opt.passkey.p_passkey = passkey;
|
||||
@@ -442,7 +442,7 @@ static void ble_evt_handler(ble_evt_t const *p_ble_evt, void *p_context) {
|
||||
// err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
|
||||
// APP_ERROR_CHECK(err_code);
|
||||
break;
|
||||
|
||||
|
||||
case BLE_GAP_EVT_PASSKEY_DISPLAY: {
|
||||
char passkey[BLE_GAP_PASSKEY_LEN + 1];
|
||||
memcpy(passkey, p_ble_evt->evt.gap_evt.params.passkey_display.passkey, BLE_GAP_PASSKEY_LEN);
|
||||
@@ -556,8 +556,7 @@ static void advertising_init(void) {
|
||||
|
||||
/**@brief Clear bond information from persistent storage.
|
||||
*/
|
||||
void delete_bonds_all(void)
|
||||
{
|
||||
void delete_bonds_all(void) {
|
||||
ret_code_t err_code;
|
||||
|
||||
NRF_LOG_INFO("Erase bonds!");
|
||||
@@ -570,8 +569,7 @@ void delete_bonds_all(void)
|
||||
*
|
||||
* @param[in] skip Filter passed to @ref pm_peer_id_list.
|
||||
*/
|
||||
static void whitelist_set(pm_peer_id_list_skip_t skip)
|
||||
{
|
||||
static void whitelist_set(pm_peer_id_list_skip_t skip) {
|
||||
pm_peer_id_t peer_ids[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
|
||||
uint32_t peer_id_count = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
|
||||
|
||||
@@ -586,15 +584,11 @@ static void whitelist_set(pm_peer_id_list_skip_t skip)
|
||||
|
||||
/**@brief Function for starting advertising.
|
||||
*/
|
||||
void advertising_start(bool erase_bonds)
|
||||
{
|
||||
if (erase_bonds == true)
|
||||
{
|
||||
void advertising_start(bool erase_bonds) {
|
||||
if (erase_bonds == true) {
|
||||
delete_bonds_all();
|
||||
// Advertising is started by PM_EVT_PEERS_DELETE_SUCCEEDED event.
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
whitelist_set(PM_PEER_ID_LIST_SKIP_NO_ID_ADDR);
|
||||
|
||||
ret_code_t ret = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
|
||||
@@ -605,8 +599,7 @@ void advertising_start(bool erase_bonds)
|
||||
/**
|
||||
* @brief Function for stop advertising.
|
||||
*/
|
||||
void advertising_stop(void)
|
||||
{
|
||||
void advertising_stop(void) {
|
||||
sd_ble_gap_adv_stop(m_advertising.adv_handle);
|
||||
}
|
||||
|
||||
@@ -614,14 +607,12 @@ void advertising_stop(void)
|
||||
*
|
||||
* @param[in] p_evt Peer Manager event.
|
||||
*/
|
||||
static void pm_evt_handler(pm_evt_t const * p_evt)
|
||||
{
|
||||
static void pm_evt_handler(pm_evt_t const *p_evt) {
|
||||
pm_handler_on_pm_evt(p_evt);
|
||||
pm_handler_disconnect_on_sec_failure(p_evt);
|
||||
pm_handler_flash_clean(p_evt);
|
||||
|
||||
switch (p_evt->evt_id)
|
||||
{
|
||||
switch (p_evt->evt_id) {
|
||||
case PM_EVT_CONN_SEC_SUCCEEDED:
|
||||
// p_evt->peer_id;
|
||||
break;
|
||||
@@ -631,22 +622,20 @@ static void pm_evt_handler(pm_evt_t const * p_evt)
|
||||
break;
|
||||
|
||||
case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
|
||||
if ( p_evt->params.peer_data_update_succeeded.flash_changed
|
||||
&& (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING))
|
||||
{
|
||||
if (p_evt->params.peer_data_update_succeeded.flash_changed
|
||||
&& (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING)) {
|
||||
NRF_LOG_INFO("New Bond, add the peer to the whitelist if possible");
|
||||
// Note: You should check on what kind of white list policy your application should use.
|
||||
|
||||
whitelist_set(PM_PEER_ID_LIST_SKIP_NO_ID_ADDR);
|
||||
}
|
||||
break;
|
||||
case PM_EVT_CONN_SEC_CONFIG_REQ:
|
||||
{
|
||||
pm_conn_sec_config_t cfg;
|
||||
cfg.allow_repairing = true;
|
||||
pm_conn_sec_config_reply(p_evt->conn_handle, &cfg);
|
||||
}
|
||||
break;
|
||||
case PM_EVT_CONN_SEC_CONFIG_REQ: {
|
||||
pm_conn_sec_config_t cfg;
|
||||
cfg.allow_repairing = true;
|
||||
pm_conn_sec_config_reply(p_evt->conn_handle, &cfg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -654,8 +643,7 @@ static void pm_evt_handler(pm_evt_t const * p_evt)
|
||||
|
||||
/**@brief Function for the Peer Manager initialization.
|
||||
*/
|
||||
static void peer_manager_init(void)
|
||||
{
|
||||
static void peer_manager_init(void) {
|
||||
ble_gap_sec_params_t sec_param;
|
||||
ret_code_t err_code;
|
||||
|
||||
@@ -711,8 +699,8 @@ void saadc_event_handler(nrf_drv_saadc_evt_t const *p_event) {
|
||||
(err_code != NRF_ERROR_INVALID_STATE) &&
|
||||
(err_code != NRF_ERROR_RESOURCES) &&
|
||||
(err_code != NRF_ERROR_BUSY) &&
|
||||
(err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
|
||||
) {
|
||||
(err_code != NRF_ERROR_FORBIDDEN) &&
|
||||
(err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)) {
|
||||
APP_ERROR_HANDLER(err_code);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@ void advertising_stop(void);
|
||||
void delete_bonds_all(void);
|
||||
void nus_data_response(uint8_t *p_data, uint16_t length);
|
||||
bool is_nus_working(void);
|
||||
void set_ble_connect_key(uint8_t* key);
|
||||
void set_ble_connect_key(uint8_t *key);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -295,7 +295,7 @@ uint8_t nfc_tag_14a_unwrap_frame(const uint8_t *pbtFrame, const size_t szFrameBi
|
||||
* @param[in] appendCrc Whether to send the byte flow, automatically send the CRC16 verification automatically
|
||||
*/
|
||||
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_WINDOW);
|
||||
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
|
||||
@@ -316,6 +316,7 @@ void nfc_tag_14a_tx_bytes_delay_freerun(uint8_t *data, uint32_t bytes, bool appe
|
||||
*/
|
||||
#define NFC_14A_TX_BITS_CORE(bits, mode) \
|
||||
do { \
|
||||
nrf_nfct_frame_delay_max_set(65535); \
|
||||
NRF_NFCT->PACKETPTR = (uint32_t)(m_nfc_tx_buffer); \
|
||||
NRF_NFCT->TXD.AMOUNT = bits; \
|
||||
NRF_NFCT->INTENSET = (NRF_NFCT_INT_TXFRAMESTART_MASK | NRF_NFCT_INT_TXFRAMEEND_MASK); \
|
||||
@@ -332,7 +333,7 @@ void nfc_tag_14a_tx_bytes_delay_freerun(uint8_t *data, uint32_t bytes, bool appe
|
||||
void nfc_tag_14a_tx_bits(uint8_t *data, uint32_t bits) {
|
||||
m_is_responded = true;
|
||||
memcpy(m_nfc_tx_buffer, data, (bits / 8) + (bits % 8 > 0 ? 1 : 0));
|
||||
NFC_14A_TX_BITS_CORE(bits, NRF_NFCT_FRAME_DELAY_MODE_FREERUN);
|
||||
NFC_14A_TX_BITS_CORE(bits, NRF_NFCT_FRAME_DELAY_MODE_WINDOWGRID);
|
||||
}
|
||||
|
||||
/**@brief The function of sending n bits is implemented, and this implementation is automatically sent SOF
|
||||
@@ -354,7 +355,7 @@ void nfc_tag_14a_tx_nbit(uint8_t data, uint32_t bits) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -578,6 +579,30 @@ 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;
|
||||
// Reset fdt max
|
||||
nrf_nfct_frame_delay_max_set(0x00001000UL);
|
||||
}
|
||||
|
||||
extern bool g_usb_led_marquee_enable;
|
||||
|
||||
/**
|
||||
@@ -619,6 +644,8 @@ 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;
|
||||
}
|
||||
@@ -648,6 +675,7 @@ void nfc_tag_14a_event_callback(nrfx_nfct_evt_t const *p_event) {
|
||||
nfc_tag_14a_data_process(m_nfc_rx_buffer);
|
||||
// The above prompt tells us that when we do not need to reply to the card reader, we need to manually enable it
|
||||
if (!m_is_responded) {
|
||||
nfc_fdt_reset();
|
||||
NRFX_NFCT_RX_BYTES
|
||||
}
|
||||
break;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user