@@ -122,16 +122,11 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
122
122
123
123
wifi_config_t conf_current;
124
124
esp_wifi_get_config (WIFI_IF_AP, &conf_current);
125
- if (softap_config_equal (conf, conf_current)) {
126
- // DEBUGV("softap config unchanged");
127
- return true ;
125
+ if (!softap_config_equal (conf, conf_current) && esp_wifi_set_config (WIFI_IF_AP, &conf) != ESP_OK) {
126
+ return false ;
128
127
}
129
128
130
- bool ret;
131
-
132
- ret = esp_wifi_set_config (WIFI_IF_AP, &conf) == ESP_OK;
133
-
134
- return ret;
129
+ return true ;
135
130
}
136
131
137
132
@@ -149,12 +144,25 @@ bool WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress
149
144
return false ;
150
145
}
151
146
147
+ esp_wifi_start ();
148
+
152
149
tcpip_adapter_ip_info_t info;
153
150
info.ip .addr = static_cast <uint32_t >(local_ip);
154
151
info.gw .addr = static_cast <uint32_t >(gateway);
155
152
info.netmask .addr = static_cast <uint32_t >(subnet);
156
153
tcpip_adapter_dhcps_stop (TCPIP_ADAPTER_IF_AP);
157
154
if (tcpip_adapter_set_ip_info (TCPIP_ADAPTER_IF_AP, &info) == ESP_OK) {
155
+ dhcps_lease_t lease;
156
+ lease.enable = true ;
157
+ lease.start_ip .addr = static_cast <uint32_t >(local_ip) + (1 << 24 );
158
+ lease.end_ip .addr = static_cast <uint32_t >(local_ip) + (11 << 24 );
159
+
160
+ tcpip_adapter_dhcps_option (
161
+ (tcpip_adapter_option_mode_t )TCPIP_ADAPTER_OP_SET,
162
+ (tcpip_adapter_option_id_t )REQUESTED_IP_ADDRESS,
163
+ (void *)&lease, sizeof (dhcps_lease_t )
164
+ );
165
+
158
166
return tcpip_adapter_dhcps_start (TCPIP_ADAPTER_IF_AP) == ESP_OK;
159
167
}
160
168
return false ;
0 commit comments