in a larger project, there is one problem left.
I like to implement a function to convert an object of the class IPAddress to a array of char.
I use a NodeMCU 1.0 and Arduino 1.8.10.
Following is a little sample sketch demonstrating what i'm trying to do:
conversion from 'IPAddress' to 'uint8_t* {aka unsigned char*}' is ambiguous
I have tried some different ways to pass the IPAddress to the function, but all result to different errors.
By now i do it "by hand" writing directly to the octets, witch are accessible like a array of four int, but i have to do it for a view different conversions and there for a universal function would be much better.
This looks like the following and work so far.
Thanks Juraj!
I know it's a printable class, but i want to use the array in other parts of my program and to say it before someone tell me to do so, i don't want to use the IP as a String objekt - i really need it as an array.
Lena:
Thanks Juraj!
I know it's a printable class, but i want to use the array in other parts of my program and to say it before someone tell me to do so, i don't want to use the IP as a String objekt - i really need it as an array.
Hey gfvalvo,
this is not what i'm looking for.
As you can see in the function in my first post, i need to modyfy the objekt IPAddress.
This objekt can behave like an array of char or uint8, im not shure, but i can not pass it's pointer to a function and that's what i'm looking for. No String conversion, no printing and i don't want to use any String objekts - the hole project only uses one large buffer and a view small c-strings for all file handling, display drawing and webpage generation.
So please stay focused to the main problem, passing a pointer to the IPAddress object.
For me it seems like the object has several representations for the data and that's why this way of conversion is ambiguous. But how can i specify witch representation i like to use?
Looks like i have another bug in my program.
I have tried the test sketch on another board and it seems to work fine - i really have to learn more about poitners, references and dereferencing
Thank you very much Juraj!
In my main project i get the error
'IPAddress' has not been declared
wich i don't understand, because they are declared global and used all over the program - strange.
But i think i will figure it out by myself.
Lena:
Looks like i have another bug in my program.
I have tried the test sketch on another board and it seems to work fine - i really have to learn more about poitners, references and dereferencing
Thank you very much Juraj!
In my main project i get the errorwich i don't understand, because they are declared global and used all over the program - strange.
But i think i will figure it out by myself.
Best regards
Lena
IPAddress is in core, but it is not included in Arduino.h
the networking libraries include it
so if you use it in a utility h or cpp file, which doesn't include the networking library header, include IPAddress.h
Very interesting!
If i split the test sketch like the main program in several tabs, i get the same error.
the tabs are called sketchname, 01_globals and 02_code.
This has worked all the time, but in this case...?
Any suggestions?
Juraj:
the first is always the sketch with the same name as the project folder
and why not use ip.fromString(test_s);?
because test_s is a c-string and not an Arduino String object.
What i don't understand is the fakt, that i can redeclare the IPAddress objekt in the 02_code tab, wich have to throw an redeclaration error, but i get the same error.
I have tried to include IPAddress.h in both tabs without any change.
Did you bother to look at the code I posted? It uses c-string, not String class. 'fromString()' has overloads for both. You just need to expend the effort and look in 'IPAddress.h':