Skip to content
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

WiFi Ranger Extender / Repeater #12784

Closed
wants to merge 8 commits into from

Conversation

sillyfrog
Copy link

Description:

This provides a range extender/repeater for Tasmota. Based on the Range Extender example.

This does not work on ESP32 at this stage as support is not provided until the v2 libraries become stable and are included in Tasmota.

This still needs a driver ID allocated, and a proper page in the documentation. I wanted to start this PR to start the discussion around any other changes that maybe required.

Comments/doco to get started is provided at the top of the .ino file.

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works with Tasmota core ESP32 V.1.0.7.3
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@Jason2866
Copy link
Collaborator

There is already TasMesh what is the benefit of this solution against?

@sillyfrog
Copy link
Author

sillyfrog commented Jul 30, 2021

@Jason2866 Good question :) - first reason: I didn't realize it was a thing, I'll have to look at it more closely.

But after a quick look it appears to setup a custom network and requires an ESP32 as a gateway. This is a pure WiFi solution (that I have been using for a while now), to allow other devices (doesn't have to be Tasmota) to connect to the new AP, that's then routed to the core network.

Aside from all the code for config, it's actually not a lot of code (but it does have a bit of overhead with NAPT enabled with the libraries it uses).

As mentioned, this one also does not (yet) support ESP32 - but best I can tell once arduino-esp32 v2 is released and integrated into Tasmota, it should be easy to add.

@Jason2866
Copy link
Collaborator

Jason2866 commented Jul 30, 2021

Sorry i did by mistake edit your comment :-(
You can already build Tasmota based on Arduino ESP32 core v2 if you want. Just take a look at https://github.com/arendst/Tasmota/blob/development/platformio_tasmota_cenv_sample.ini#L70-L81 Tasmota does run already with (fairly stable).

@sillyfrog
Copy link
Author

All good.
I missed that in the sample (esp32 core v2), I'll check it out now!

@sillyfrog
Copy link
Author

@Jason2866 Thanks again for the pointer on the v2 arduino-esp32.

Do you think it's likely that this concept would be accepted into Tasmota? I'm hitting a number of walls with the ESP32 implementation, so won't continue if it's unlikely to become part of Tasmota. It looks like support in bleeding edge in Arduino - or even not included at this stage (without doing a custom build of the esp-idf library). Spent a few hours on it and I'm about to go back to basics (ie: outside Tasmota) to try and get it going for the ESP32.

Thanks!

@sillyfrog
Copy link
Author

PS: Or would it be accepted as an ESP8266 only option?

@Jason2866 Jason2866 requested a review from arendst July 31, 2021 09:54
@Jason2866
Copy link
Collaborator

I could imagine, since Berry is ESP32 only. Tagged Theo for review. We will se what he is thinking

@sillyfrog
Copy link
Author

sillyfrog commented Jul 31, 2021

Further to getting it going on ESP32 - I think we are going to need the following options in the esp32-arduino-lib:

CONFIG_LWIP_L2_TO_L3_COPY=y
CONFIG_LWIP_IP_FORWARD=y
CONFIG_LWIP_IPV4_NAPT=y

I have not tested myself yet (it's getting late here and I've been doing too much reading), but I think that'll be the solution if everyone thinks it's worth it. :)

Cheers.

Copy link
Owner

@arendst arendst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the code and as long as it stays within a single driver file it's OK with me. Considering the amount of memory used I think it won't be enabled in the current binary versions.

Also how many clients do you think an ESP8266 can handle? I suppose not many.

In the end adding another wifi router is probably a more productive solution.

@Jason2866
Copy link
Collaborator

Jason2866 commented Jul 31, 2021

Further to getting it going on ESP32 - I think we are going to need the following options in the esp32-arduino-lib:

CONFIG_LWIP_L2_TO_L3_COPY=y
CONFIG_LWIP_IP_FORWARD=y
CONFIG_LWIP_IPV4_NAPT=y

I have not tested myself yet (it's getting late here and I've been doing too much reading), but I think that'll be the solution if everyone thinks it's worth it. :)

Cheers.

I will add/change this settings

CONFIG_LWIP_L2_TO_L3_COPY=y
CONFIG_LWIP_IP_FORWARD=y
CONFIG_LWIP_IPV4_NAPT=y

in my next Tasmota Arduino Esp32 framework build

@Jason2866
Copy link
Collaborator

This are the available options:

#
# LWIP
#
CONFIG_LWIP_LOCAL_HOSTNAME="espressif"
# CONFIG_LWIP_NETIF_API is not set
CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y
CONFIG_LWIP_L2_TO_L3_COPY=y
# CONFIG_LWIP_IRAM_OPTIMIZATION is not set
CONFIG_LWIP_TIMERS_ONDEMAND=y
CONFIG_LWIP_MAX_SOCKETS=10
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
# CONFIG_LWIP_SO_LINGER is not set
CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
CONFIG_LWIP_SO_RCVBUF=y
# CONFIG_LWIP_NETBUF_RECVINFO is not set
CONFIG_LWIP_IP4_FRAG=y
CONFIG_LWIP_IP6_FRAG=y
# CONFIG_LWIP_IP4_REASSEMBLY is not set
# CONFIG_LWIP_IP6_REASSEMBLY is not set
CONFIG_LWIP_IP_FORWARD=y
# CONFIG_LWIP_STATS is not set
CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
CONFIG_LWIP_GARP_TMR_INTERVAL=60
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
# CONFIG_LWIP_DHCP_DOES_ARP_CHECK is not set
# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set
CONFIG_LWIP_DHCP_RESTORE_LAST_IP=y

I see no CONFIG_LWIP_IPV4_NAPT

@Jason2866
Copy link
Collaborator

Jason2866 commented Jul 31, 2021

@sillyfrog
Copy link
Author

Okay, i read the IDF docs and just added the option. Let us see what the lib builder does....
https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/384/framework-arduinoespressif32-master-cd287c4d6.tar.gz
to use change this line https://github.com/arendst/Tasmota/blob/development/platformio_tasmota_cenv_sample.ini#L74

Thanks! I should have mentioned I found the options by using the idf.py menuconfig command then running a diff.

@sillyfrog
Copy link
Author

I looked at the code and as long as it stays within a single driver file it's OK with me. Considering the amount of memory used I think it won't be enabled in the current binary versions.

Also how many clients do you think an ESP8266 can handle? I suppose not many.

In the end adding another wifi router is probably a more productive solution.

@arendst Thanks! I agree, I would not include this by default, but I'm trying to make it as easy to add as practical for those that do want it in their own builds.

For my use case I have a several outdoor WiFi switches (the Sonoff S55), some of which are slightly underground. To connect them to my "core" network the WiFi base-station would need to be would be very exposed to the elements, but the another S55 (on a nearby fence post basically) is working well as a low-cost outdoor bridge.

From my research so far, it's limited to about 8 clients on the ESP8266.

@sillyfrog
Copy link
Author

Thank you @Jason2866! That worked!

It all ended up far more complex than I was hoping as some of the interface/API's are significantly different to the ESP8266.

I'm have just pushed that update with ESP32 support.

Thanks again.

@arendst
Copy link
Owner

arendst commented Aug 1, 2021

Thx.

Let me play with this and do some changes in regards to correct driver number and possibly persistance.

Hold on.

Jason2866 added a commit to Jason2866/Tasmota that referenced this pull request Aug 1, 2021
@Jason2866
Copy link
Collaborator

Needed framework for this PR is #12807

arendst added a commit that referenced this pull request Aug 1, 2021
Support for wifi range extender in IDF 4.4 (needed for PR #12784)
arendst added a commit that referenced this pull request Aug 1, 2021
@arendst
Copy link
Owner

arendst commented Aug 1, 2021

Rewrote your extender to add persistence.

I'm currently unable to test NAPT as it fails to compile. I'm sure you'll find a simple solution.

Note most defines have changed to make them in line with used Tasmota defines.

Pls open a new PR for any changes you'll suggest.

@arendst arendst closed this Aug 1, 2021
@sillyfrog
Copy link
Author

Thanks! Even better getting persistent settings :)

I'll start a PR now - I'll add in some more comments about why things are as they are in case I (or someone) needs to work on it in the future.

I'll also start some formal documentation for it as well.

For now, I'm commenting out the offending lines that are preventing the ESP32 compilation - hopefully they'll be fixed shortly (by Stephen from what VScode is telling me).

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants