- *** Booting Zephyr OS build v3.6.0 ***
- [00:00:00.152,000] <inf> net_config: Initializing network
- [00:00:00.152,000] <inf> net_config: Waiting interface 1 (0x3fcc0b00) to be up.
- [00:00:00.153,000] <inf> net_config: Interface 1 (0x3fcc0b00) coming up
- [00:00:00.153,000] <inf> net_config: Running dhcpv4 client...
- before connection request
- connection request failed: -22
connectTo method:
- bool WifiDriver::connectTo(const SSIDstring& ssid, const PSKstring& password) {
- if (k_sem_count_get(&connectionSemaphore) > 0) {
- return false;
- }
- strncpy(reinterpret_cast<char*>(_ssid), ssid.c_str(), WIFI_SSID_MAX_LEN);
- _wifiParams.ssid_length = ssid.length();
- strncpy(
- reinterpret_cast<char*>(_password), password.c_str(), WIFI_PSK_MAX_LEN);
- _wifiParams.psk_length = password.length();
- _wifiParams.sae_password_length = password.length();
- printk("before connection request\n");
- int res = net_mgmt(NET_REQUEST_WIFI_CONNECT,
- _netInterface,
- &_wifiParams,
- sizeof(_wifiParams));
- if (res) {
- printk("connection request failed: %d\n", res, strerror(res));
- return false;
- }
- printk("connection succeded\n");
- _connected = true;
- return true;
- }
- void WifiDriver::init() {
- k_sem_init(&connectionSemaphore, 0, 1);
- net_mgmt_init_event_callback(
- &_wifiCallback,
- WifiDriver::wifiCallbackHandler,
- NET_EVENT_WIFI_CONNECT_RESULT | NET_EVENT_WIFI_DISCONNECT_RESULT);
- net_mgmt_init_event_callback(&_ipv4Callback,
- WifiDriver::ipv4CallbackHandler,
- NET_EVENT_IPV4_ADDR_ADD);
- net_mgmt_add_event_callback(&_wifiCallback);
- net_mgmt_add_event_callback(&_ipv4Callback);
- _netInterface = net_if_get_default();
- if (_netInterface == NULL) {
- printk("net_if_get_default failed! No default interface configured!\n");
- }
- _wifiParams.ssid = _ssid;
- _wifiParams.ssid_length = 0;
- _wifiParams.psk = _password;
- _wifiParams.psk_length = 0;
- _wifiParams.sae_password = _password;
- _wifiParams.sae_password_length = 0;
- _wifiParams.band = WIFI_FREQ_BAND_2_4_GHZ;
- _wifiParams.channel = WIFI_CHANNEL_ANY;
- _wifiParams.security = WIFI_SECURITY_TYPE_UNKNOWN;
- _wifiParams.mfp = WIFI_MFP_DISABLE;
- _wifiParams.timeout = SYS_FOREVER_MS;
- _connected = false;
- }