MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / addCredential

Method addCredential

src/WifiCredentialStore.cpp:104–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104bool WifiCredentialStore::addCredential(const std::string& ssid, const std::string& password) {
105 // Check if this SSID already exists and update it
106 const auto cred = find_if(credentials.begin(), credentials.end(),
107 [&ssid](const WifiCredential& cred) { return cred.ssid == ssid; });
108 if (cred != credentials.end()) {
109 cred->password = password;
110 LOG_DBG("WCS", "Updated credentials for: %s", ssid.c_str());
111 return saveToFile();
112 }
113
114 // Check if we've reached the limit
115 if (credentials.size() >= MAX_NETWORKS) {
116 LOG_DBG("WCS", "Cannot add more networks, limit of %zu reached", MAX_NETWORKS);
117 return false;
118 }
119
120 // Add new credential
121 credentials.push_back({ssid, password});
122 LOG_DBG("WCS", "Added credentials for: %s", ssid.c_str());
123 return saveToFile();
124}
125
126bool WifiCredentialStore::removeCredential(const std::string& ssid) {
127 const auto cred = find_if(credentials.begin(), credentials.end(),

Callers 2

handlePostWifiNetworkMethod · 0.80
loopMethod · 0.80

Calls 4

endMethod · 0.80
push_backMethod · 0.80
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected