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

WiFiSpi.config(...) problems with number of parameters #35

Open
madmetz opened this issue Sep 2, 2022 · 6 comments
Open

WiFiSpi.config(...) problems with number of parameters #35

madmetz opened this issue Sep 2, 2022 · 6 comments

Comments

@madmetz
Copy link

madmetz commented Sep 2, 2022

Hello Jiri,

After spending an entire day to find out why I can't get the ip address passed from my Mega2560 to my ESP8266 I was about to give up. But then I made a last attempt: What I found out is that the ip address is passed when I set all of the 4 parameters at once.
I.e. WifiSpi.config(local_ip) doesn't work but WifiSpi.config(local_ip, dns, gateway, subnet) works well.
I had a look at the WiFiSpi.h / WiFiSpi.cpp but I couldn't find out what goes wrong here.
Can you please have a look at this issue?

Best regards from Duesseldorf (Germany)

Michael

@JAndrassy
Copy link

you mean WiFi.config

@madmetz
Copy link
Author

madmetz commented Sep 2, 2022

No, we are talking about WiFiSpi here - I thought. ;-)
Pls look at file WiFiSpi.h
But you are right - Of course I meant ".config" and not ".begin"
Thanx anyway.

@madmetz madmetz changed the title WiFiSpi.begin(...) problems with number of parameters WiFiSpi.config(...) problems with number of parameters Sep 2, 2022
@JiriBilek
Copy link
Owner

JiriBilek commented Sep 2, 2022

Hi, I can't do any tests now. I'll be back in the middle of September.
Looking at the code I am afraid the code won't work without entering a gateway address. Precisely speaking, without specifying the gateway address, the gateway IP is set to 0.0.0.0. I can't test it, I've only looked into the sources.

Look at:

  1. library WiFiSPI, file WiFiSPI.cpp, function bool WiFiSpiClass::config(IPAddress local_ip)
  2. then app WiFiSPIESP, file WiFiSPICmdGeneral.cpp, function void WiFiSpiEspCommandProcessor::cmdSetIpConfig()
  3. then library ESP8266WiFi, file ESP8266WIFISTA.cpp, function bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress arg2, IPAddress arg3, IPAddress dns2)
  4. and finally <arduino_path>\hardware\esp8266\esp8266\tools\sdk\lwip\src\core\netif.c, function void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)

If it were so, I'd have to delete the function bool WiFiSpiClass::config(IPAddress local_ip) from the library.

@JAndrassy
Copy link

JAndrassy commented Sep 3, 2022

the Arduino's WiFiNINA and WiFi101 have the same error. the code to create the addresses is missing.
I have a PR for booth
arduino-libraries/WiFiNINA#219
arduino-libraries/WiFi101#326

@madmetz
Copy link
Author

madmetz commented Sep 4, 2022

@JiriBilek, @JAndrassy
Hi and thanx for your replies.
I had a look at all the files and functions you listed and it's exactly the same on my machine.
Then I tried to find a workaround and decided to take my own ip address as gateway and dns like this:
#ifdef IP_ADDRESS
IPAddress local_ip(IP_ADDRESS);
#ifdef DNS_ADDRESS
IPAddress dns_server(DNS_ADDRESS);
#else
IPAddress dns_server(IP_ADDRESS);
#endif
#ifdef GW_ADDRESS
IPAddress gateway(GW_ADDRESS);
#else
IPAddress gateway(IP_ADDRESS);
#endif
#ifdef SUBNET_MASK
IPAddress subnet(SUBNET_MASK);
#else // if none specified we assume the smallest network class (C)
IPAddress subnet(255, 255, 255, 0);
#endif
#endif

At least it works this way and I couldn't find any problems so far.
BTW: do you know if there is example code that makes the AVR (Mega) / ESP8266 work as a server that supports multiple sockets? The Ethernet library has a function "Ethernet.accept" which is missing in the WiFiSpi library.

@JAndrassy
Copy link

JAndrassy commented Sep 4, 2022

BTW: do you know if there is example code that makes the AVR (Mega) / ESP8266 work as a server that supports multiple sockets? The Ethernet library has a function "Ethernet.accept" which is missing in the WiFiSpi library.

my WiFiEspAT library with Jiri's ATMod firmware

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

No branches or pull requests

3 participants