How to use static IP stored in dynamic config. #4
Replies: 2 comments 2 replies
-
It's good that you've spent some time to read the example code and know we can use
After the first call to To get the WiFiManager_RTL8720/src/WiFiManager_RTL8720.h Line 699 in 9659ee5 then You really don't need to do this after the following
See example WiFiManager_RTL8720/examples/RTL8720_WiFi/RTL8720_WiFi.ino Lines 118 to 153 in 9659ee5
This is left as an exercise for you, after the above answers. If not possible, it'll be a serious problem, and you have to post on the Arduino Forum for help. I hope I have time to deal with all the basic knowledge and coding and help every single person. |
Beta Was this translation helpful? Give feedback.
-
@khoih-prog thanks for the answer. void Setup(){
WiFiManager->begin(HOST_NAME);
String mip = myMenuItems[0].pdata;
// char item[4] = strtok(mip, "."); // this did not worked
IPAddress static_IP = str2IP(mip);
WiFiManager->setSTAStaticIPConfig(static_IP);
Serial.println("Static IP menu \r\n");
Serial.println(myMenuItems[0].pdata);
}
IPAddress str2IP(String str) {
IPAddress ret(getIpBlock(0, str), getIpBlock(1, str), getIpBlock(2, str), getIpBlock(3, str));
return ret;
}
int getIpBlock(int index, String str) {
char separator = '.';
int found = 0;
int strIndex[] = { 0, -1 };
int maxIndex = str.length() - 1;
for (int i = 0; i <= maxIndex && found <= index; i++) {
if (str.charAt(i) == separator || i == maxIndex) {
found++;
strIndex[0] = strIndex[1] + 1;
strIndex[1] = (i == maxIndex) ? i + 1 : i;
}
}
return found > index ? str.substring(strIndex[0], strIndex[1]).toInt() : 0;
} I have one more question. Is there any way to save/change the config data (one or multiple values) after the wifi connection? I want to have rest API to do that. |
Beta Was this translation helpful? Give feedback.
-
I need an example of using static IP from dynamic parameters.
Questions:
How to use dynamic parameters in code.?
At what point are the values available to use?
in the case of a static IP address, it will be required at the wifi connection time. How to use dynamic parameter from config form to assign it to
WiFiManager->setSTAStaticIPConfig(static_ip);
?@khoih-prog Please help
Beta Was this translation helpful? Give feedback.
All reactions