[beken-72xx] Fake enabling AP to fix connection issues, set default IP

This commit is contained in:
Kuba Szczodrzyński
2022-09-10 16:44:45 +02:00
parent 83573a743b
commit 9495e3418c
3 changed files with 12 additions and 7 deletions

View File

@@ -27,6 +27,13 @@ bool WiFiClass::softAP(const char *ssid, const char *passphrase, int channel, bo
LT_IM(WIFI, "Creating SoftAP %s", ssid);
if (!AP_CFG->local_ip_addr[0]) {
LT_DM(WIFI, "Setting default IP config");
softAPConfig((uint32_t)0, (uint32_t)0, (uint32_t)0);
}
LT_DM(WIFI, "Static IP: %s / %s / %s", AP_CFG->local_ip_addr, AP_CFG->net_mask, AP_CFG->gateway_ip_addr);
__wrap_bk_printf_disable();
OSStatus ret = bk_wlan_start_ap_adv(AP_CFG);
__wrap_bk_printf_enable();

View File

@@ -21,4 +21,5 @@ typedef struct {
void *statusLink;
rw_evt_type lastStaEvent;
rw_evt_type lastApEvent;
bool apEnabled;
} WiFiData;

View File

@@ -44,16 +44,13 @@ bool WiFiClass::modePriv(WiFiMode mode, WiFiModeAction sta, WiFiModeAction ap) {
if (ap == WLMODE_ENABLE) {
LT_DM(WIFI, "Enabling AP");
bk_wlan_ap_init(NULL);
#if CFG_WPA_CTRL_IFACE
wlan_ap_enable();
wlan_ap_reload();
uap_ip_down();
#endif
// fake it - on BK7231, enabling the AP without starting it breaks all connection attempts
data.apEnabled = true;
wifiEventSendArduino(ARDUINO_EVENT_WIFI_AP_START);
} else if (ap == WLMODE_DISABLE) {
LT_DM(WIFI, "Disabling AP");
bk_wlan_stop(BK_SOFT_AP);
data.apEnabled = false;
wifiEventSendArduino(ARDUINO_EVENT_WIFI_AP_STOP);
}
@@ -71,7 +68,7 @@ bool WiFiClass::modePriv(WiFiMode mode, WiFiModeAction sta, WiFiModeAction ap) {
WiFiMode WiFiClass::getMode() {
uint8_t sta = !!bk_wlan_has_role(VIF_STA) * WIFI_MODE_STA;
uint8_t ap = !!bk_wlan_has_role(VIF_AP) * WIFI_MODE_AP;
uint8_t ap = data.apEnabled * WIFI_MODE_AP; // report the faked value
return (WiFiMode)(sta | ap);
}