Setting up a macvlan in docker has an irritating fact that the host cannot be reached from the container and the host itself cannot reach the container.
Most people propose to add a second macvlan to the ethernet interface to allow routing between docker container and host. The drawback is, that this setup involves manual work for the container user.
I think I came up with an elegant solution (at least for me) to solve this;
a) add a second (default bridge) network to the container (see A & B) b) add a routing rule inside the container to route trafic to the host via this second interface -> allow container to host traffic (see C) c) As usual, expose ports on this default interface -> allows host to container traffic
Benefits: - Can be configured completely inside a container (i.e. startup script) and with a docker compse file ==> easy for users!
Example / proof of concept for a host at 192.168.0.22 hosting a docker container:
A) docker-compose with a macvlan network at 192.168.0.28: B) The resulting network configurationC) Non reachable host and ip-route setting in the container to reach host again
This was a short proof of concept to use the IO_MUX capability of the ESP32 to change online the PINs used for the I2C communication. Basically, the I2C hardware module can be connected to nearly every pin ofd the ESP32 and this switch can be done on the fly. I was not sure how good this work but a fast breadboard build and software sketch showed that it works like charme! See the picture and the code snippet below. Combining this with this nice hack to use only one SCL or SDA for multiple devices (link), this could be even more advantagous in several cases and save costs/space for an I2C multiplexer!
thanks for following #Long Range Weather Station (65€)