network config in EEPROM (not like in google)

Guys, My project is a complete network based. I have dove and tested it fully operational. ow, I need to put the IP from serial via a config shell... I am a fan of Cisco type shell, and thus I made a way so that when someone will type "conf t" in serial, it will enter the conf mode. Then I can type my commands like "set ip" like this... Now here is the thing:

I am now using it from the code, a const value. But as I need to make it variable, user should input and save it in eeprom, I need your guide... I prefer a code block as I'm running out of time, and stuck in only here...

after the system gets a command match, "set ip" it will need to save the IP address in to the eeprom. And then it needs to display it again as a confirmation (though saved by then). Same way I will save mask, dns, gateway and the server IP

Please note: I can use saveeepromint and saveeepromlong or anything else. The IP needs to be saved in eepropm, readable and showable via serial port and also be usable by ethernet library. help me please...


This library seems like it might be useful to you:

to be honest, that came to me first and i refused as i found that saves the data permanently, and you again need to load sketch to change it.

Actually I need the ability for the user to use a serial console (putty) so user can enter them as their wish, when they need and save them.

neteeprom easens the life as next time I change the sketch, it does not need IP-MAC to input again in code. Thus once it's pre-loaded, a sticker on the board will be the thing. But what if my user change the location and network and they need the re-set of new parameter?

This item is more like a commercial type, where there must be enough flexibility for users...


You're just looking at the example sketches. The library can be used for anything you like. I didn't say it was a turnkey solution. Of course you're going to need to write some code yourself. That library is very simple and you could easily implement the same sort of thing yourself but you said you're looking for something already written so there it is.

If you're looking to have someone write some custom code for you then you should be ready to pay them for their work and the correct forum section is "Gigs and Collaborations": You can click the "report to moderator" link on your post and then ask nicely for the moderator to move this thread over to that forum section.

hey, no hard feelings... after you said, i again looked at it and then i found a way...

just that i need a way how to read a string and then put it as a byte[4] for IP. that way probs will be solved i hope...

getbytes() will hopefully help me...

nope... not that big help yet...

I need a sloution, like this: i will read the IP from serial. sub_str_IP will hold the IP as and then I need to make it as a byte [] for neteeprom's ip[4] format. tried in different way, no luck.

I can split the strings very well, and seems i'm mastering string but not BYTES!!! help plz...

split the IP address string into octets, use atoi() to convert each octet string to a byte, then add the byte to correct position in the array.

okey, so for IP part, I did this and it worked…

if (str_rx.startsWith("set ip ")) {
sub_str = str_rx.substring(7);
String sub_str2 = “”;
int dotIndex = sub_str.indexOf(’.’);
int secondDotIndex = sub_str.indexOf(’.’, dotIndex + 1);
int thirdDotIndex = sub_str.indexOf(’.’, secondDotIndex + 1);
sub_str2 = sub_str.substring(0, dotIndex);
int ip_A = sub_str2.toInt();
sub_str2 = sub_str.substring(dotIndex + 1, secondDotIndex);
int ip_B = sub_str2.toInt();
sub_str2 = sub_str.substring(secondDotIndex + 1, thirdDotIndex);
int ip_C = sub_str2.toInt();
sub_str2 = sub_str.substring(thirdDotIndex + 1); // To the end of the string
int ip_D = sub_str2.toInt();

byte mac[6] = { 0xCA, 0xFE, 0xBA, 0xBE, 0x00, 0x00 };
byte ip[4] = { ip_A, ip_B, ip_C, ip_D };
byte dns[4] = { 8, 8, 8, 8 };
byte gw[4] = { 192, 168, 1, 1 };
byte subnet[4] = { 255, 255, 255, 0 };

NetEeprom.writeManualConfig(mac, ip, dns, gw, subnet);