Add documentation to setup dev env
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		
							
								
								
									
										106
									
								
								docs/SETUP_DEV.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								docs/SETUP_DEV.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,106 @@
 | 
				
			|||||||
 | 
					# 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:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								docs/img/custom_consumption.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								docs/img/custom_consumption.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 6.6 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								docs/img/esp_mapping.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								docs/img/esp_mapping.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 66 KiB  | 
		Reference in New Issue
	
	Block a user