Skip to content

Commit

Permalink
[beken-72xx] Fake enabling AP to fix connection issues, set default IP
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Sep 10, 2022
1 parent 83573a7 commit 9495e34
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 7 additions & 0 deletions arduino/beken-72xx/libraries/WiFi/WiFiAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions arduino/beken-72xx/libraries/WiFi/WiFiData.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ typedef struct {
void *statusLink;
rw_evt_type lastStaEvent;
rw_evt_type lastApEvent;
bool apEnabled;
} WiFiData;
11 changes: 4 additions & 7 deletions arduino/beken-72xx/libraries/WiFi/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 9495e34

Please sign in to comment.