-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwifi.cpp
36 lines (26 loc) · 809 Bytes
/
wifi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include "wifi.hpp"
Wifi::Wifi() : _failed(false){
if (cyw43_arch_init_with_country(CYW43_COUNTRY_UK)) {
_failed = true;
}
}
Wifi::~Wifi() {
cyw43_arch_deinit();
}
bool Wifi::connect(const char* ssid, const char* pass, uint32_t timeout){
return cyw43_arch_wifi_connect_timeout_ms(ssid, pass, CYW43_AUTH_WPA2_AES_PSK, timeout) == 0;
}
WifiStation::WifiStation(){
cyw43_arch_enable_sta_mode();
}
void WifiStation::restart(){
cyw43_arch_deinit();
cyw43_arch_init_with_country(CYW43_COUNTRY_UK);
cyw43_arch_enable_sta_mode();
}
WifiAccessPoint::WifiAccessPoint(const char * ssid, const char * password, uint32_t auth ){
cyw43_arch_enable_ap_mode(ssid, password, auth);
}