-
Notifications
You must be signed in to change notification settings - Fork 200
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
How to obtain a network ID for a stored network #228
Comments
Thank you for raising this issue and apologies for not seeing it earlier. I agree there should be a more direct way to retrieve the Until such a time where the ID is directly returned via Via the CLIWhen a network is added via the CLI, a configuration name can be provided. The configration name is associated with the added network, and from your application you can get the In your app, you can retrieve the network ID through the following code: const char cfg_name[] = "TEST_CFG\0";
int id = WifiConfig_GetNetworkIdByConfigName(cfg_name);
Log_Debug("ID for %s is %d", cfg_name, id); where the Via your applicationI've drafted the following function which will create add a new network with a configuration name if it does not already exist. If the configuration name does exist, the function returns the ID of the given network associated to that configuration name. int add_network_with_config_name(const char* ssid, int ssid_length, const char* config_name) {
int id = WifiConfig_GetNetworkIdByConfigName(config_name);
// return the id of the network if the configuration already exists
if (id >= 0) {
Log_Debug("Configuration with name %s exists with id %d\n", config_name, id);
return id;
}
Log_Debug("Configuration does not exist. Creating...\n");
// otherwise obtain a new network id and assign the configuration name.
id = WifiConfig_AddNetwork();
WifiConfig_SetSSID(id, (uint8_t *)ssid, ssid_length);
WifiConfig_SetConfigName(id, config_name);
Log_Debug("Added network configuration name %s and id %d\n", config_name, id);
} The function can be called from your main application as follows: int main(void) {
const char ssid[] = "GREAT_SCOTT";
const char cfg_name[] = "NEW_CFG1\0";
add_network_with_config_name(ssid, sizeof(ssid), cfg_name);
} The first time the program is run:
The second time the program is run:
|
Hi,
I used
int WifiConfig_ForgetNetwork(const WifiConfig_StoredNetwork * storedNetwork)
.This function is obsolete.
I am trying to use WifiConfig_ForgetNetworkById instead, but I cannot get the networkID from WifiConfig_StoredNetwork.
Is there any way to do that?
The text was updated successfully, but these errors were encountered: