Fixed a return of entries(). Issue #133

pull/134/head
Hieromon Ikasamo 5 years ago
parent e1b2a7acb5
commit 3dda824a0f
  1. 11
      src/AutoConnectCredential.cpp
  2. 1
      src/AutoConnectCredential.h

@ -344,6 +344,15 @@ inline bool AutoConnectCredential::del(const char* ssid) {
return _del(ssid, true); return _del(ssid, true);
} }
/**
* Refresh the number of stored credential entries.
* @retval A number of entries.
*/
inline uint8_t AutoConnectCredential::entries(void) {
_entries = _credit.size();
return _entries;
}
/** /**
* Load the credential entry for the specified SSID from the internal * Load the credential entry for the specified SSID from the internal
* dictionary. The credentials are stored to the station_config * dictionary. The credentials are stored to the station_config
@ -356,6 +365,7 @@ inline bool AutoConnectCredential::del(const char* ssid) {
int8_t AutoConnectCredential::load(const char* ssid, struct station_config* config) { int8_t AutoConnectCredential::load(const char* ssid, struct station_config* config) {
// Determine the number in entries // Determine the number in entries
int8_t en = 0; int8_t en = 0;
_entries = _import(); // Reload the saved credentials
for (decltype(_credit)::iterator it = _credit.begin(), e = _credit.end(); it != e; ++it) { for (decltype(_credit)::iterator it = _credit.begin(), e = _credit.end(); it != e; ++it) {
String key = it->first; String key = it->first;
if (!strcmp(ssid, key.c_str())) { if (!strcmp(ssid, key.c_str())) {
@ -377,6 +387,7 @@ int8_t AutoConnectCredential::load(const char* ssid, struct station_config* conf
* false The number is not available. * false The number is not available.
*/ */
bool AutoConnectCredential::load(int8_t entry, struct station_config* config) { bool AutoConnectCredential::load(int8_t entry, struct station_config* config) {
_entries = _import();
for (decltype(_credit)::iterator it = _credit.begin(), e = _credit.end(); it != e; ++it) { for (decltype(_credit)::iterator it = _credit.begin(), e = _credit.end(); it != e; ++it) {
if (!entry--) { if (!entry--) {
_obtain(it, config); _obtain(it, config);

@ -126,6 +126,7 @@ class AutoConnectCredential : public AutoConnectCredentialBase {
explicit AutoConnectCredential(uint16_t offset); explicit AutoConnectCredential(uint16_t offset);
~AutoConnectCredential(); ~AutoConnectCredential();
bool del(const char* ssid) override; bool del(const char* ssid) override;
uint8_t entries(void) override;
int8_t load(const char* ssid, struct station_config* config) override; int8_t load(const char* ssid, struct station_config* config) override;
bool load(int8_t entry, struct station_config* config) override; bool load(int8_t entry, struct station_config* config) override;
bool save(const struct station_config* config) override; bool save(const struct station_config* config) override;

Loading…
Cancel
Save