Commit 2ce77d65 authored by Stefan Hackenberg's avatar Stefan Hackenberg
Browse files

Add more tasks

parent 4c5c051b
# Clone Repository SMI21
## Description
We've already prepared a starting point including some helper functions. This repository needs to be cloned.
## Prerequisites
### Tasks done
- [Install VSCode and PlatformIO](./install_vscode_and_platformio.md)
## Steps
1. Navigate to a folder where you want to store the project.
2. Open git bash and clone SMI21:
```sh
$ git clone https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/science-meets-industry-2021-students
```
3. Optional: Rename the folder to whatever you want.
4. Open the folder in VSCode as workspace: `"File" -> "Open Workspace"`.
5. Optional: If you want to track your work via git you can change the repository's origin:
```sh
$ git remote rename origin gitlab_hackenbs
$ git remote add origin <YOUR_REPOSITORY>
```
## Acceptance criteria
- SMI21 project is visible in sidebar and `platformio.ini` can be opened.
## References
- SMI21 repository: https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/science-meets-industry-2021-students
## Further information
- PlatformIO Project Configuration File: https://docs.platformio.org/en/latest/projectconf/index.html
## Notes
We need two additional libraries: `mbed-http` and `mbed-mfrc522`. Both needed some adjustments for PSoc6 so you will concrete gitlab links in `platformio.ini`
```ini
lib_deps =
https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/mbed-http.git
https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/mbed-mfrc522.git
```
# Compile SMI21
## Description
To see that the starting point works we need to compile it.
## Prerequisites
### Tasks done
- [Clone Repository SMI21](./clone_repository_smi21.md)
## Steps
1. Open PlatformIO sidebar.
2. Press `Build`.
## Acceptance criteria
- SMI21 project compiles without error.
## References
- SMI21 repository: https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/science-meets-industry-2021-students
## Further information
- Build options: https://docs.platformio.org/en/latest/projectconf/section_env_build.html
## Notes
During the first compilation both libraries `mbed-http` and `mbed-mfrc522` are cloned to your workspace. They can be found under `./.pio/libdeps`.
# Connect PSoc6 with RC522
## Description
We are using PSoc6 together with RC522 NFC reader. They communicate via SPI and so we need to connect them.
## Prerequisites
### Material list
- CY8CPROTO-062-4343W Prototyping Board
- RC522 NFC reader
- 7 Female-Female jumper wires
## Steps
Connect SPI:
| Meaning | PSoc6 Pin | RC522 Pin |
| :-- | :-- | :-- |
| VCC | P6 VDD | 3.3V |
| GND | GND | GND |
| CS | P9.3 | SDA |
| SCK | P9.2 | SCK |
| MOSI | P9.0 | MOSI |
| MISO | P9.1 | MSIO |
| RST | P9.4 | RST |
TODO: Fritzing image
## Acceptance criteria
- Pins connected
## References
- PSoC 6 Wi-Fi BT Prototyping Kit: https://www.cypress.com/documentation/development-kitsboards/psoc-6-wi-fi-bt-prototyping-kit-cy8cproto-062-4343w
- RFID Kit RC522: https://www.az-delivery.de/products/rfid-set
## Further information
- SPI: https://de.wikipedia.org/wiki/Serial_Peripheral_Interface
# Install Platform Cypress PSoC6
## Description
Cypress PSoC6 is not included in PlatformIO (yet). So it needs to be installed manually.
## Prerequisites
### Tasks done
- [Install VSCode and PlatformIO](./install_vscode_and_platformio.md)
- [Clone Repository SMI21](./clone_smi21_repository)
## Steps
1. Navigate to PlatformIO's core directory.
2. Navigate to the subfolder `platforms`.
3. Open git bash and clone PSoC6 platform package:
```sh
$ git clone https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/platformio-cypress_psco6 cypress_psoc6
```
## Acceptance criteria
- Cypress PSoc6 CY8CPROTO-062-4343W board file present under:
```sh
<PIO_CORE_DIR>/platforms/cypress_psoc6/boards/cy8cproto_062_4343w.json
```
- SMI21 projects compiles
## References
- PlatformIO core directory: https://docs.platformio.org/en/latest/projectconf/section_platformio.html#core-dir
- PSoC6 platform: https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/platformio-cypress_psco6
## Further information
- Creating custom develop development platforms: https://docs.platformio.org/en/latest/platforms/custom_platform_and_board.html
\ No newline at end of file
# Optional: Install further extensions
## Description
VSCode has limited power if used bare metal. It's strength lies in the tremendous amount of extensions.
For C/C++ development the following extensions are useful:
- C/C++
- C/C++ Extension Pack
- Code Spell Checker
For markdown editing the following extension is useful:
- Markdown All in One
- markdownlint
Note, that there are also many themes you can play with.
## Prerequisites
### Tasks done
- [Install VScode and PlatformIO](./install_vscode_and_platformio.md)
## Steps
1. Open `Extensions` sidebar.
2. Install useful extensions.
## Acceptance criteria
- Selected extensions installed.
## References
- VSCode extension marketplace: https://marketplace.visualstudio.com/VSCode
# Test connection between PSoC6 and RC522 NFC reader
## Description
After physically connected we need to test that the communication works properly.
## Prerequisites
### Tasks done
- [Connect PSoc6 with RC522](./connect_psoc6_with_rc522.md)
- [Write first test](./write_first_test.md)
## Steps
1. Add a new test to read out RC522's firmware version number:
1. Include MFRC522 header file:
```c
#include <MFRC522.h>
```
2. Initialize RC522:
```c
MFRC522 nfc(P9_0, P9_1, P9_2, P9_3, P9_4);
nfc.PCD_Init();
```
3. The firmware version number can be read out by the following function:
```c
uint8_t version = nfc.PCD_ReadRegister(MFRC522::VersionReg);
```
4. The firmware version must equal `0x93`.
2. Run test.
## Acceptance criteria
- Test passing.
## References
- MFRC522 Header File: https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/mbed-mfrc522/-/blob/main/MFRC522.h
# Test HTTP request
## Description
We're using HTTP GET requests to receive data from and send data to the smi-server. Let's test if it works properly.
## Prerequisites
### Tasks done
- [Test WiFi connection](./test_wifi_connection.md)
## Steps
1. Add a new test to test `hello` route.
1. Include header file:
```c
#include <http_request.h>
```
2. Create HTTP request:
```c
HttpRequest request(wifi, HTTP_GET, "http://smi-server/hello");
```
3. Send empty request:
```c
HttpResponse *response = request.send(NULL, 0);
```
4. Check status code:
```c
response->get_status_code();
```
It must equal `200`.
5. Check response with `TEST_ASSERT_EQUAL_STRING()`:
```c
response->get_body_as_string().c_str();
```
It must equal `hello`.
2. Run test.
## Acceptance criteria
- Test passing.
## References
- HTTP Request header file: https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/mbed-http/-/blob/main/src/https_request.h
- HTTP Response header file: https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/mbed-http/-/blob/main/src/http_response.h
# Test WiFi Connection
## Description
We're using WiFi to communicate between PSoC6 and the SMI-server. The connection needs to be established and tested.
## Prerequisites
### Tasks done
- [Write first test](./write_first_test.md)
## Steps
1. Add a new test to connect with SMI-server:
1. Get WiFiInterface instance:
```c
WiFiInterface wifi = WiFiInterface::get_default_instance();
```
2. Define global constants for SSID and Password:
```c
const char WIFI_SSID[] = "smi-server";
const char WIFI_PASSWORD[] = "smi21";
```
3. Connect:
```c
nsapi_error_t status = wifi->connect(WIFI_SSID, WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
```
4. `status` must equal `NSAPI_ERROR_OK`.
2. Run test.
## Acceptance criteria
- Test passing.
## References
- WiFiInterface header file: https://github.com/ARMmbed/mbed-os/blob/mbed-os-5.13/features/netsocket/WiFiInterface.h
- Mbed OS WiFi example: https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-mbed5-wifi//file/86dca48315d8/main.cpp/
# Upload SMI21
## Description
To see that the starting point works we need to upload it to the board.
## Prerequisites
### Tasks done
- [Compile SMI21](./compile_smi21.md)
## Steps
1. Open PlatformIO sidebar.
2. Press `Upload`.
## Acceptance criteria
- Terminal shows `SUCCESS`.
## References
- SMI21 repository: https://gitlab.elektrotechnik.hs-augsburg.de/hackenbs/science-meets-industry-2021-students
## Further information
- Upload options: https://docs.platformio.org/en/latest/projectconf/section_env_upload.html
# Write first test
## Description
Testing is one of the most important jobs during software development. PlatformIO already incorporates the Unity test framework and we want to use it intensively.
Let's write a first test!
## Prerequisites
### Tasks done
- [Compile SMI21](./compile_smi21.md)
- [Upload SMI21](./upload_smi21.md)
## Steps
1. Open `Explorer` sidebar.
2. Create a new folder `test` on the same level as `platformio.ini`.
3. Create a file `test.cpp` with the following content:
```c
#include <mbed.h>
#include <unity.h>
void test_a_well_known_truth(void)
{
TEST_ASSERT_EQUAL(1 == 1);
}
int main(void)
{
UNITY_BEGIN();
test_a_well_known_truth();
UNITY_END();
}
```
4. Open `PlatformIO` sidebar.
5. Press `Project Tasks -> Advanced -> Test`.
## Acceptance criteria
- Terminal shows `test/test.cpp:..:test_a_well_known_truth [PASSED]` and a final `SUCCESS`.
## Further information
- Unit Testing: https://docs.platformio.org/en/latest/plus/unit-testing.html
- Unity Test API: https://github.com/ThrowTheSwitch/Unity#unity-test-api
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