Commit a78c0d78 authored by Stefan Hackenberg's avatar Stefan Hackenberg
Browse files

Add more tasks and task graph

parent 2ce77d65
# Science Meets Industry 2021
![Task order](./tasks/order.svg)
![Task order](./tasks/order.dot)
digraph G {
graph [fontname = "helvetica"];
node [fontname = "helvetica"];
edge [fontname = "helvetica"];
install_vscode_and_platformio [URL="install_vscode_and_platformio.md"];
clone_repository_smi21 [URL="clone_repository_smi21.md"];
compile_smi21 [URL="compile_smi21.md"];
connect_psoc6_with_rc522 [URL="connect_psoc6_with_rc522.md"];
install_platform_cypress_psoc6 [URL="install_platform_cypress_psoc6.md"];
optional_install_further_extensions [URL="optional_install_further_extensions.md"];
test_connection_psoc6_with_rc522 [URL="test_connection_psoc6_with_rc522.md"];
test_http_request [URL="test_http_request.md"];
test_wifi_connection [URL="test_wifi_connection.md"];
upload_smi21 [URL="upload_smi21.md"];
write_first_test [URL="write_first_test.md"];
read_nfc_uid [URL="read_nfc_uid.md"];
read_nfc_hashtable [URL="read_nfc_hashtable.md"];
install_platform_cypress_psoc6 -> compile_smi21;
clone_repository_smi21 -> compile_smi21;
install_vscode_and_platformio -> install_platform_cypress_psoc6;
connect_psoc6_with_rc522 -> test_connection_psoc6_with_rc522;
write_first_test -> test_connection_psoc6_with_rc522;
upload_smi21 -> write_first_test;
compile_smi21 -> upload_smi21;
write_first_test -> test_wifi_connection;
test_wifi_connection -> test_http_request;
install_vscode_and_platformio -> optional_install_further_extensions;
test_connection_psoc6_with_rc522 -> read_nfc_uid;
read_nfc_uid -> read_nfc_hashtable;
}
digraph G {
graph [bb="0,0,802.88,540",
fontname=helvetica
];
node [fontname=helvetica,
label="\N"
];
edge [fontname=helvetica];
install_vscode_and_platformio [URL="install_vscode_and_platformio.md",
height=0.5,
pos="281.89,522",
width=3.5927];
install_platform_cypress_psoc6 [URL="install_platform_cypress_psoc6.md",
height=0.5,
pos="133.89,450",
width=3.7191];
install_vscode_and_platformio -> install_platform_cypress_psoc6 [pos="e,168.63,467.43 247.19,504.59 226.48,494.79 199.99,482.26 177.83,471.78"];
optional_install_further_extensions [URL="optional_install_further_extensions.md",
height=0.5,
pos="430.89,450",
width=4.0441];
install_vscode_and_platformio -> optional_install_further_extensions [pos="e,395.66,467.55 316.82,504.59 337.59,494.83 364.15,482.35 386.41,471.9"];
clone_repository_smi21 [URL="clone_repository_smi21.md",
height=0.5,
pos="698.89,450",
width=2.8886];
compile_smi21 [URL="compile_smi21.md",
height=0.5,
pos="415.89,378",
width=1.9498];
clone_repository_smi21 -> compile_smi21 [pos="e,464.71,391.08 641.96,434.92 593.34,422.89 523.67,405.66 474.55,393.51"];
upload_smi21 [URL="upload_smi21.md",
height=0.5,
pos="415.89,306",
width=1.8234];
compile_smi21 -> upload_smi21 [pos="e,415.89,324.1 415.89,359.7 415.89,351.98 415.89,342.71 415.89,334.11"];
connect_psoc6_with_rc522 [URL="connect_psoc6_with_rc522.md",
height=0.5,
pos="186.89,234",
width=3.2497];
test_connection_psoc6_with_rc522 [URL="test_connection_psoc6_with_rc522.md",
height=0.5,
pos="186.89,162",
width=4.0982];
connect_psoc6_with_rc522 -> test_connection_psoc6_with_rc522 [pos="e,186.89,180.1 186.89,215.7 186.89,207.98 186.89,198.71 186.89,190.11"];
install_platform_cypress_psoc6 -> compile_smi21 [pos="e,367.32,391.06 194.73,433.9 242.95,421.93 309.9,405.31 357.48,393.5"];
read_nfc_uid [URL="read_nfc_uid.md",
height=0.5,
pos="186.89,90",
width=1.7151];
test_connection_psoc6_with_rc522 -> read_nfc_uid [pos="e,186.89,108.1 186.89,143.7 186.89,135.98 186.89,126.71 186.89,118.11"];
test_http_request [URL="test_http_request.md",
height=0.5,
pos="441.89,90",
width=2.1845];
test_wifi_connection [URL="test_wifi_connection.md",
height=0.5,
pos="441.89,162",
width=2.4914];
test_wifi_connection -> test_http_request [pos="e,441.89,108.1 441.89,143.7 441.89,135.98 441.89,126.71 441.89,118.11"];
write_first_test [URL="write_first_test.md",
height=0.5,
pos="415.89,234",
width=1.8776];
upload_smi21 -> write_first_test [pos="e,415.89,252.1 415.89,287.7 415.89,279.98 415.89,270.71 415.89,262.11"];
write_first_test -> test_connection_psoc6_with_rc522 [pos="e,238.83,178.88 373.35,220 338.29,209.28 288.1,193.94 248.62,181.87"];
write_first_test -> test_wifi_connection [pos="e,435.47,180.28 422.18,216.05 425.11,208.18 428.66,198.62 431.94,189.79"];
read_nfc_hashtable [URL="read_nfc_hashtable.md",
height=0.5,
pos="186.89,18",
width=2.4373];
read_nfc_uid -> read_nfc_hashtable [pos="e,186.89,36.104 186.89,71.697 186.89,63.983 186.89,54.712 186.89,46.112"];
}
# Read NFC Hashtable
## Description
Each NFC tag contains a table of snippet indices and hashes. We need to read this.
### Tag data
Each or our tags has a capability of 868 bytes data. The data is organized in blocks of 4 bytes:
| Meaning | Block | Data |
| :-- | --: | :-- |
| Metadata | 0 | `xx xx xx xx` |
| Metadata | 1 | `xx xx xx xx` |
| Metadata | 2 | `xx xx xx xx` |
| Metadata | 3 | `xx xx xx xx` |
| User data | 4 | `xx xx xx xx` |
| User data | ... | `xx xx xx xx` |
| User data | 216 | `xx xx xx xx` |
Each block can be read out using:
```c
uint8_t buffer[18];
uint8_t buffer_size = sizeof(buffer);
uint8_t status = nfc.MIFARE_Read(<BLOCK_NUMBER>, buffer, &buffer_size);
```
Note that always a buffer of 18 bytes need to be passed but only the first 4 bytes are valid.
### Hashtable
We stored SHA256 digests on the tag. Usually a SHA256 digest has 32 bytes. Due to the limited storage capacity we stored only 11 bytes of the digest.
One snipped index plus hash uses 3 blocks, i.e. 12 bytes in total:
| Block | Data |
| --: | :-- |
| 4 | `INDEX_0 HASH_0_BYTE_0 HASH_0_BYTE_1 HASH_0_BYTE_2` |
| 5 | `HASH_0_BYTE_3 HASH_0_BYTE_4 HASH_0_BYTE_5 HASH_0_BYTE_6` |
| 6 | `HASH_0_BYTE_7 HASH_0_BYTE_8 HASH_0_BYTE_9 HASH_0_BYTE_10` |
| | |
| 7 | `INDEX_1 HASH_1_BYTE_0 HASH_1_BYTE_1 HASH_1_BYTE_2` |
| 8 | `HASH_1_BYTE_3 HASH_1_BYTE_4 HASH_1_BYTE_5 HASH_1_BYTE_6` |
| 9 | `HASH_1_BYTE_7 HASH_1_BYTE_8 HASH_1_BYTE_9 HASH_1_BYTE_10` |
| | |
| | ... |
| | |
In total 64 of such index-hash-datasets are stored (i.e. 768 bytes) on each tag.
## Prerequisites
### Tasks done
- [Read NFC UID](./read_nfc_uid.md)
### State
- NFC must be initialized, i.e. `nfc.PCD_Init()` called.
- NFC UID must be read out, i.e. `nfc.PICC_ReadCardSerial()` successfully called.
## Acceptance criteria
- Index-Hash-Datasets can be read.
## References
- MFRC522 Header File: https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/mbed-mfrc522/-/blob/main/MFRC522.h
## Hints
- It might be helpful to have a function which reads one index-hash-dataset at once. E.g.:
```c
int nfc_read_index_hash_set(uint8_t block, uint8_t &index, uint8_t hash[11]);
```
- You can verify your readout by using a NFC Smartphone App, e.g. https://play.google.com/store/apps/details?id=com.wakdev.wdnfc.
# Read NFC UID
## Description
Each NFC tag as a unique identifier (UID). This can be read out.
## Prerequisites
### Tasks done
- [Test connection between PSoC6 and RC522 NFC reader](./test_connection_psoc6_with_rc522.md)
### State
- NFC must be initialized, i.e. `nfc.PCD_Init()` called.
## Steps
1. Wait for new tag:
```c
bool result = false;
while (result != true)
{
result = nfc.PICC_IsNewCardPresent();
}
```
2. Read UID:
```c
bool result = nfc.PICC_ReadCardSerial();
```
3. The UID can be accessed by `nfc.uid.uidByte` and printed e.g. with:
```c
debugprintf("Tagid: ");
debugprintfhex(nfc.uid.uidByte, nfc.uid.size);
```
## Acceptance criteria
- UID can be read out.
## References
- MFRC522 Header File: https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/mbed-mfrc522/-/blob/main/MFRC522.h
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment