SolarEnergy/docs/SETUP_DEV.md

106 lines
2.5 KiB
Markdown
Raw Normal View History

2024-10-14 21:07:06 +00:00
# Setup development environment
## Backend
To build the backend, you will need to install:
* Rust: https://www.rust-lang.org/
* An IDE with Rust support. I would definitly recommend [RustRover](https://www.jetbrains.com/rust/) (the tool from IntelliJ).
Check if your environment is working using the following command:
```bash
cargo fmt && cargo clippy && cargo run -- --help
```
For development, the following flags might prove being useful:
* `--unsecure-disable-login`: Disable authentication on all web API endpoints
* `--hostname`: Change public server hostname, if you want to expose your test instance to network device, such as an ESP32
## Custom consumption
Same requirements as for the backend. This tool spawns a gui that allows to set arbitrary consumption values:
![Custom consumption](img/custom_consumption.png)
To use it, first launch this tool:
```bash
cd custom_consumption
cargo run
```
Set a custom value to force file creation (in the UI).
Then launch central backend (in another terminal):
```bash
cd central_backend
cargo fmt && cargo clippy && RUST_LOG=debug cargo run -- file
```
## Central frontend
The frontend has been built using [NodeJS](https://nodejs.org/en), [Vite](https://vite.dev/) and [MUI](https://mui.com/).
Launch it using this command:
```bash
cd central_frontend
npm run dev
```
## Python device
This component has been built using ... Python. Waw!
You will need to install this dependency, first:
```bash
apt install python3-jwt
```
Run the client:
```bash
cd python_device
python3 -m src.main
# Get CLI help
python3 -m src.main --help
```
Reformat code:
```bash
black src/*.py
```
## ESP32 device
The ESP32 device is in reality a [Wt32-Eth01](https://en.wireless-tag.com/product-item-2.html) device. Use the following mapping to setup dev env:
![ESP mapping](img/esp_mapping.png)
You can use a [CP2102](https://fr.aliexpress.com/item/4000120687489.html) to flash the ESP32.
I recommend to use VSCode with the following extensions:
* [ESP-IDF](https://marketplace.visualstudio.com/items?itemName=espressif.esp-idf-extension)
* [C/C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)
* [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
To build the project, use this command (in an ESP-IDF terminal):
```bash
idf.py build
```
To flash the ESP32, use this one:
```bash
idf.py flash
```
To capture logs from device, use either `cu` or the following command:
```
idf.py monitor
```