diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index a078a1c..936cc87 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -2,8 +2,8 @@ * AutoConnect class implementation. * @file AutoConnect.cpp * @author hieromon@gmail.com - * @version 1.1.5 - * @date 2020-04-15 + * @version 1.2.0 + * @date 2020-04-22 * @copyright MIT license. */ @@ -746,6 +746,15 @@ bool AutoConnect::_loadAvailCredential(const char* ssid, const AC_PRINCIPLE_t pr return false; } +/** + * Get current AutoConnectCredential size + * @return Size of the AutoConnectCredential + */ +uint16_t AutoConnect::getCredentialSize(void) { + AutoConnectCredential credentials(_apConfig.boundaryOffset); + return credentials.dataSize(); +} + /** * Disconnect from the AP and stop the AutoConnect portal. * Stops DNS server and flush tcp sending. diff --git a/src/AutoConnect.h b/src/AutoConnect.h index a483087..671802a 100644 --- a/src/AutoConnect.h +++ b/src/AutoConnect.h @@ -2,8 +2,8 @@ * Declaration of AutoConnect class and accompanying AutoConnectConfig class. * @file AutoConnect.h * @author hieromon@gmail.com - * @version 1.1.5 - * @date 2020-04-01 + * @version 1.2.0 + * @date 2020-04-22 * @copyright MIT license. */ @@ -252,6 +252,7 @@ class AutoConnect { String where(void) const { return _auxUri; } inline void enableMenu(const uint16_t items) { _apConfig.menuItems |= items; } inline void disableMenu(const uint16_t items) { _apConfig.menuItems &= (0xffff ^ items); } + uint16_t getCredentialSize(void); /** For AutoConnectAux described in JSON */ #ifdef AUTOCONNECT_USE_JSON diff --git a/src/AutoConnectCredential.h b/src/AutoConnectCredential.h index 1a22fc9..3e33de0 100644 --- a/src/AutoConnectCredential.h +++ b/src/AutoConnectCredential.h @@ -2,8 +2,8 @@ * Declaration of AutoConnectCredential class. * @file AutoConnectCredential.h * @author hieromon@gmail.com - * @version 1.1.0 - * @date 2019-10-07 + * @version 1.2.0 + * @date 2020-04-22 * @copyright MIT license. */ @@ -78,7 +78,8 @@ class AutoConnectCredentialBase { public: explicit AutoConnectCredentialBase() : _entries(0), _containSize(0) {} virtual ~AutoConnectCredentialBase() {} - virtual uint8_t entries(void) { return _entries; } + virtual uint8_t entries(void) const { return _entries; } + virtual uint16_t dataSize(void) const { return sizeof(AC_IDENTIFIER) - 1 + sizeof(uint8_t) + sizeof(uint16_t) + _containSize; } virtual bool del(const char* ssid) = 0; virtual int8_t load(const char* ssid, station_config_t* config) = 0; virtual bool load(int8_t entry, station_config_t* config) = 0;