Skip to content

Commit

Permalink
Merge pull request #33 from Romkabouter/rewrite
Browse files Browse the repository at this point in the history
Merge rewrite into master
  • Loading branch information
Romkabouter authored Jan 13, 2021
2 parents 5ef30cb + 5a42f9e commit 2fa8e64
Show file tree
Hide file tree
Showing 26 changed files with 2,243 additions and 2,909 deletions.
915 changes: 0 additions & 915 deletions MatrixVoiceAudioServer/MatrixVoiceAudioServer.ino

This file was deleted.

210 changes: 0 additions & 210 deletions MatrixVoiceAudioServer/RingBuf.h

This file was deleted.

Binary file removed MatrixVoiceAudioServer/bootloader.bin
Binary file not shown.
15 changes: 0 additions & 15 deletions MatrixVoiceAudioServer/config.h

This file was deleted.

1 change: 0 additions & 1 deletion MatrixVoiceAudioServer/deploy_ota.sh

This file was deleted.

Binary file removed MatrixVoiceAudioServer/partitions_two_ota.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion PlatformIO/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ else
echo ""
cp .pio/build/esp32dev/firmware.bin .
cp .pio/build/esp32dev/partitions.bin .
echo "Loading firmware: $FIRMWARE"
echo "Loading firmware: $FIRMWARE to $1"
echo ""
tar cf - *.bin | ssh pi@$1 'tar xf - -C /tmp;sudo voice_esp32_reset;voice_esptool --chip esp32 --port /dev/ttyS0 --baud 1500000 --before default_reset --after hard_reset write_flash -u --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 /tmp/bootloader.bin 0x10000 /tmp/firmware.bin 0x8000 /tmp/partitions.bin'
echo "done"
Expand Down
51 changes: 32 additions & 19 deletions PlatformIO/load_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from string import Template

settings = "settings.ini"
sectionMatrix = "Matrix"
sectionGeneral = "General"
sectionWifi = "Wifi"
sectionOta = "OTA"
sectionMqtt = "MQTT"
Expand All @@ -15,31 +15,44 @@
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"] + "\\\""),
("SITEID", "\\\"" + config[sectionGeneral]["siteId"] + "\\\""),
("HOSTNAME", "\\\"" + config[sectionGeneral]["hostname"] + "\\\""),
("MQTT_IP", "\\\"" + config[sectionMqtt]["ip"] + "\\\""),
("MQTT_PORT", config[sectionMqtt]["port"]),
("MQTT_USER", "\\\"" + config[sectionMqtt]["username"] + "\\\""),
("MQTT_PASS", "\\\"" + config[sectionMqtt]["password"] + "\\\""),
("MQTT_MAX_PACKET_SIZE", config[sectionMqtt]["maxPacketSize"])
("MQTT_MAX_PACKET_SIZE", 2000),
("CONFIG_ASYNC_TCP_RUNNING_CORE", 0),
("DEVICE_TYPE", config[sectionGeneral]["device_type"])
])

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"
],
)

if (config[sectionOta]["method"] == "upload") :
env.Replace(
TARGETS="upload",
)

if (config[sectionOta]["method"] == "matrix") :
env.Replace(
UPLOAD_PROTOCOL="custom",
UPLOADCMD="sh deploy.sh " + config[sectionGeneral]["deployhost"]
)

if (config[sectionOta]["method"] == "ota") :
env.Replace(
UPLOAD_PROTOCOL="espota",
UPLOAD_PORT=config[sectionGeneral]["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")
Expand Down
20 changes: 9 additions & 11 deletions PlatformIO/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,27 @@
build_flags =
'-DFIXED_POINT=1'
'-DOUTSIDE_SPEEX=1'
'-DMODELID="alexa"' ; modelid is part of the MQTT topic
'-lnn_model_alexa_wn3'
'-Llib/esp_sr'
'-lwakenet'
'-ldl_lib'
'-lc_speech_features'


[env:esp32dev]
extra_scripts = pre:load_settings.py
platform = espressif32@1.9.0
upload_protocol = espota
platform = espressif32
upload_speed = 115200
board = esp32dev
framework = arduino
board_build.partitions = ../OTABuilder/partitions_two_ota.csv
; MatrixVoice ESP32 LAN name or IP, should match HOSTNAME in build_flags
build_flags = ${common.build_flags}
monitor_speed = 115200
monitor_filters = esp32_exception_decoder

;This is where you can add dependencies of your device.
lib_deps =
https://github.com/matrix-io/matrixio_hal_esp32.git
https://github.com/matrix-io/esp32-arduino-ota.git
https://github.com/Locoduino/RingBuffer.git
https://github.com/marvinroger/async-mqtt-client.git
https://github.com/me-no-dev/AsyncTCP.git
https://github.com/knolleary/pubsubclient.git
https://github.com/bblanchon/ArduinoJson.git
ESP Async WebServer
m5stack/M5Atom
fastled/FastLED
yveaux/AC101 @ ^0.0.1
17 changes: 12 additions & 5 deletions PlatformIO/settings.ini.example
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
[Matrix]
[General]
hostname=192.168.43.140
siteId=matrixvoice
deployhost=192.168.43.24
siteId=satellite
;supported: M5ATOMECHO=0, MATRIXVOICE=1, AUDIOKIT=2
device_type=0

[Wifi]
ssid=SSID
password=password

[OTA]
password=OTA
;supported: upload, ota, matrix
;-upload: device should be attached to computer via usb
;-ota: will use espota
;-matrix: matrix voice should be attached to a raspberry pi with matrix software.
; deployhost should be set to ip of the pi
method=upload
password=OTApassword
port=3232

[MQTT]
ip=192.168.43.54
hostname=192.168.43.54
port=1883
username=username
password=password
maxPacketSize=2000
Loading

0 comments on commit 2fa8e64

Please sign in to comment.