How can I change the Wifi name (SSID) for Slate Plus (GL-A1300) router prgrammatically and not through the interface.
I've tried to use curl commands, and everything returns OK, but the name is not changed.
Here is the code I execute from C++
// URL of the router's settings page
std::string url = "http://" + ip + "/cgi-bin/luci/admin/network/wireless";
// Data to send in the POST request
std::string postData = "username=" + username + "&password=" + password;
// Perform login to get the session token (this step might vary depending on the router's API)
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str());
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
std::cerr << "Login failed: " << curl_easy_strerror(res) << std::endl;
curl_easy_cleanup(curl);
return;
}
// Assuming login was successful and you have a valid session
// Change the SSID
url = "http://" + ip + "/cgi-bin/luci/admin/network/wireless/change_ssid";
postData = "ssid=" + newWifiName;
// Add necessary headers (e.g., session token, if needed)
headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
// Perform the request
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
std::cerr << "Failed to change SSID: " << curl_easy_strerror(res) << std::endl;
} else {
std::cout << "SSID changed successfully." << std::endl;
}
What am I doing wrong?