-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ESP32_S2_MINI, improve device support flexibility, improve debug logging and fix web control interface. #248
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love the idea of displaying board info, had some thoughts about alternative ways to achieve that!
|
||
# Allow the name of the binary to be reported by the webapp | ||
env.Append(CPPDEFINES=[ | ||
("PIO_BINARY", binary_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think PIO_BINARY would be set for someone who compiles the sketch in the Arduino IDE, right? I mean, the clue is in the name 😄
I'm not a maintainer on this project, just an interested bystander - but instead of displaying a filename (which can change in future updates if someone decides to change the naming structure), WDYT about just showing the board info? It looks like the preprocessor gets a couple of helpful defines at compile time - here's what's generated when compiling in the IDE for my D1 Mini :
"-DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\""
"-DARDUINO_BOARD_ID=\"d1_mini_clone\""
I got this by enabling verbose compile output in the Arduino IDE. It looks like these are set in platformio builds as well? Grepping for ARDUINO_BOARD_ID
in my Arduino libraries folder looks promising:
❯ rg ARDUINO_BOARD_ID
packages/esp8266/hardware/esp8266/3.1.1/libraries/ESP8266mDNS/src/LEAmDNS.cpp
35:#ifndef ARDUINO_BOARD_ID
36:#define ARDUINO_BOARD_ID "generic"
1275: || (!addServiceTxt(hService, "board", ARDUINO_BOARD_ID))
packages/esp8266/hardware/esp8266/3.1.1/platform.txt
131:recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -D{build.sdk}=1 -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DA>
134:recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -D{build.sdk}=1 -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_leve>
137:recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -D{build.sdk}=1 -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DA>
packages/esp8266/hardware/esp8266/3.1.1/tools/platformio-build.py
130: ("ARDUINO_BOARD_ID", '\\"%s\\"' % env.BoardConfig().id),
I feel like displaying the board info would meet the need of "remind me what piece of hardware this is" without requiring any build hacking or prebuild scripts. I do think it's a great idea to display board info in the UI!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting, I had no idea it was even possible to build this in Arduino ide (I've never used that before).
I did see those defines when I had verbose build enabled myself, but personally I didn't think they gave enough info, doesn't show which build profile was actually used etc.
Best of both however would be to use the PIO define if it exists, else the C code could fallback to the Arduino define.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, doing both makes sense to me! seems like they could just be on separate lines. there’s plenty of room on that page.
filename: PIO_BINARY
| (not set)
target: ARDUINO_BOARD
| (not set)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting, I had no idea it was even possible to build this in Arduino ide (I've never used that before).
it does seem like I need to get hip to using PlatformIO…I’m a total dabbler in the embedded world 🤣
45dd9f7
to
4476cea
Compare
I've spent some time today fixing the web control interface, I had found on an older unit as well as this S2 based one that many commands from the web control page just didn't seem to stick, or ended up selecting the wrong thing. settings updates in change_states() were failing as the String.c_str() values go out of scope too quickly. The control web page now auto-refreshes when settings changes are received from the hvac unit, either from external changes, mqtt changes or just delayed responses to web changes. This should also fix #182 |
4476cea
to
47cd6b0
Compare
ps. For anyone who wants to build this project without needing to install / configure PlatformIO I've got it building and flashing my esp32 board in docker with this little bash script:
|
My S2 MINI build is bow installed in a HVAC unit and needed a couple of extra fixes, these are now included in this branch. |
... But looking at the CI here, it appears some of my debug logging changes don't work on 8266, I'll have to look into that. |
47cd6b0
to
ce42e89
Compare
ce42e89
to
43cf436
Compare
cc817ae
to
276db8b
Compare
settings updates in change_states() were failing as the String.c_str() values go out of scope too quickly. The scope of changes is now more tightly controlled. More details are also logged if debug logging is enabled. The control web page now auto-refreshes when settings changes are received from the hvac unit, either from external changes, mqtt changes or just delayed responses to web changes.
276db8b
to
64681ad
Compare
Ok all the compatibility issues have been resolved, this change set should now work well on all platforms. It's been tested and is in active use on two HVAC units, running the esp32 and esp32s2 builds. |
This MR contains a whole bunch of changes in separate commits, let me know if you'd prefer them split out into separate MR's.
This all started when I wanted to upgrade an older unit I had running and it took me a while to remember what hardware I used. I thought it'd be handy to show the correct / expected build on the firmware upgrade page, eg.
I then wanted to test my changes on a separate esp32 module rather than the one tucked up in my aircon, but the only one I had handy was a newer esp32-s2, so I added support for that.
The default
Serial
object on the S3 is the internal USB port, not a uart. So I added support for specifying the desired UART via:build_flags = -DHVAC_UART=0
Finally I was having some more issues so wanted serial logging; now that hvac can be configured to run on a separate uart, I decided to make debug logging automatically enabled if HVAC is on a different uart to the default Serial output.