G-Two / smoke-x-receiver

An ESP32+LoRa application to bridge a ThermoWorks Smoke X remote thermometer to Home Assistant via MQTT
MIT License
14 stars 5 forks source link

This URI does not exist #12

Closed dylanh117 closed 1 year ago

dylanh117 commented 1 year ago

First ran into an error during flash stating RuntimeError: given base directory C:/Espressif/frameworks/esp-idf-v4.4.4/smoke-x-receiver/web_ui/dist does not exist

Was able to bypass this by manually creating that directory. Flash completes successfully, but when I try to access the web UI at http://192.168.4.1/wlan, I get an error saying "This URI does not exist"

dylanh117 commented 1 year ago

This is an amazing project btw. Thanks for all of your work

G-Two commented 1 year ago

It looks like the web assets aren't being built. They are a dependency shown in lines 8-9 of CMakeLists.txt

In order for it to work, the script ./web_ui/build.sh must run successfully (which is what creates and populates the ./web_ui/dist directory. There might be an error message buried in your build output that says why/how it failed. I've never tested building in Windows, so it probably has something to do with the script being written for bash. For Windows, you'll probably need to run it in a bash or bash-like environment (WSL2, Cygwin, etc).

dylanh117 commented 1 year ago

Thanks for your help. I'm now getting the following error when running with WSL2:

C:\Espressif\frameworks\esp-idf-v4.4.4\smoke-x-receiver\web_ui>bash ./build.sh
./build.sh: line 2: $'\r': command not found
./build.sh: line 16: syntax error: unexpected end of file

Any ideas here?

dylanh117 commented 1 year ago

I also noticed that during the flash, the file build.sh will open instead of running

dylanh117 commented 1 year ago

Running dos2unix on build.sh & removing line 1 fixed the latest error

G-Two commented 1 year ago

I don't have a Windows environment to test/debug on, but my recommendation would be to start over and perform all actions from the WSL2 Ubuntu (assuming you went with the default distro) shell. Bouncing between Windows and linux environments will make it very difficult to keep dependencies and file formats in order.

Using a WSL2 Ubuntu shell, everything (for the purposes of building/flashing) should be identical to a native linux environment (i.e. if ESP-IDF and npm are installed in the WSL2 environment, everything should just work with idf.py build flash).

Alternatively, if you just want to get the device running, I've attached my contents of ./web_ui/dist in a zipfile. Normally node.js would produce these files in your environment, but since it's not working, you can just use these pre-built files.

Unzip this file to ./web_ui/: dist.zip Then try flashing again.

dylanh117 commented 1 year ago

I was able to get the device working, and am happy to close this one out.

Unfortunately I made a mistake in configuring it that I think may have corrupted the config. I applied the MQTT config without setting a MQTT URI... Right afterwards, the device dropped off the network and I haven't been able to get it to reconnect or go back into AP mode. I've tried to clear the NVRAM a few different ways but haven't had any luck. Do you want me to open a new issue on that?

G-Two commented 1 year ago

Yes, please open a new issue for the empty MQTT URI. I don't think there is a check for that, and that would probably result in a fatal error causing the device to get stuck in a boot loop.

In the meantime, you can restore your device by following the info below.

The flash partition table is specified as:

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x6000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000, 0x200000,
storage,  data, spiffs,  0x210000,0x100000,

So to clear the application NVRAM (nvs), just plug your device in and run this from your ESP-IDF environment:

$ esptool.py erase_region 0x9000 0x6000