Change station_config_dhcp enum

pull/137/head
Hieromon Ikasamo 5 years ago
parent d2a076249e
commit cb2a8f4972
  1. 2
      examples/Credential/Credential.ino
  2. 13
      examples/CreditMigrate/CreditMigrate.ino
  3. 4
      src/AutoConnectCredential.h

@ -103,7 +103,7 @@ PageBuilder delPage("/del", { elmDel });
// with the <li> tag.
String viewCredential(PageArgument& args) {
AutoConnectCredential ac(CREDENTIAL_OFFSET);
struct station_config entry;
station_config_t entry;
String content = "";
uint8_t count = ac.entries(); // Get number of entries.

@ -75,7 +75,7 @@ void convert(const uint8_t* eeprom, const size_t size) {
break;
// Obtain each entry and store to Preferences
struct station_config config;
station_config_t config;
Serial.printf("[%d] ", ec);
uint8_t ei = 0;
do {
@ -91,6 +91,17 @@ void convert(const uint8_t* eeprom, const size_t size) {
config.bssid[ei] = *dp++;
Serial.printf(":%02x", config.bssid[ei]);
}
config.dhcp = *dp++;
if (config.dhcp == STA_STATIC) {
for (uint8_t e = 0; e < sizeof(station_config_t::_config::addr) / sizeof(uint32_t); e++) {
uint32_t* ip = &config.config.addr[e];
*ip = 0;
for (uint8_t b = 0; b < sizeof(uint32_t); b++) {
*ip <<= 8;
*ip += *dp++;
}
}
}
bool rc = credential.save(&config);
Serial.println(rc ? " transferred" : " failed to save Preferences");
}

@ -53,7 +53,7 @@ extern "C" {
#endif
typedef enum {
STA_DHCP,
STA_DHCP = 0,
STA_STATIC
} station_config_dhcp;
@ -61,7 +61,7 @@ typedef struct {
uint8_t ssid[32];
uint8_t password[64];
uint8_t bssid[6];
uint8_t dhcp; /**< 1:DHCP, 2:Static IP */
uint8_t dhcp; /**< 0:DHCP, 1:Static IP */
union _config {
uint32_t addr[5];
struct _sta {

Loading…
Cancel
Save