-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from ntrp/master
Implement external settings
- Loading branch information
Showing
5 changed files
with
98 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch | ||
settings.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Import ("env") | ||
import os.path | ||
import configparser | ||
import hashlib | ||
from string import Template | ||
|
||
settings = "settings.ini" | ||
sectionMatrix = "Matrix" | ||
sectionWifi = "Wifi" | ||
sectionOta = "OTA" | ||
sectionMqtt = "MQTT" | ||
|
||
if os.path.isfile(settings): | ||
config = configparser.RawConfigParser() | ||
config.read(settings) | ||
|
||
otaPasswordHash = hashlib.md5(config[sectionOta]['password'].encode()).hexdigest() | ||
|
||
env.Append(CPPDEFINES=[ | ||
("WIFI_SSID", "\\\"" + config[sectionWifi]["ssid"] + "\\\""), | ||
("WIFI_PASS", "\\\"" + config[sectionWifi]["password"] + "\\\""), | ||
("OTA_PASS_HASH", "\\\"" + otaPasswordHash + "\\\""), | ||
("SITEID", "\\\"" + config[sectionMatrix]["siteId"] + "\\\""), | ||
("HOSTNAME", "\\\"" + config[sectionMatrix]["hostname"] + "\\\""), | ||
("MQTT_IP", "IPAddress\(" + config[sectionMqtt]["ip"].replace(".", ",") + "\)"), | ||
("MQTT_HOST", "\\\"" + config[sectionMqtt]["hostname"] + "\\\""), | ||
("MQTT_PORT", "\\\"" + config[sectionMqtt]["port"] + "\\\""), | ||
("MQTT_USER", "\\\"" + config[sectionMqtt]["username"] + "\\\""), | ||
("MQTT_PASS", "\\\"" + config[sectionMqtt]["password"] + "\\\""), | ||
("MQTT_MAX_PACKET_SIZE", config[sectionMqtt]["maxPacketSize"]) | ||
]) | ||
|
||
env.Replace( | ||
UPLOAD_PROTOCOL="espota", | ||
UPLOAD_PORT=config[sectionMatrix]["hostname"], | ||
UPLOAD_FLAGS=[ | ||
"--port=" + config[sectionOta]["port"], | ||
"--auth=" + config[sectionOta]["password"], | ||
"--timeout=30", | ||
"--f=.pio/build/esp32dev/firmware.bin" | ||
], | ||
) | ||
else: | ||
print() | ||
print("Please copy 'settings.ini.example' to 'settings.ini' and set the correct values before building") | ||
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,40 +12,23 @@ | |
build_flags = | ||
'-DFIXED_POINT=1' | ||
'-DOUTSIDE_SPEEX=1' | ||
'-DWIFI_SSID="SSID"' ; Change to your wifi ssid | ||
'-DWIFI_PASS="password"' ; Change to your wifi password | ||
'-DHOSTNAME="192.168.43.140"' ; Should match above upload_port | ||
'-DSITEID="matrixvoice"' ; siteid is part of the MQTT topic | ||
'-DMODELID="alexa"' ; modelid is part of the MQTT topic | ||
'-DOTA_PASS_HASH="createmd5hash"' ; hashed with MD5 https://www.md5hashgenerator.com/ | ||
'-DMQTT_IP=IPAddress(192, 168, 43, 54)' ; Change to the IP of your MQTT broker | ||
'-DMQTT_HOST="192.168.43.54"' ; Change to the IP of your MQTT broker | ||
'-DMQTT_PORT=1883' ; Change to the port of your MQTT broker | ||
'-DMQTT_USER="username"' ; Change to your MQTT username | ||
'-DMQTT_PASS="password"' ; Change to your MQTT password | ||
'-DMQTT_MAX_PACKET_SIZE=2000' ; This is required, otherwise audiopackets will not be send | ||
'-lnn_model_alexa_wn3' | ||
'-Llib/esp_sr' | ||
'-lwakenet' | ||
'-ldl_lib' | ||
'-lc_speech_features' | ||
|
||
[env:esp32dev] | ||
extra_scripts = pre:load_settings.py | ||
platform = [email protected] | ||
upload_protocol = espota | ||
board = esp32dev | ||
framework = arduino | ||
board_build.partitions = ../OTABuilder/partitions_two_ota.csv | ||
; MatrixVoice ESP32 LAN name or IP, should match HOSTNAME in build_flags | ||
upload_port = '192.168.43.140' | ||
build_flags = ${common.build_flags} | ||
|
||
; MatrixVoice OTA password (auth), should match hashed password (OTA_PASS_HASH) in build_flags | ||
upload_flags = | ||
--port=3232 | ||
--auth=unhashedmd5pass | ||
--f=.pio/build/esp32dev/firmware.bin | ||
|
||
lib_deps = | ||
https://github.com/matrix-io/matrixio_hal_esp32.git | ||
https://github.com/matrix-io/esp32-arduino-ota.git | ||
|
@@ -54,4 +37,4 @@ lib_deps = | |
https://github.com/me-no-dev/AsyncTCP.git | ||
https://github.com/knolleary/pubsubclient.git | ||
https://github.com/bblanchon/ArduinoJson.git | ||
ESP Async WebServer | ||
ESP Async WebServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[Matrix] | ||
hostname=192.168.43.140 | ||
siteId=matrixvoice | ||
|
||
[Wifi] | ||
ssid=SSID | ||
password=password | ||
|
||
[OTA] | ||
password=OTA | ||
port=3232 | ||
|
||
[MQTT] | ||
ip=192.168.43.54 | ||
hostname=192.168.43.54 | ||
port=1883 | ||
username=username | ||
password=password | ||
maxPacketSize=2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters