Skip to content

Commit

Permalink
feat(rust-training-esp32c3): fetch examples (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioGasquez authored Nov 10, 2023
1 parent 28a25f3 commit 372d44d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
18 changes: 12 additions & 6 deletions rust-training-esp32c3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FROM espressif/rust-std-training
USER esp
ENV USER=esp

RUN git clone https://github.com/ferrous-systems/espressif-trainings.git espressif-trainings \
&& rm -rf espressif-trainings/book
RUN git clone https://github.com/esp-rs/std-training.git std-training \
&& rm -rf std-training/book

ENV IDF_TOOLS_PATH=/home/esp/.espressif
RUN echo "source /home/esp/.espressif/frameworks/esp-idf/export.sh > /dev/null 2>&1" >> ~/.bashrc
Expand All @@ -14,15 +14,21 @@ ENV PATH=${PATH}:/home/esp/.cargo/bin
COPY sdkconfig.defaults /home/esp/
COPY cfg.toml /home/esp/
COPY compile.sh /home/esp/
COPY fetch.sh /home/esp/

RUN mkdir -p /home/esp/build-in /home/esp/build-out

RUN WOKWI_MCU=esp32-c3 ./fetch.sh advanced/button-interrupt
RUN WOKWI_MCU=esp32-c3 ./fetch.sh advanced/i2c-driver
RUN WOKWI_MCU=esp32-c3 ./fetch.sh advanced/i2c-sensor-reading
RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/hardware-check
RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/http-client
RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/http-server
RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/mqtt/exercise


ENV HEXI_SRC_DIR="/home/esp/build-in"
ENV HEXI_SRC_FILES="*.rs"
ENV HEXI_BUILD_CMD="bash /home/esp/compile.sh"
ENV HEXI_OUT_HEX="/home/esp/build-out/project.bin"
ENV HEXI_OUT_ELF="/home/esp/build-out/project.elf"

EXPOSE 8080
COPY --from=wokwi/mini-hexi /wokwi-hexi /wokwi-hexi
CMD /wokwi-hexi
21 changes: 21 additions & 0 deletions rust-training-esp32c3/fetch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -ef

echo "Compiling $1"

cd /home/esp/std-training/$1

if [ -f cfg.toml.example ]; then
# Rename file to cfg.toml
cp cfg.toml.example cfg.toml
# Replace defaults
sed -i 's/wifi_ssid = "FBI Surveillance Van"/wifi_ssid = "Wokwi-GUEST"/g' cfg.toml
sed -i 's/wifi_psk = "hunter2"/wifi_psk = ""/g' cfg.toml
sed -i 's/mqtt_user = "horse"/mqtt_user = "user"/g' cfg.toml
sed -i 's/mqtt_pass = "CorrectHorseBatteryStaple"/mqtt_pass = "pass"/g' cfg.toml
sed -i 's/mqtt_host = "yourpc.local"/mqtt_host = "host"/g' cfg.toml
fi

$HOME/.cargo/bin/cargo clean
$HOME/.cargo/bin/cargo build --release

0 comments on commit 372d44d

Please sign in to comment.