[beken-72xx] Make WiFiData private
This commit is contained in:
@@ -3,36 +3,16 @@
|
||||
#include "WiFiPrivate.h"
|
||||
|
||||
WiFiClass::WiFiClass() {
|
||||
memset(&data, 0x00, sizeof(WiFiData));
|
||||
data.scanSem = xSemaphoreCreateBinary();
|
||||
data = (WiFiData *)calloc(1, sizeof(WiFiData));
|
||||
|
||||
DATA->scanSem = xSemaphoreCreateBinary();
|
||||
STA_CFG.dhcp_mode = DHCP_CLIENT;
|
||||
}
|
||||
|
||||
WiFiClass::~WiFiClass() {
|
||||
vSemaphoreDelete(data.scanSem);
|
||||
}
|
||||
|
||||
void WiFiClass::dataInitialize() {
|
||||
if (data.statusIp)
|
||||
return;
|
||||
LT_DM(WIFI, "Data init");
|
||||
data.configSta = calloc(1, sizeof(network_InitTypeDef_st));
|
||||
data.configAp = calloc(1, sizeof(network_InitTypeDef_ap_st));
|
||||
data.statusIp = malloc(sizeof(IPStatusTypedef));
|
||||
data.statusLink = malloc(sizeof(LinkStatusTypeDef));
|
||||
STA_CFG->dhcp_mode = DHCP_CLIENT;
|
||||
LT_DM(WIFI, "Data = %p", data.configSta);
|
||||
}
|
||||
|
||||
void WiFiClass::dataFree() {
|
||||
LT_DM(WIFI, "Data free");
|
||||
free(data.configSta);
|
||||
free(data.configAp);
|
||||
free(data.statusIp);
|
||||
free(data.statusLink);
|
||||
data.configSta = NULL;
|
||||
data.configAp = NULL;
|
||||
data.statusIp = NULL;
|
||||
data.statusLink = NULL;
|
||||
vSemaphoreDelete(DATA->scanSem);
|
||||
free(data);
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
WiFiStatus eventTypeToStatus(uint8_t type) {
|
||||
|
||||
@@ -13,32 +13,32 @@ bool WiFiClass::softAP(const char *ssid, const char *passphrase, int channel, bo
|
||||
// Beken SDK bug: bk_wlan_ap_init_adv() doesn't null-terminate the passphrase
|
||||
memset(g_ap_param_ptr->key, '\0', 65);
|
||||
|
||||
strcpy(AP_CFG->wifi_ssid, ssid);
|
||||
strcpy(AP_CFG.wifi_ssid, ssid);
|
||||
if (passphrase) {
|
||||
strcpy(AP_CFG->wifi_key, passphrase);
|
||||
AP_CFG->security = BK_SECURITY_TYPE_WPA2_MIXED;
|
||||
strcpy(AP_CFG.wifi_key, passphrase);
|
||||
AP_CFG.security = BK_SECURITY_TYPE_WPA2_MIXED;
|
||||
} else {
|
||||
AP_CFG->wifi_key[0] = '\0';
|
||||
AP_CFG->security = BK_SECURITY_TYPE_NONE;
|
||||
AP_CFG.wifi_key[0] = '\0';
|
||||
AP_CFG.security = BK_SECURITY_TYPE_NONE;
|
||||
}
|
||||
|
||||
AP_CFG->channel = channel;
|
||||
AP_CFG->ssid_hidden = ssidHidden;
|
||||
AP_CFG->max_con = maxClients;
|
||||
AP_CFG->dhcp_mode = DHCP_SERVER;
|
||||
AP_CFG->wifi_retry_interval = 100;
|
||||
AP_CFG.channel = channel;
|
||||
AP_CFG.ssid_hidden = ssidHidden;
|
||||
AP_CFG.max_con = maxClients;
|
||||
AP_CFG.dhcp_mode = DHCP_SERVER;
|
||||
AP_CFG.wifi_retry_interval = 100;
|
||||
|
||||
LT_IM(WIFI, "Creating SoftAP %s", ssid);
|
||||
|
||||
if (!AP_CFG->local_ip_addr[0]) {
|
||||
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);
|
||||
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);
|
||||
OSStatus ret = bk_wlan_start_ap_adv(&AP_CFG);
|
||||
__wrap_bk_printf_enable();
|
||||
|
||||
if (ret != 0) {
|
||||
@@ -50,24 +50,23 @@ bool WiFiClass::softAP(const char *ssid, const char *passphrase, int channel, bo
|
||||
}
|
||||
|
||||
bool WiFiClass::softAPConfig(IPAddress localIP, IPAddress gateway, IPAddress subnet) {
|
||||
dataInitialize();
|
||||
if (!localIP) {
|
||||
localIP = gateway = IPAddress(192, 168, 43, 1);
|
||||
subnet = IPAddress(255, 255, 255, 0);
|
||||
}
|
||||
sprintf(AP_CFG->local_ip_addr, IP_FMT, localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||
sprintf(AP_CFG->net_mask, IP_FMT, subnet[0], subnet[1], subnet[2], subnet[3]);
|
||||
sprintf(AP_CFG->gateway_ip_addr, IP_FMT, gateway[0], gateway[1], gateway[2], gateway[3]);
|
||||
sprintf(AP_CFG.local_ip_addr, IP_FMT, localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||
sprintf(AP_CFG.net_mask, IP_FMT, subnet[0], subnet[1], subnet[2], subnet[3]);
|
||||
sprintf(AP_CFG.gateway_ip_addr, IP_FMT, gateway[0], gateway[1], gateway[2], gateway[3]);
|
||||
// from wlan_ui.c:1370
|
||||
if (uap_ip_is_start()) {
|
||||
uap_ip_down();
|
||||
ip_address_set(
|
||||
BK_STATION,
|
||||
AP_CFG->dhcp_mode,
|
||||
AP_CFG->local_ip_addr,
|
||||
AP_CFG->net_mask,
|
||||
AP_CFG->gateway_ip_addr,
|
||||
AP_CFG->dns_server_ip_addr
|
||||
AP_CFG.dhcp_mode,
|
||||
AP_CFG.local_ip_addr,
|
||||
AP_CFG.net_mask,
|
||||
AP_CFG.gateway_ip_addr,
|
||||
AP_CFG.dns_server_ip_addr
|
||||
);
|
||||
uap_ip_start();
|
||||
}
|
||||
@@ -88,14 +87,14 @@ uint8_t WiFiClass::softAPgetStationNum() {
|
||||
IPAddress WiFiClass::softAPIP() {
|
||||
AP_GET_IP_STATUS_RETURN((uint32_t)0);
|
||||
IPAddress ip;
|
||||
ip.fromString(IP_STATUS->ip);
|
||||
ip.fromString(IP_STATUS.ip);
|
||||
return ip;
|
||||
}
|
||||
|
||||
IPAddress WiFiClass::softAPSubnetMask() {
|
||||
AP_GET_IP_STATUS_RETURN((uint32_t)0);
|
||||
IPAddress ip;
|
||||
ip.fromString(IP_STATUS->mask);
|
||||
ip.fromString(IP_STATUS.mask);
|
||||
return ip;
|
||||
}
|
||||
|
||||
@@ -123,5 +122,5 @@ String WiFiClass::softAPmacAddress(void) {
|
||||
|
||||
const String WiFiClass::softAPSSID(void) {
|
||||
AP_GET_LINK_STATUS_RETURN("");
|
||||
return AP_CFG->wifi_ssid;
|
||||
return AP_CFG.wifi_ssid;
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-26. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern "C" {
|
||||
#define _ARCH_H_
|
||||
#define _GENERIC_H_
|
||||
#include <FreeRTOS.h>
|
||||
#include <include.h>
|
||||
#include <rw_msg_pub.h>
|
||||
#include <semphr.h>
|
||||
#undef _ARCH_H_
|
||||
#undef _GENERIC_H_
|
||||
} // extern "C"
|
||||
|
||||
typedef struct {
|
||||
void *configSta;
|
||||
void *configAp;
|
||||
unsigned long scannedAt;
|
||||
SemaphoreHandle_t scanSem;
|
||||
void *statusIp;
|
||||
void *statusLink;
|
||||
uint32_t lastStaEvent; // TODO revert this type back to rw_evt_type
|
||||
uint32_t lastApEvent;
|
||||
bool apEnabled;
|
||||
} WiFiData;
|
||||
@@ -53,9 +53,9 @@ void wifiEventHandler(rw_evt_type event) {
|
||||
LT_DM(WIFI, "BK event %u", event);
|
||||
|
||||
if (event <= RW_EVT_STA_GOT_IP)
|
||||
pWiFi->data.lastStaEvent = event;
|
||||
pDATA->lastStaEvent = event;
|
||||
else
|
||||
pWiFi->data.lastApEvent = event;
|
||||
pDATA->lastApEvent = event;
|
||||
|
||||
EventId eventId;
|
||||
EventInfo eventInfo;
|
||||
|
||||
@@ -45,21 +45,18 @@ bool WiFiClass::modePriv(WiFiMode mode, WiFiModeAction sta, WiFiModeAction ap) {
|
||||
if (ap == WLMODE_ENABLE) {
|
||||
LT_DM(WIFI, "Enabling AP");
|
||||
// fake it - on BK7231, enabling the AP without starting it breaks all connection attempts
|
||||
data.apEnabled = true;
|
||||
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;
|
||||
DATA->apEnabled = false;
|
||||
wifiEventSendArduino(ARDUINO_EVENT_WIFI_AP_STOP);
|
||||
}
|
||||
|
||||
// force checking actual mode again
|
||||
mode = getMode();
|
||||
|
||||
if (!mode)
|
||||
dataFree();
|
||||
|
||||
LT_HEAP_I();
|
||||
|
||||
__wrap_bk_printf_enable();
|
||||
@@ -68,14 +65,13 @@ 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 = data.apEnabled * WIFI_MODE_AP; // report the faked value
|
||||
uint8_t ap = DATA->apEnabled * WIFI_MODE_AP; // report the faked value
|
||||
return (WiFiMode)(sta | ap);
|
||||
}
|
||||
|
||||
WiFiStatus WiFiClass::status() {
|
||||
// TODO remove the cast
|
||||
rw_evt_type status = (rw_evt_type)data.lastStaEvent;
|
||||
if (status == RW_EVT_STA_CONNECTED && STA_CFG->dhcp_mode == DHCP_DISABLE)
|
||||
rw_evt_type status = DATA->lastStaEvent;
|
||||
if (status == RW_EVT_STA_CONNECTED && STA_CFG.dhcp_mode == DHCP_DISABLE)
|
||||
status = RW_EVT_STA_GOT_IP;
|
||||
return eventTypeToStatus(status);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ extern "C" {
|
||||
#include <config.h>
|
||||
#include <main_none.h>
|
||||
#include <param_config.h>
|
||||
#include <rw_msg_pub.h>
|
||||
#include <rw_msg_rx.h>
|
||||
#include <sa_ap.h>
|
||||
#include <sys_ctrl_pub.h>
|
||||
@@ -53,25 +54,41 @@ extern void wifiEventHandler(rw_evt_type event);
|
||||
|
||||
#define IP_FMT "%u.%u.%u.%u"
|
||||
|
||||
#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)
|
||||
typedef struct {
|
||||
network_InitTypeDef_st configSta;
|
||||
network_InitTypeDef_ap_st configAp;
|
||||
unsigned long scannedAt;
|
||||
SemaphoreHandle_t scanSem;
|
||||
IPStatusTypedef statusIp;
|
||||
LinkStatusTypeDef statusLink;
|
||||
rw_evt_type lastStaEvent;
|
||||
rw_evt_type lastApEvent;
|
||||
bool apEnabled;
|
||||
} WiFiData;
|
||||
|
||||
#define DATA ((WiFiData *)data)
|
||||
#define pDATA ((WiFiData *)pWiFi->data)
|
||||
#define cDATA ((WiFiData *)cls->data)
|
||||
|
||||
#define STA_CFG (DATA->configSta)
|
||||
#define AP_CFG (DATA->configAp)
|
||||
#define IP_STATUS (DATA->statusIp)
|
||||
#define LINK_STATUS (DATA->statusLink)
|
||||
|
||||
#define STA_GET_LINK_STATUS_RETURN(ret) \
|
||||
{ \
|
||||
if (!sta_ip_is_start()) \
|
||||
return ret; \
|
||||
memset(LINK_STATUS, 0x00, sizeof(LinkStatusTypeDef)); \
|
||||
bk_wlan_get_link_status(LINK_STATUS); \
|
||||
memset(&LINK_STATUS, 0x00, sizeof(LinkStatusTypeDef)); \
|
||||
bk_wlan_get_link_status(&LINK_STATUS); \
|
||||
}
|
||||
|
||||
#define STA_GET_IP_STATUS_RETURN(ret) \
|
||||
{ \
|
||||
if (!sta_ip_is_start()) \
|
||||
return ret; \
|
||||
memset(IP_STATUS, 0x00, sizeof(IPStatusTypedef)); \
|
||||
bk_wlan_get_ip_status(IP_STATUS, BK_STATION); \
|
||||
memset(&IP_STATUS, 0x00, sizeof(IPStatusTypedef)); \
|
||||
bk_wlan_get_ip_status(&IP_STATUS, BK_STATION); \
|
||||
}
|
||||
|
||||
#define AP_GET_LINK_STATUS_RETURN(ret) \
|
||||
@@ -84,8 +101,8 @@ extern void wifiEventHandler(rw_evt_type event);
|
||||
{ \
|
||||
if (!uap_ip_is_start()) \
|
||||
return ret; \
|
||||
memset(IP_STATUS, 0x00, sizeof(IPStatusTypedef)); \
|
||||
bk_wlan_get_ip_status(IP_STATUS, BK_SOFT_AP); \
|
||||
memset(&IP_STATUS, 0x00, sizeof(IPStatusTypedef)); \
|
||||
bk_wlan_get_ip_status(&IP_STATUS, BK_SOFT_AP); \
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -13,11 +13,11 @@ WiFiClass::begin(const char *ssid, const char *passphrase, int32_t channel, cons
|
||||
|
||||
disconnect(false);
|
||||
|
||||
strcpy(STA_CFG->wifi_ssid, ssid);
|
||||
strcpy(STA_CFG.wifi_ssid, ssid);
|
||||
if (passphrase) {
|
||||
strcpy(STA_CFG->wifi_key, passphrase);
|
||||
strcpy(STA_CFG.wifi_key, passphrase);
|
||||
} else {
|
||||
STA_CFG->wifi_bssid[0] = '\0';
|
||||
STA_CFG.wifi_bssid[0] = '\0';
|
||||
}
|
||||
|
||||
if (reconnect(bssid))
|
||||
@@ -27,23 +27,21 @@ WiFiClass::begin(const char *ssid, const char *passphrase, int32_t channel, cons
|
||||
}
|
||||
|
||||
bool WiFiClass::config(IPAddress localIP, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2) {
|
||||
dataInitialize();
|
||||
|
||||
STA_CFG->dhcp_mode = localIP ? DHCP_DISABLE : DHCP_CLIENT;
|
||||
STA_CFG.dhcp_mode = localIP ? DHCP_DISABLE : DHCP_CLIENT;
|
||||
if (localIP) {
|
||||
sprintf(STA_CFG->local_ip_addr, IP_FMT, localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||
sprintf(STA_CFG->net_mask, IP_FMT, subnet[0], subnet[1], subnet[2], subnet[3]);
|
||||
sprintf(STA_CFG->gateway_ip_addr, IP_FMT, gateway[0], gateway[1], gateway[2], gateway[3]);
|
||||
sprintf(STA_CFG.local_ip_addr, IP_FMT, localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||
sprintf(STA_CFG.net_mask, IP_FMT, subnet[0], subnet[1], subnet[2], subnet[3]);
|
||||
sprintf(STA_CFG.gateway_ip_addr, IP_FMT, gateway[0], gateway[1], gateway[2], gateway[3]);
|
||||
if (dns1) {
|
||||
sprintf(STA_CFG->dns_server_ip_addr, IP_FMT, dns1[0], dns1[1], dns1[2], dns1[3]);
|
||||
sprintf(STA_CFG.dns_server_ip_addr, IP_FMT, dns1[0], dns1[1], dns1[2], dns1[3]);
|
||||
} else {
|
||||
STA_CFG->dns_server_ip_addr[0] = '\0';
|
||||
STA_CFG.dns_server_ip_addr[0] = '\0';
|
||||
}
|
||||
} else {
|
||||
STA_CFG->local_ip_addr[0] = '\0';
|
||||
STA_CFG->net_mask[0] = '\0';
|
||||
STA_CFG->gateway_ip_addr[0] = '\0';
|
||||
STA_CFG->dns_server_ip_addr[0] = '\0';
|
||||
STA_CFG.local_ip_addr[0] = '\0';
|
||||
STA_CFG.net_mask[0] = '\0';
|
||||
STA_CFG.gateway_ip_addr[0] = '\0';
|
||||
STA_CFG.dns_server_ip_addr[0] = '\0';
|
||||
}
|
||||
|
||||
// from wlan_ui.c:1370
|
||||
@@ -51,11 +49,11 @@ bool WiFiClass::config(IPAddress localIP, IPAddress gateway, IPAddress subnet, I
|
||||
sta_ip_down();
|
||||
ip_address_set(
|
||||
BK_STATION,
|
||||
STA_CFG->dhcp_mode,
|
||||
STA_CFG->local_ip_addr,
|
||||
STA_CFG->net_mask,
|
||||
STA_CFG->gateway_ip_addr,
|
||||
STA_CFG->dns_server_ip_addr
|
||||
STA_CFG.dhcp_mode,
|
||||
STA_CFG.local_ip_addr,
|
||||
STA_CFG.net_mask,
|
||||
STA_CFG.gateway_ip_addr,
|
||||
STA_CFG.dns_server_ip_addr
|
||||
);
|
||||
sta_ip_start();
|
||||
}
|
||||
@@ -63,8 +61,7 @@ bool WiFiClass::config(IPAddress localIP, IPAddress gateway, IPAddress subnet, I
|
||||
}
|
||||
|
||||
bool WiFiClass::reconnect(const uint8_t *bssid) {
|
||||
dataInitialize();
|
||||
if (!bssid && !STA_CFG->wifi_ssid[0]) {
|
||||
if (!bssid && !STA_CFG.wifi_ssid[0]) {
|
||||
LT_EM(WIFI, "(B)SSID not specified");
|
||||
goto error;
|
||||
}
|
||||
@@ -72,21 +69,21 @@ bool WiFiClass::reconnect(const uint8_t *bssid) {
|
||||
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.wifi_ssid);
|
||||
}
|
||||
|
||||
LT_DM(WIFI, "Data = %p", data.configSta);
|
||||
LT_DM(WIFI, "Data = %p", DATA->configSta);
|
||||
|
||||
STA_CFG->wifi_mode = BK_STATION;
|
||||
STA_CFG->wifi_retry_interval = 100;
|
||||
STA_CFG.wifi_mode = BK_STATION;
|
||||
STA_CFG.wifi_retry_interval = 100;
|
||||
if (bssid)
|
||||
memcpy(STA_CFG->wifi_bssid, bssid, 6);
|
||||
memcpy(STA_CFG.wifi_bssid, bssid, 6);
|
||||
else
|
||||
memset(STA_CFG->wifi_bssid, 0x00, 6);
|
||||
memset(STA_CFG.wifi_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);
|
||||
LT_DM(WIFI, "Static DNS: %s", STA_CFG->dns_server_ip_addr);
|
||||
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);
|
||||
LT_DM(WIFI, "Static DNS: %s", STA_CFG.dns_server_ip_addr);
|
||||
} else {
|
||||
LT_DM(WIFI, "Using DHCP");
|
||||
}
|
||||
@@ -94,7 +91,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(&STA_CFG);
|
||||
__wrap_bk_printf_enable();
|
||||
|
||||
LT_DM(WIFI, "Start OK");
|
||||
@@ -106,9 +103,9 @@ error:
|
||||
|
||||
bool WiFiClass::disconnect(bool wifiOff) {
|
||||
#if LT_DEBUG_WIFI
|
||||
memset(LINK_STATUS, 0x00, sizeof(LinkStatusTypeDef));
|
||||
bk_wlan_get_link_status(LINK_STATUS);
|
||||
LT_DM(WIFI, "Disconnecting from %s (wifiOff=%d)", LINK_STATUS ? LINK_STATUS->ssid : NULL, wifiOff);
|
||||
memset(&LINK_STATUS, 0x00, sizeof(LinkStatusTypeDef));
|
||||
bk_wlan_get_link_status(&LINK_STATUS);
|
||||
LT_DM(WIFI, "Disconnecting from %s (wifiOff=%d)", LINK_STATUS.ssid, wifiOff);
|
||||
#endif
|
||||
bk_wlan_connection_loss();
|
||||
if (wifiOff)
|
||||
@@ -127,28 +124,28 @@ bool WiFiClass::getAutoReconnect() {
|
||||
IPAddress WiFiClass::localIP() {
|
||||
STA_GET_IP_STATUS_RETURN((uint32_t)0);
|
||||
IPAddress ip;
|
||||
ip.fromString(IP_STATUS->ip);
|
||||
ip.fromString(IP_STATUS.ip);
|
||||
return ip;
|
||||
}
|
||||
|
||||
IPAddress WiFiClass::subnetMask() {
|
||||
STA_GET_IP_STATUS_RETURN((uint32_t)0);
|
||||
IPAddress ip;
|
||||
ip.fromString(IP_STATUS->mask);
|
||||
ip.fromString(IP_STATUS.mask);
|
||||
return ip;
|
||||
}
|
||||
|
||||
IPAddress WiFiClass::gatewayIP() {
|
||||
STA_GET_IP_STATUS_RETURN((uint32_t)0);
|
||||
IPAddress ip;
|
||||
ip.fromString(IP_STATUS->gate);
|
||||
ip.fromString(IP_STATUS.gate);
|
||||
return ip;
|
||||
}
|
||||
|
||||
IPAddress WiFiClass::dnsIP(uint8_t dns_no) {
|
||||
STA_GET_IP_STATUS_RETURN((uint32_t)0);
|
||||
IPAddress ip;
|
||||
ip.fromString(IP_STATUS->dns);
|
||||
ip.fromString(IP_STATUS.dns);
|
||||
return ip;
|
||||
}
|
||||
|
||||
@@ -191,7 +188,7 @@ bool WiFiClass::setMacAddress(const uint8_t *mac) {
|
||||
|
||||
const String WiFiClass::SSID() {
|
||||
STA_GET_LINK_STATUS_RETURN("");
|
||||
return (char *)LINK_STATUS->ssid;
|
||||
return (char *)LINK_STATUS.ssid;
|
||||
}
|
||||
|
||||
const String WiFiClass::psk() {
|
||||
@@ -205,20 +202,20 @@ const String WiFiClass::psk() {
|
||||
|
||||
uint8_t *WiFiClass::BSSID() {
|
||||
STA_GET_LINK_STATUS_RETURN(NULL);
|
||||
return LINK_STATUS->bssid;
|
||||
return LINK_STATUS.bssid;
|
||||
}
|
||||
|
||||
int32_t WiFiClass::channel() {
|
||||
STA_GET_LINK_STATUS_RETURN(0);
|
||||
return LINK_STATUS->channel;
|
||||
return LINK_STATUS.channel;
|
||||
}
|
||||
|
||||
int8_t WiFiClass::RSSI() {
|
||||
STA_GET_LINK_STATUS_RETURN(0);
|
||||
return LINK_STATUS->wifi_strength;
|
||||
return LINK_STATUS.wifi_strength;
|
||||
}
|
||||
|
||||
WiFiAuthMode WiFiClass::getEncryption() {
|
||||
STA_GET_LINK_STATUS_RETURN(WIFI_AUTH_INVALID);
|
||||
return securityTypeToAuthMode(LINK_STATUS->security);
|
||||
return securityTypeToAuthMode(LINK_STATUS.security);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ static void scanHandler(void *ctx, uint8_t param) {
|
||||
memcpy(scan->ap[i].bssid.addr, result.ApList[i].bssid, 6);
|
||||
}
|
||||
|
||||
cls->data.scannedAt = millis();
|
||||
cDATA->scannedAt = millis();
|
||||
|
||||
wifiEventSendArduino(ARDUINO_EVENT_WIFI_SCAN_DONE);
|
||||
|
||||
@@ -45,7 +45,7 @@ end:
|
||||
if (scan->running) {
|
||||
// running == false means it was discarded (timeout)
|
||||
scan->running = false;
|
||||
xSemaphoreGive(cls->data.scanSem);
|
||||
xSemaphoreGive(cDATA->scanSem);
|
||||
}
|
||||
LT_HEAP_I();
|
||||
return;
|
||||
@@ -78,8 +78,8 @@ int16_t WiFiClass::scanNetworks(bool async, bool showHidden, bool passive, uint3
|
||||
int16_t ret = WIFI_SCAN_RUNNING;
|
||||
if (!async) {
|
||||
LT_IM(WIFI, "Waiting for results");
|
||||
xSemaphoreTake(data.scanSem, 1); // reset the semaphore quickly
|
||||
xSemaphoreTake(data.scanSem, pdMS_TO_TICKS(maxMsPerChannel * 20));
|
||||
xSemaphoreTake(DATA->scanSem, 1); // reset the semaphore quickly
|
||||
xSemaphoreTake(DATA->scanSem, pdMS_TO_TICKS(maxMsPerChannel * 20));
|
||||
if (scan->running) {
|
||||
scanDelete();
|
||||
ret = WIFI_SCAN_FAILED;
|
||||
|
||||
@@ -29,11 +29,6 @@
|
||||
|
||||
#include "WiFiType.h"
|
||||
|
||||
#ifdef LT_ARD_HAS_WIFI
|
||||
// family's data structure
|
||||
#include <WiFiData.h>
|
||||
#endif
|
||||
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
#include <WiFiServer.h>
|
||||
@@ -41,10 +36,8 @@
|
||||
|
||||
class WiFiClass {
|
||||
public:
|
||||
#ifdef LT_ARD_HAS_WIFI
|
||||
// must be public for WiFiEvents & WiFiScan static handlers
|
||||
WiFiData data;
|
||||
#endif
|
||||
void *data;
|
||||
WiFiScanData *scan = NULL;
|
||||
|
||||
public: /* WiFi.cpp */
|
||||
|
||||
Reference in New Issue
Block a user