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

'inet_addr_to_ipaddr' was not declared in this scope [SOLVED] #8

Open
wieb18 opened this issue Jan 17, 2019 · 15 comments
Open

'inet_addr_to_ipaddr' was not declared in this scope [SOLVED] #8

wieb18 opened this issue Jan 17, 2019 · 15 comments

Comments

@wieb18
Copy link

wieb18 commented Jan 17, 2019

Thanks a lot for excellent library.

It works fine on ESP32, no compiler error.

Because something wrong on my PC, I did fresh install Windows 10 and Arduino IDE 1.8.8.

But after fresh install, ESP32 Ping doesn't work anymore.

Arduino IDE Compiler error in Ping.cpp line:

inet_addr_from_ipaddr(&to.sin_addr, addr);

The error message: 'inet_addr_to_ipaddr' was not declared in this scope

It seems this error cause by broken lwip library.

ESP32 Ping use 2 separate lwip libraries (Arduino library in C:\Program Files (x86)\Arduino and ESP32 library in C:\Users\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.1\tools\sdk\include\lwip\lwip folder).

But somehow the library connection is broken and cause 'inet_addr_to_ipaddr' was not declared in this scope error

Instead using Board Manager to install ESP32 package, also tried install ESP32 package by using git, but didn't help either. Still 'inet_addr_to_ipaddr' was not declared in this scope error

How to fix this error?

Please help...

@wieb18
Copy link
Author

wieb18 commented Jan 17, 2019

Tried very dumb solution by adding these lines:

#define inet_addr_from_ipaddr 
#define inet_addr_to_ipaddr 

in Ping.cpp.

No compiler error and able upload the sketch into ESP32.

But ping doesn't work because it didn't find inet_addr_from_ipaddr and inet_addr_to_ipaddr functions.

How to fix this?

Please help...

@wieb18
Copy link
Author

wieb18 commented Jan 18, 2019

Done this steps:

1. Uninstall Arduino IDE 1.8.8
2. Delete C:\Users\AppData\Local\
3. Rename C:\Users\Documents\Arduino into C:\Users\Documents\Arduino_OLD
4. Restart the PC
5. Install Arduino IDE 1.8.8
6. Install ESP32 Core version 1.0.0 using Boards Manager

Then.... compile my sketch.

And now.... it WORKS.... :) :) :)

My previous mistake is not installing ESP32 Core version 1.0.0.

I did it by installing version 1.0.1 - the Boards Manager default version - which didn't work.

It seems some change in ESP32 Core version 1.0.1 broke ESP32 Ping library connection.

@wieb18 wieb18 changed the title 'inet_addr_to_ipaddr' was not declared in this scope 'inet_addr_to_ipaddr' was not declared in this scope [SOLVED] Jan 18, 2019
@atanisoft
Copy link

Ping.cpp does not include the header that defines this function, you can alter the library to add the following to fix this likely:

#include <lwip/inet.h>

@bill-orange
Copy link

I added #include <lwip/inet.h> to Ping.cpp.. Compilation with Core 1.0.1 resulted in the same error.

@atanisoft
Copy link

The "function" is defined in that file, additional code may be required but I don't have this library setup on my system but I do use this function in my own code without issues.

@atanisoft
Copy link

a fix for this: PotatoX@4b8688e

@bill-orange
Copy link

@atanisoft That works, thanks! I use ping to test for a live internet connection.

@dachshund-digital
Copy link

When will PotatoX fix be merged to mater? I am getting the same issue with ESP core 1.0.1 right now.

@dachshund-digital
Copy link

Found another bug, typo...

In Ping.cpp... free() call is malformed, missing ";"... throws errors on compile.

if ((err = sendto(s, iecho, ping_size, 0, (struct sockaddr*)&to, sizeof(to)))) {
	transmitted++;
}
free(iecho)
return (err ? ERR_OK : ERR_VAL);

@chillitomato
Copy link

to make this work for v1.01 just change

inet_addr_from_ipaddr to inet_addr_from_ip4addr
inet_addr_to_ipaddr to inet_addr_to_ip4addr

in file Ping.cpp in your library path

Thats it

@BojanJurca
Copy link

The solution that works for me is changing the following lines:

to.sin_addr = *(in_addr *) addr; // inet_addr_from_ipaddr (&to.sin_addr, addr);

fromaddr = *(ip4_addr_t *) &from.sin_addr; // inet_addr_to_ipaddr (&fromaddr, &from.sin_addr);

@pvint
Copy link

pvint commented Dec 4, 2019

I'm using ESP 1.0.4 and could not easily get any of the above methods to work, but I have gotten it to work using ip4addr_aton(AF_INET, &to.sin_addr, inet_addr(addr));

Please test with my fork at https://github.com/pvint/ESP32_ping and let me know if it works with your version(s)

@zyklone92
Copy link

Thanks @pvint, that totally worked for me (using ESP 1.0.4 here).
Saved me a bunch of time, much appreciated.

@pvint
Copy link

pvint commented Mar 11, 2020

Good to hear @zyklone92 (and thanks for the feedback!)
I've been running a few devices for a few months now with those changes - I'll have another look at my code tomorrow to make sure it looks clean and submit a PR. It's a great library, but it looks like it may possibly be abandoned. I foresee using this a lot for a long time... @pbecchi : Do you have plans to maintain this in the future? If so, I'm glad to help out, and if not, I'd be happy to take it over (if you so desire) or simply do some maintenance/bugfixes on my fork.

Cheers
Paul

@marian-craciunescu
Copy link

https://github.com/marian-craciunescu/ESP32Ping not abandoned input may is welcomed

sakinit added a commit to sakinit/ESPEasy that referenced this issue May 10, 2020
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

9 participants