Skip to content

Commit

Permalink
Switch to bk_wlan_start_sta_adv for specific bssid control.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cossid committed Nov 18, 2023
1 parent 9b8e00c commit 09050a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cores/beken-72xx/arduino/libraries/WiFi/WiFiPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extern void wifiEventHandler(rw_evt_type event);
#define IP_FMT "%u.%u.%u.%u"

typedef struct {
network_InitTypeDef_st configSta;
network_InitTypeDef_adv_st configSta;
network_InitTypeDef_ap_st configAp;
unsigned long scannedAt;
SemaphoreHandle_t scanSem;
Expand All @@ -72,7 +72,7 @@ typedef struct {
#define pDATA ((WiFiData *)pWiFi->data)
#define cDATA ((WiFiData *)cls->data)

#define STA_CFG (DATA->configSta)
#define STA_CFG (DATA->configSta)
#define AP_CFG (DATA->configAp)
#define IP_STATUS (DATA->statusIp)
#define LINK_STATUS (DATA->statusLink)
Expand Down
25 changes: 14 additions & 11 deletions cores/beken-72xx/arduino/libraries/WiFi/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ WiFiClass::begin(const char *ssid, const char *passphrase, int32_t channel, cons

disconnect(false);

strcpy(STA_CFG.wifi_ssid, ssid);
strcpy(STA_CFG.ap_info.ssid, ssid);
STA_CFG.ap_info.channel = channel;
if (passphrase) {
strcpy(STA_CFG.wifi_key, passphrase);
strcpy(STA_CFG.key, passphrase);
STA_CFG.key_len = strlen(passphrase);
} else {
STA_CFG.wifi_bssid[0] = '\0';
STA_CFG.ap_info.bssid[0] = '\0';
}

if (reconnect(bssid))
Expand Down Expand Up @@ -61,25 +63,26 @@ bool WiFiClass::config(IPAddress localIP, IPAddress gateway, IPAddress subnet, I
}

bool WiFiClass::reconnect(const uint8_t *bssid) {
if (!bssid && !STA_CFG.wifi_ssid[0]) {
if (!bssid && !STA_CFG.ap_info.ssid[0]) {
LT_EM(WIFI, "(B)SSID not specified");
goto error;
}

if (bssid) {
LT_IM(WIFI, "Connecting to " MACSTR, MAC2STR(bssid));
} else {
LT_IM(WIFI, "Connecting to %s", STA_CFG.wifi_ssid);
LT_IM(WIFI, "Connecting to %s", STA_CFG.ap_info.ssid);
}

LT_DM(WIFI, "Data = %p", DATA->configSta);

STA_CFG.wifi_mode = BK_STATION;
STA_CFG.wifi_retry_interval = 100;
if (bssid)
memcpy(STA_CFG.wifi_bssid, bssid, 6);
else
memset(STA_CFG.wifi_bssid, 0x00, 6);
if (bssid) {
memcpy(STA_CFG.ap_info.bssid, bssid, 6);
}
else{
memset(STA_CFG.ap_info.bssid, 0x00, 6);
}

if (STA_CFG.dhcp_mode == DHCP_DISABLE) {
LT_DM(WIFI, "Static IP: %s / %s / %s", STA_CFG.local_ip_addr, STA_CFG.net_mask, STA_CFG.gateway_ip_addr);
Expand All @@ -91,7 +94,7 @@ bool WiFiClass::reconnect(const uint8_t *bssid) {
LT_DM(WIFI, "Starting WiFi...");

__wrap_bk_printf_disable();
bk_wlan_start_sta(&STA_CFG);
bk_wlan_start_sta_adv(&STA_CFG);
__wrap_bk_printf_enable();

LT_DM(WIFI, "Start OK");
Expand Down

0 comments on commit 09050a8

Please sign in to comment.