|
1 | 1 | # Access Front Door
|
2 | 2 |
|
3 |
| -This is the code required for opening the front door latch. |
| 3 | +This is the code required for opening the front door latch. |
| 4 | + |
| 5 | + |
| 6 | +## Flashing ESP32 |
| 7 | + |
| 8 | +```bash |
| 9 | +pip install esptool |
| 10 | + |
| 11 | +# Find the serial port of the connected ESP32 |
| 12 | +esptool.py flash_id |
| 13 | + |
| 14 | +# Wipe the chip |
| 15 | +esptool.py --port [serial_port] erase_flash |
| 16 | + |
| 17 | +# Download the latest firmware from https://micropython.org/download/ESP32_GENERIC/ |
| 18 | +# Install the firmware |
| 19 | +esptool.py --chip esp32 --port [serial_port] --baud 460800 write_flash -z 0x1000 [path_to_downloaded_bin_file] |
| 20 | +``` |
| 21 | + |
| 22 | + |
| 23 | +## Setting up environment variables |
| 24 | + |
| 25 | +1. Clone this repository |
| 26 | + ```sh |
| 27 | + git clone [email protected]:FarsetLabs/gate-network.git |
| 28 | + cd gate-network |
| 29 | + ``` |
| 30 | +1. Create the environment file |
| 31 | + ```sh |
| 32 | + cp ./access-front-door/src/env.example.py ./access-front-door/src/env.py |
| 33 | + ``` |
| 34 | +1. Set `WIFI_SSID` and `WIFI_PASSWORD` to your wifi ssid and password |
| 35 | +1. Update any other variables |
| 36 | + |
| 37 | + |
| 38 | +## Micropython type hints in VSCode |
| 39 | + |
| 40 | +### Install these extensions: |
| 41 | +* https://marketplace.visualstudio.com/items?itemName=ms-python.python |
| 42 | +* https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance |
| 43 | + |
| 44 | + |
| 45 | +### Setup virtualenv and install stubs |
| 46 | +```bash |
| 47 | +# setup virtualenv |
| 48 | +python3 -m venv .venv |
| 49 | + |
| 50 | +# activate virtualenv |
| 51 | +source ./.venv/bin/activate |
| 52 | + |
| 53 | +# install micropython stubs |
| 54 | +pip3 install -U micropython-esp32-stubs |
| 55 | + |
| 56 | +# install mpremote (optional, lets you connect via command line) |
| 57 | +pip3 install -U mpremote |
| 58 | +``` |
| 59 | + |
| 60 | +### Configure vscode |
| 61 | +`.vscode/settings.json` |
| 62 | +```json |
| 63 | +{ |
| 64 | + "python.languageServer": "Pylance", |
| 65 | + "python.analysis.typeCheckingMode": "basic", |
| 66 | + "python.analysis.diagnosticSeverityOverrides": { |
| 67 | + "reportMissingModuleSource": "none" |
| 68 | + }, |
| 69 | + "python.analysis.typeshedPaths": [ |
| 70 | + // Replace <python_version> with whatever the folder name is in .venv/lib/ |
| 71 | + ".venv/lib/<python_version>/site-packages", |
| 72 | + ], |
| 73 | + "python.analysis.extraPaths": [ |
| 74 | + // Allow importing from lib/ |
| 75 | + "access-front-door/src/lib", |
| 76 | + ], |
| 77 | + "pylint.args": [ |
| 78 | + // Fixes imports |
| 79 | + "--init-hook 'import sys; sys.path.append(\".\")'", |
| 80 | + ], |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | + |
| 85 | +### Copy code to device via command line (requires mpremote) |
| 86 | +```bash |
| 87 | +# make sure you are in the access-front-door directory |
| 88 | +cd access-front-door |
| 89 | + |
| 90 | +# list connected devices |
| 91 | +./run.sh |
| 92 | + |
| 93 | +# copy code and run main.py on device |
| 94 | +./run.sh [device_id] |
| 95 | +``` |
0 commit comments