[beken-72xx] Revert to standard station config struct
This commit is contained in:
@@ -6,7 +6,7 @@ bool WiFiClass::modePriv(WiFiMode mode, WiFiModeAction sta, WiFiModeAction ap) {
|
||||
__wrap_bk_printf_disable();
|
||||
|
||||
if (mode && !data.statusIp) {
|
||||
data.configSta = zalloc(sizeof(network_InitTypeDef_adv_st));
|
||||
data.configSta = zalloc(sizeof(network_InitTypeDef_st));
|
||||
data.configAp = zalloc(sizeof(network_InitTypeDef_ap_st));
|
||||
data.statusIp = malloc(sizeof(IPStatusTypedef));
|
||||
data.statusLink = malloc(sizeof(LinkStatusTypeDef));
|
||||
|
||||
@@ -42,7 +42,7 @@ WiFiAuthMode securityTypeToAuthMode(uint8_t type);
|
||||
|
||||
#define IP_FMT "%u.%u.%u.%u"
|
||||
|
||||
#define STA_CFG ((network_InitTypeDef_adv_st *)data.configSta)
|
||||
#define STA_CFG ((network_InitTypeDef_st *)data.configSta)
|
||||
#define AP_CFG ((network_InitTypeDef_ap_st *)data.configAp)
|
||||
#define IP_STATUS ((IPStatusTypedef *)data.statusIp)
|
||||
#define LINK_STATUS ((LinkStatusTypeDef *)data.statusLink)
|
||||
|
||||
@@ -11,16 +11,13 @@ WiFiClass::begin(const char *ssid, const char *passphrase, int32_t channel, cons
|
||||
|
||||
LT_HEAP_I();
|
||||
|
||||
strcpy(STA_CFG->ap_info.ssid, ssid);
|
||||
strcpy(STA_CFG->wifi_ssid, ssid);
|
||||
if (passphrase) {
|
||||
strcpy(STA_CFG->key, passphrase);
|
||||
STA_CFG->key_len = strlen(passphrase);
|
||||
strcpy(STA_CFG->wifi_key, passphrase);
|
||||
} else {
|
||||
STA_CFG->key_len = 0;
|
||||
STA_CFG->wifi_bssid[0] = '\0';
|
||||
}
|
||||
|
||||
STA_CFG->ap_info.channel = channel;
|
||||
|
||||
if (reconnect(bssid))
|
||||
return WL_CONNECTED;
|
||||
|
||||
@@ -54,7 +51,7 @@ bool WiFiClass::config(IPAddress localIP, IPAddress gateway, IPAddress subnet, I
|
||||
}
|
||||
|
||||
bool WiFiClass::reconnect(const uint8_t *bssid) {
|
||||
if (!bssid && !STA_CFG->ap_info.ssid[0]) {
|
||||
if (!bssid && !STA_CFG->wifi_ssid[0]) {
|
||||
LT_E("(B)SSID not specified");
|
||||
goto error;
|
||||
}
|
||||
@@ -62,17 +59,17 @@ bool WiFiClass::reconnect(const uint8_t *bssid) {
|
||||
if (bssid) {
|
||||
LT_D_WG("Connecting to " MACSTR, MAC2STR(bssid));
|
||||
} else {
|
||||
LT_D_WG("Connecting to %s", STA_CFG->ap_info.ssid);
|
||||
LT_D_WG("Connecting to %s", STA_CFG->wifi_ssid);
|
||||
}
|
||||
|
||||
STA_CFG->wifi_mode = BK_STATION;
|
||||
STA_CFG->wifi_retry_interval = 100;
|
||||
STA_CFG->ap_info.security = BK_SECURITY_TYPE_AUTO;
|
||||
if (bssid)
|
||||
memcpy(STA_CFG->ap_info.bssid, bssid, 6);
|
||||
memcpy(STA_CFG->wifi_bssid, bssid, 6);
|
||||
else
|
||||
memset(STA_CFG->ap_info.bssid, 0x00, 6);
|
||||
memset(STA_CFG->wifi_bssid, 0x00, 6);
|
||||
|
||||
if (STA_CFG->dhcp_mode == DHCP_DISABLE) {
|
||||
if (STA_CFG->dhcp_mode != DHCP_DISABLE) {
|
||||
LT_D_WG("Static IP: %s / %s / %s", STA_CFG->local_ip_addr, STA_CFG->net_mask, STA_CFG->gateway_ip_addr);
|
||||
LT_D_WG("Static DNS: %s", STA_CFG->dns_server_ip_addr);
|
||||
} else {
|
||||
@@ -90,7 +87,7 @@ bool WiFiClass::reconnect(const uint8_t *bssid) {
|
||||
LT_D_WG("Starting WiFi...");
|
||||
|
||||
__wrap_bk_printf_disable();
|
||||
bk_wlan_start_sta_adv(STA_CFG);
|
||||
bk_wlan_start_sta(STA_CFG);
|
||||
__wrap_bk_printf_enable();
|
||||
|
||||
LT_D_WG("Start OK");
|
||||
|
||||
28
platform/beken-72xx/fixups/wrap_wlan_ui.c
Normal file
28
platform/beken-72xx/fixups/wrap_wlan_ui.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-07-01. */
|
||||
|
||||
#include <param_config.h>
|
||||
#include <wlan_ui_pub.h>
|
||||
|
||||
// NOTE: this wrap is currently not used, as the related methods
|
||||
// are in the same translation unit (wlan_ui.c), so wrapping doesn't work
|
||||
|
||||
extern void __real_bk_wlan_sta_init_adv(network_InitTypeDef_adv_st *inNetworkInitParaAdv);
|
||||
extern sta_param_t *g_sta_param_ptr;
|
||||
|
||||
// enable/disable fast connect according to the config parameters
|
||||
void __wrap_bk_wlan_sta_init_adv(network_InitTypeDef_adv_st *inNetworkInitParaAdv) {
|
||||
// let it do the job first
|
||||
__real_bk_wlan_sta_init_adv(inNetworkInitParaAdv);
|
||||
// correct the parameter
|
||||
bool fast_connect = false;
|
||||
if (inNetworkInitParaAdv->ap_info.channel) {
|
||||
// enable fast connect after finding first non-zero octet of BSSID
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
if (inNetworkInitParaAdv->ap_info.bssid[i] != 0x00) {
|
||||
fast_connect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_sta_param_ptr->fast_connect_set = fast_connect;
|
||||
}
|
||||
Reference in New Issue
Block a user