9 #include "lwip/netif.h" 21 static const char *
const TAG =
"wifi_pico_w";
24 if (sta.has_value()) {
26 cyw43_wifi_set_up(&cyw43_state, CYW43_ITF_STA,
true, CYW43_COUNTRY_WORLDWIDE);
31 cyw43_wifi_set_up(&cyw43_state, CYW43_ITF_AP,
true, CYW43_COUNTRY_WORLDWIDE);
41 pm = CYW43_PERFORMANCE_PM;
44 pm = CYW43_DEFAULT_PM;
47 pm = CYW43_AGGRESSIVE_PM;
50 int ret = cyw43_wifi_pm(&cyw43_state, pm);
61 auto ret = WiFi.begin(ap.get_ssid().c_str(), ap.get_password().c_str());
62 if (ret != WL_CONNECTED)
71 if (!manual_ip.has_value()) {
75 IPAddress ip_address = manual_ip->static_ip;
76 IPAddress gateway = manual_ip->gateway;
77 IPAddress subnet = manual_ip->subnet;
79 IPAddress dns = manual_ip->dns1;
81 WiFi.config(ip_address, dns, gateway, subnet);
99 int status = cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_STA);
101 case CYW43_LINK_JOIN:
102 case CYW43_LINK_NOIP:
106 case CYW43_LINK_FAIL:
107 case CYW43_LINK_BADAUTH:
109 case CYW43_LINK_NONET:
122 std::copy(result->bssid, result->bssid + 6, bssid.begin());
123 std::string ssid(reinterpret_cast<const char *>(result->ssid));
124 WiFiScanResult res(bssid, ssid, result->channel, result->rssi, result->auth_mode != CYW43_AUTH_OPEN, ssid.empty());
133 cyw43_wifi_scan_options_t scan_options = {0};
134 scan_options.scan_type = passive ? 1 : 0;
137 ESP_LOGV(TAG,
"cyw43_wifi_scan failed!");
147 ip_address = manual_ip->static_ip;
148 gateway = manual_ip->gateway;
149 subnet = manual_ip->subnet;
150 dns = manual_ip->static_ip;
157 WiFi.config(ip_address, dns, gateway, subnet);
165 ESP_LOGV(TAG,
"wifi_ap_ip_config_ failed!");
175 #endif // USE_WIFI_AP 178 int err = cyw43_wifi_leave(&cyw43_state, CYW43_ITF_STA);
184 uint8_t raw_bssid[6];
185 WiFi.BSSID(raw_bssid);
186 for (
size_t i = 0; i < bssid.size(); i++)
187 bssid[i] = raw_bssid[i];
197 for (
auto addr : addrList) {
198 addresses[index++] = addr.ipFromNetifNum();
205 const ip_addr_t *dns_ip = dns_getserver(num);
212 ESP_LOGV(TAG,
"Scan done!");
WiFiSTAConnectStatus wifi_sta_connect_status_()
std::array< uint8_t, 6 > bssid_t
const std::string & get_password() const
WiFiPowerSaveMode power_save_
WiFiComponentState state_
network::IPAddress wifi_dns_ip_(int num)
network::IPAddresses wifi_sta_ip_addresses()
bool wifi_mode_(optional< bool > sta, optional< bool > ap)
bool wifi_apply_output_power_(float output_power)
bool wifi_sta_ip_config_(optional< ManualIP > manual_ip)
network::IPAddress wifi_subnet_mask_()
bool wifi_apply_hostname_()
std::vector< WiFiScanResult > scan_result_
WiFi is in STA-only mode and currently scanning for APs.
bool wifi_start_ap_(const WiFiAP &ap)
const optional< ManualIP > & get_manual_ip() const
const optional< uint8_t > & get_channel() const
BedjetMode mode
BedJet operating mode.
bool wifi_apply_power_save_()
Application App
Global storage of Application pointer - only one Application can exist.
bool wifi_ap_ip_config_(optional< ManualIP > manual_ip)
WiFiComponent * global_wifi_component
const std::string & get_name() const
Get the name of this Application set by pre_setup().
std::array< IPAddress, 5 > IPAddresses
network::IPAddress wifi_soft_ap_ip()
bool wifi_sta_pre_setup_()
const char * get_auth_mode_str(uint8_t mode)
network::IPAddress wifi_gateway_ip_()
bool wifi_scan_start_(bool passive)
Implementation of SPI Controller mode.
const std::string & get_ssid() const
const char * get_disconnect_reason_str(uint8_t reason)
static int s_wifi_scan_result(void *env, const cyw43_ev_scan_result_t *result)
value_type value_or(U const &v) const
bool wifi_sta_connect_(const WiFiAP &ap)
void wifi_scan_result(void *env, const cyw43_ev_scan_result_t *result)