diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index ba3fb70cd9bee4..c4989b0011d3c8 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -851,15 +851,8 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFPublish(ConnectivityManager::WiFiPAF uint16_t freq_list_buf[0xff]; uint16_t * pfreq_lst = freq_list_buf; enum nan_service_protocol_type srv_proto_type = nan_service_protocol_type::NAN_SRV_PROTO_CSA_MATTER; - bool solicited = true; - bool unsolicited = true; - bool solicited_multicast = false; unsigned int ttl = CHIP_DEVICE_CONFIG_WIFIPAF_MAX_ADVERTISING_TIMEOUT; - bool disable_events = false; - bool fsd = true; - bool fsd_gas = false; unsigned int freq = CHIP_DEVICE_CONFIG_WIFIPAF_24G_DEFAUTL_CHNL; - unsigned int announcement_period = false; unsigned int freq_list_len; unsigned int ssi_len = sizeof(struct PAFPublishSSI); @@ -896,20 +889,28 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFPublish(ConnectivityManager::WiFiPAF return CHIP_ERROR_INTERNAL; } - std::lock_guard lock(mWpaSupplicantMutex); - GVariant * args = g_variant_new("(sybbbqbbbqqqqvv)", srv_name, srv_proto_type, solicited, unsolicited, solicited_multicast, ttl, - disable_events, fsd, fsd_gas, freq, announcement_period, ssi_len, freq_list_len, - ssi_array_variant, freq_array_variant); - + GVariantBuilder builder; + GVariant * args = nullptr; + g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_add(&builder, "{sv}", "srv_name", g_variant_new_string(srv_name)); + g_variant_builder_add(&builder, "{sv}", "srv_proto_type", g_variant_new_byte(srv_proto_type)); + g_variant_builder_add(&builder, "{sv}", "ttl", g_variant_new_uint16(ttl)); + g_variant_builder_add(&builder, "{sv}", "freq", g_variant_new_uint16(freq)); + g_variant_builder_add(&builder, "{sv}", "ssi", ssi_array_variant); + g_variant_builder_add(&builder, "{sv}", "freq_list", freq_array_variant); + args = g_variant_builder_end(&builder); wpa_fi_w1_wpa_supplicant1_interface_call_nanpublish_sync(mWpaSupplicant.iface, args, &publish_id, nullptr, &err.GetReceiver()); + ChipLogProgress(DeviceLayer, "WiFi-PAF: publish_id: %d ! ", publish_id); + mpaf_info.peer_publish_id = publish_id; - g_signal_connect(mWpaSupplicant.iface, "nan-replied", - G_CALLBACK(+[](WpaFiW1Wpa_supplicant1Interface * proxy, gboolean success, GVariant * obj, - ConnectivityManagerImpl * self) { return self->OnReplied(success, obj); }), + g_signal_connect(mWpaSupplicant.iface, "nanreplied", + G_CALLBACK(+[](WpaFiW1Wpa_supplicant1Interface * proxy, GVariant * obj, ConnectivityManagerImpl * self) { + return self->OnReplied(obj); + }), this); - g_signal_connect(mWpaSupplicant.iface, "nan-receive", + g_signal_connect(mWpaSupplicant.iface, "nanreceive", G_CALLBACK(+[](WpaFiW1Wpa_supplicant1Interface * proxy, GVariant * obj, ConnectivityManagerImpl * self) { return self->OnNanReceive(obj); }), @@ -917,6 +918,45 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFPublish(ConnectivityManager::WiFiPAF return CHIP_NO_ERROR; } +CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFUpdatePublish() +{ + ChipLogProgress(Controller, "WiFi-PAF: Try to update publish the NAN-USD devices"); + GAutoPtr err; + gint publish_id = mpaf_info.peer_publish_id; + unsigned int ssi_len = sizeof(struct PAFPublishSSI); + struct PAFPublishSSI PafPublish_ssi; + + PafPublish_ssi.DevOpCode = 0; + VerifyOrDie(DeviceLayer::GetCommissionableDataProvider()->GetSetupDiscriminator(PafPublish_ssi.DevInfo) == CHIP_NO_ERROR); + if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetProductId(PafPublish_ssi.ProductId) != CHIP_NO_ERROR) + { + PafPublish_ssi.ProductId = 0; + } + if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(PafPublish_ssi.VendorId) != CHIP_NO_ERROR) + { + PafPublish_ssi.VendorId = 0; + } + + GVariant * ssi_array_variant = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, &PafPublish_ssi, ssi_len, sizeof(guint8)); + if (ssi_array_variant == nullptr) + { + ChipLogProgress(DeviceLayer, "WiFi-PAF: ssi_array_variant is NULL "); + return CHIP_ERROR_INTERNAL; + } + std::lock_guard lock(mWpaSupplicantMutex); + GVariantBuilder builder; + GVariant * args = nullptr; + g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_add(&builder, "{sv}", "publish_id", g_variant_new_int32(publish_id)); + g_variant_builder_add(&builder, "{sv}", "ssi_len", g_variant_new_uint16(ssi_len)); + g_variant_builder_add(&builder, "{sv}", "ssi", ssi_array_variant); + args = g_variant_builder_end(&builder); + wpa_fi_w1_wpa_supplicant1_interface_call_nanupdate_publish_sync(mWpaSupplicant.iface, args, nullptr, &err.GetReceiver()); + ChipLogProgress(DeviceLayer, "WiFi-PAF: publish_id: [%d]", publish_id); + + return CHIP_NO_ERROR; +} + CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFCancelPublish() { GAutoPtr err; @@ -1376,9 +1416,9 @@ CHIP_ERROR ConnectivityManagerImpl::ConnectWiFiNetworkWithPDCAsync( /* NAN-USD Service Protocol Type: ref: Table 58 of Wi-Fi Aware Specificaiton */ -void ConnectivityManagerImpl::OnDiscoveryResult(gboolean success, GVariant * discov_info) +void ConnectivityManagerImpl::OnDiscoveryResult(GVariant * discov_info) { - ChipLogProgress(Controller, "WiFi-PAF: OnDiscoveryResult, %d", success); + ChipLogProgress(Controller, "WiFi-PAF: OnDiscoveryResult"); std::lock_guard lock(mWpaSupplicantMutex); if (g_variant_n_children(discov_info) == 0) @@ -1386,45 +1426,61 @@ void ConnectivityManagerImpl::OnDiscoveryResult(gboolean success, GVariant * dis return; } - if (success == true) - { - GAutoPtr dataValue(g_variant_lookup_value(discov_info, "discov_info", G_VARIANT_TYPE_BYTESTRING)); - size_t bufferLen; - auto buffer = g_variant_get_fixed_array(dataValue.get(), &bufferLen, sizeof(uint8_t)); - if (((struct wpa_dbus_discov_info *) buffer)->subscribe_id == mpaf_info.subscribe_id) - { - return; - } - memcpy(&mpaf_info, buffer, sizeof(struct wpa_dbus_discov_info)); - ChipLogProgress(DeviceLayer, "WiFi-PAF: subscribe_id: %u", mpaf_info.subscribe_id); - ChipLogProgress(DeviceLayer, "WiFi-PAF: peer_publish_id: %u", mpaf_info.peer_publish_id); - ChipLogProgress(DeviceLayer, "WiFi-PAF: peer_addr: [%02x:%02x:%02x:%02x:%02x:%02x]", mpaf_info.peer_addr[0], - mpaf_info.peer_addr[1], mpaf_info.peer_addr[2], mpaf_info.peer_addr[3], mpaf_info.peer_addr[4], - mpaf_info.peer_addr[5]); - GetWiFiPAF()->SetWiFiPAFState(WiFiPAF::State::kConnected); - - // Read the ssi - GAutoPtr ssiValue(g_variant_lookup_value(discov_info, "ssi", G_VARIANT_TYPE_BYTESTRING)); - size_t ssiBufLen; - g_variant_get_fixed_array(ssiValue.get(), &ssiBufLen, sizeof(uint8_t)); - - ChipDeviceEvent event; - event.Type = DeviceEventType::kCHIPoWiFiPAFConnected; - PlatformMgr().PostEventOrDie(&event); - } - else - { - GetWiFiPAF()->SetWiFiPAFState(WiFiPAF::State::kInitialized); - if (mOnPafSubscribeError != nullptr) - { - mOnPafSubscribeError(mAppState, CHIP_ERROR_TIMEOUT); - } - } + GAutoPtr dataValue; + GVariant * value; + + value = g_variant_lookup_value(discov_info, "subscribe_id", G_VARIANT_TYPE_UINT32); + dataValue.reset(value); + g_variant_get(dataValue.get(), "u", &mpaf_info.subscribe_id); + + value = g_variant_lookup_value(discov_info, "publish_id", G_VARIANT_TYPE_UINT32); + dataValue.reset(value); + g_variant_get(dataValue.get(), "u", &mpaf_info.peer_publish_id); + + char addr_str[20]; + char * paddr; + value = g_variant_lookup_value(discov_info, "peer_addr", G_VARIANT_TYPE_STRING); + dataValue.reset(value); + g_variant_get(dataValue.get(), "s", &paddr); + strncpy(addr_str, paddr, sizeof(addr_str)); + sscanf(addr_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &mpaf_info.peer_addr[0], &mpaf_info.peer_addr[1], + &mpaf_info.peer_addr[2], &mpaf_info.peer_addr[3], &mpaf_info.peer_addr[4], &mpaf_info.peer_addr[5]); + + value = g_variant_lookup_value(discov_info, "fsd", G_VARIANT_TYPE_BOOLEAN); + dataValue.reset(value); + g_variant_get(dataValue.get(), "b", &mpaf_info.fsd); + + value = g_variant_lookup_value(discov_info, "fsd_gas", G_VARIANT_TYPE_BOOLEAN); + dataValue.reset(value); + g_variant_get(dataValue.get(), "b", &mpaf_info.fsd_gas); + + value = g_variant_lookup_value(discov_info, "srv_proto_type", G_VARIANT_TYPE_UINT32); + dataValue.reset(value); + g_variant_get(dataValue.get(), "u", &mpaf_info.srv_proto_type); + + ChipLogProgress(DeviceLayer, "WiFi-PAF: subscribe_id: %u", mpaf_info.subscribe_id); + ChipLogProgress(DeviceLayer, "WiFi-PAF: peer_publish_id: %u", mpaf_info.peer_publish_id); + ChipLogProgress(DeviceLayer, "WiFi-PAF: peer_addr: [%02x:%02x:%02x:%02x:%02x:%02x]", mpaf_info.peer_addr[0], + mpaf_info.peer_addr[1], mpaf_info.peer_addr[2], mpaf_info.peer_addr[3], mpaf_info.peer_addr[4], + mpaf_info.peer_addr[5]); + GetWiFiPAF()->SetWiFiPAFState(WiFiPAF::State::kConnected); + mpaf_tx_info.id = mpaf_info.subscribe_id; + mpaf_tx_info.peer_id = mpaf_info.peer_publish_id; + memcpy(mpaf_tx_info.peer_addr, mpaf_info.peer_addr, sizeof(mpaf_tx_info.peer_addr)); + + // Read the ssi + GAutoPtr ssiValue(g_variant_lookup_value(discov_info, "ssi", G_VARIANT_TYPE_BYTESTRING)); + size_t ssiBufLen; + g_variant_get_fixed_array(ssiValue.get(), &ssiBufLen, sizeof(uint8_t)); + + ChipDeviceEvent event; + event.Type = DeviceEventType::kCHIPoWiFiPAFConnected; + PlatformMgr().PostEventOrDie(&event); } -void ConnectivityManagerImpl::OnReplied(gboolean success, GVariant * reply_info) +void ConnectivityManagerImpl::OnReplied(GVariant * reply_info) { - ChipLogProgress(Controller, "WiFi-PAF: OnReplied, %d", success); + ChipLogProgress(Controller, "WiFi-PAF: OnReplied"); std::lock_guard lock(mWpaSupplicantMutex); if (g_variant_n_children(reply_info) == 0) @@ -1432,29 +1488,39 @@ void ConnectivityManagerImpl::OnReplied(gboolean success, GVariant * reply_info) return; } - if (success == true) - { - GAutoPtr dataValue(g_variant_lookup_value(reply_info, "reply_info", G_VARIANT_TYPE_BYTESTRING)); - size_t bufferLen; - auto buffer = g_variant_get_fixed_array(dataValue.get(), &bufferLen, sizeof(uint8_t)); - struct wpa_dbus_reply_info * preply_info; - - preply_info = (struct wpa_dbus_reply_info *) buffer; - ChipLogProgress(DeviceLayer, "WiFi-PAF: publish_id: %u", preply_info->publish_id); - ChipLogProgress(DeviceLayer, "WiFi-PAF: peer_subscribe_id: %u", preply_info->peer_subscribe_id); - ChipLogProgress(DeviceLayer, "WiFi-PAF: peer_addr: [%02x:%02x:%02x:%02x:%02x:%02x]", preply_info->peer_addr[0], - preply_info->peer_addr[1], preply_info->peer_addr[2], preply_info->peer_addr[3], preply_info->peer_addr[4], - preply_info->peer_addr[5]); - ChipLogProgress(DeviceLayer, "WiFi-PAF: ssi_len: %u", preply_info->ssi_len); - } - else - { - GetWiFiPAF()->SetWiFiPAFState(WiFiPAF::State::kInitialized); - if (mOnPafSubscribeError != nullptr) - { - mOnPafSubscribeError(mAppState, CHIP_ERROR_TIMEOUT); - } - } + GAutoPtr dataValue; + GVariant * value; + + value = g_variant_lookup_value(reply_info, "publish_id", G_VARIANT_TYPE_UINT32); + dataValue.reset(value); + g_variant_get(dataValue.get(), "u", &mpaf_reply_info.publish_id); + + value = g_variant_lookup_value(reply_info, "subscribe_id", G_VARIANT_TYPE_UINT32); + dataValue.reset(value); + g_variant_get(dataValue.get(), "u", &mpaf_reply_info.peer_subscribe_id); + + char addr_str[20]; + char * paddr; + value = g_variant_lookup_value(reply_info, "peer_addr", G_VARIANT_TYPE_STRING); + dataValue.reset(value); + g_variant_get(dataValue.get(), "s", &paddr); + strncpy(addr_str, paddr, sizeof(addr_str)); + sscanf(addr_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &mpaf_reply_info.peer_addr[0], &mpaf_reply_info.peer_addr[1], + &mpaf_reply_info.peer_addr[2], &mpaf_reply_info.peer_addr[3], &mpaf_reply_info.peer_addr[4], + &mpaf_reply_info.peer_addr[5]); + + value = g_variant_lookup_value(reply_info, "srv_proto_type", G_VARIANT_TYPE_UINT32); + dataValue.reset(value); + g_variant_get(dataValue.get(), "u", &mpaf_reply_info.srv_proto_type); + + ChipLogProgress(DeviceLayer, "WiFi-PAF: publish_id: %u", mpaf_reply_info.publish_id); + ChipLogProgress(DeviceLayer, "WiFi-PAF: peer_subscribe_id: %u", mpaf_reply_info.peer_subscribe_id); + ChipLogProgress(DeviceLayer, "WiFi-PAF: peer_addr: [%02x:%02x:%02x:%02x:%02x:%02x]", mpaf_reply_info.peer_addr[0], + mpaf_reply_info.peer_addr[1], mpaf_reply_info.peer_addr[2], mpaf_reply_info.peer_addr[3], + mpaf_reply_info.peer_addr[4], mpaf_reply_info.peer_addr[5]); + mpaf_tx_info.id = mpaf_reply_info.publish_id; + mpaf_tx_info.peer_id = mpaf_reply_info.peer_subscribe_id; + memcpy(mpaf_tx_info.peer_addr, mpaf_reply_info.peer_addr, sizeof(mpaf_tx_info.peer_addr)); } void ConnectivityManagerImpl::OnNanReceive(GVariant * obj) @@ -1464,22 +1530,32 @@ void ConnectivityManagerImpl::OnNanReceive(GVariant * obj) return; } // Read the rx_info - GAutoPtr dataValueInfo(g_variant_lookup_value(obj, "nanrx_info", G_VARIANT_TYPE_BYTESTRING)); - size_t infoBufferLen; - auto infoBuffer = g_variant_get_fixed_array(dataValueInfo.get(), &infoBufferLen, sizeof(uint8_t)); + GAutoPtr dataValue; + GVariant * value; + value = g_variant_lookup_value(obj, "id", G_VARIANT_TYPE_UINT32); + dataValue.reset(value); + g_variant_get(dataValue.get(), "u", &mpaf_rx_info.id); + + value = g_variant_lookup_value(obj, "peer_id", G_VARIANT_TYPE_UINT32); + dataValue.reset(value); + g_variant_get(dataValue.get(), "u", &mpaf_rx_info.peer_id); + + char addr_str[20]; + char * paddr; + value = g_variant_lookup_value(obj, "peer_addr", G_VARIANT_TYPE_STRING); + dataValue.reset(value); + g_variant_get(dataValue.get(), "s", &paddr); + strncpy(addr_str, paddr, sizeof(addr_str)); + sscanf(addr_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &mpaf_rx_info.peer_addr[0], &mpaf_rx_info.peer_addr[1], + &mpaf_rx_info.peer_addr[2], &mpaf_rx_info.peer_addr[3], &mpaf_rx_info.peer_addr[4], &mpaf_rx_info.peer_addr[5]); - memcpy(&mpaf_nanrx_info, infoBuffer, sizeof(struct wpa_dbus_nanrx_info)); - mpaf_info.subscribe_id = mpaf_nanrx_info.id; - mpaf_info.peer_publish_id = mpaf_nanrx_info.peer_id; - memcpy(mpaf_info.peer_addr, mpaf_nanrx_info.peer_addr, 6); - if (mpaf_nanrx_info.ssi_len == 0) - { - return; - } // Read the rx_data - GAutoPtr dataValue(g_variant_lookup_value(obj, "ssi", G_VARIANT_TYPE_BYTESTRING)); size_t bufferLen; System::PacketBufferHandle buf; + + value = g_variant_lookup_value(obj, "ssi", G_VARIANT_TYPE_BYTESTRING); + dataValue.reset(value); + auto rxbuf = g_variant_get_fixed_array(dataValue.get(), &bufferLen, sizeof(uint8_t)); ChipLogProgress(DeviceLayer, "WiFi-PAF: wpa_supplicant: nan-rx: [len: %lu]", bufferLen); buf = System::PacketBufferHandle::NewWithData(rxbuf, bufferLen); @@ -1491,14 +1567,14 @@ void ConnectivityManagerImpl::OnNanReceive(GVariant * obj) PlatformMgr().PostEventOrDie(&event); } -void ConnectivityManagerImpl::OnNanSubscribeTerminated(gint term_subscribe_id, gint reason) +void ConnectivityManagerImpl::OnNanSubscribeTerminated(guint subscribe_id, gchar * reason) { - ChipLogProgress(Controller, "WiFi-PAF: Subscription terminated (%d, %d)", term_subscribe_id, reason); - if (mpresubscribe_id == (uint32_t) term_subscribe_id) + ChipLogProgress(Controller, "WiFi-PAF: Subscription terminated (%u, %s)", subscribe_id, reason); + if (mpresubscribe_id == (uint32_t) subscribe_id) { mpresubscribe_id = 0; } - if (mpaf_info.subscribe_id == (uint32_t) term_subscribe_id) + if (mpaf_info.subscribe_id == (uint32_t) subscribe_id) { mpaf_info.subscribe_id = 0; } @@ -1538,28 +1614,38 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFConnect(const SetupDiscriminator & c } std::lock_guard lock(mWpaSupplicantMutex); - GVariant * args = g_variant_new("(syyqqqv)", srv_name, srv_proto_type, is_active, ttl, freq, ssi_len, ssi_array_variant); - + GVariantBuilder builder; + GVariant * args = nullptr; + g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_add(&builder, "{sv}", "srv_name", g_variant_new_string(srv_name)); + g_variant_builder_add(&builder, "{sv}", "srv_proto_type", g_variant_new_byte(srv_proto_type)); + g_variant_builder_add(&builder, "{sv}", "active", g_variant_new_boolean(is_active)); + g_variant_builder_add(&builder, "{sv}", "ttl", g_variant_new_uint16(ttl)); + g_variant_builder_add(&builder, "{sv}", "freq", g_variant_new_uint16(freq)); + g_variant_builder_add(&builder, "{sv}", "ssi", ssi_array_variant); + args = g_variant_builder_end(&builder); wpa_fi_w1_wpa_supplicant1_interface_call_nansubscribe_sync(mWpaSupplicant.iface, args, &subscribe_id, nullptr, &err.GetReceiver()); + ChipLogProgress(DeviceLayer, "WiFi-PAF: subscribe_id: [%d]", subscribe_id); mpresubscribe_id = subscribe_id; mOnPafSubscribeComplete = onSuccess; mOnPafSubscribeError = onError; - g_signal_connect(mWpaSupplicant.iface, "nan-discoveryresult", - G_CALLBACK(+[](WpaFiW1Wpa_supplicant1Interface * proxy, gboolean success, GVariant * obj, - ConnectivityManagerImpl * self) { return self->OnDiscoveryResult(success, obj); }), + g_signal_connect(mWpaSupplicant.iface, "nandiscovery-result", + G_CALLBACK(+[](WpaFiW1Wpa_supplicant1Interface * proxy, GVariant * obj, ConnectivityManagerImpl * self) { + return self->OnDiscoveryResult(obj); + }), this); - g_signal_connect(mWpaSupplicant.iface, "nan-receive", + g_signal_connect(mWpaSupplicant.iface, "nanreceive", G_CALLBACK(+[](WpaFiW1Wpa_supplicant1Interface * proxy, GVariant * obj, ConnectivityManagerImpl * self) { return self->OnNanReceive(obj); }), this); g_signal_connect( - mWpaSupplicant.iface, "nan-subscribeterminated", - G_CALLBACK(+[](WpaFiW1Wpa_supplicant1Interface * proxy, gint term_subscribe_id, gint reason, + mWpaSupplicant.iface, "nansubscribe-terminated", + G_CALLBACK(+[](WpaFiW1Wpa_supplicant1Interface * proxy, guint term_subscribe_id, gchar * reason, ConnectivityManagerImpl * self) { return self->OnNanSubscribeTerminated(term_subscribe_id, reason); }), this); @@ -1615,13 +1701,12 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFSend(System::PacketBufferHandle && m } } - // ================================================================================================================ // Send the packets GAutoPtr err; gchar peer_mac[18]; - snprintf(peer_mac, sizeof(peer_mac), "%02x:%02x:%02x:%02x:%02x:%02x", mpaf_info.peer_addr[0], mpaf_info.peer_addr[1], - mpaf_info.peer_addr[2], mpaf_info.peer_addr[3], mpaf_info.peer_addr[4], mpaf_info.peer_addr[5]); + snprintf(peer_mac, sizeof(peer_mac), "%02x:%02x:%02x:%02x:%02x:%02x", mpaf_tx_info.peer_addr[0], mpaf_tx_info.peer_addr[1], + mpaf_tx_info.peer_addr[2], mpaf_tx_info.peer_addr[3], mpaf_tx_info.peer_addr[4], mpaf_tx_info.peer_addr[5]); GVariant * ssi_array_variant = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, msgBuf->Start(), msgBuf->DataLength(), sizeof(guint8)); if (ssi_array_variant == nullptr) @@ -1631,10 +1716,16 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFSend(System::PacketBufferHandle && m } std::lock_guard lock(mWpaSupplicantMutex); - GVariant * args = g_variant_new("(yysqv)", mpaf_info.subscribe_id, mpaf_info.peer_publish_id, peer_mac, msgBuf->DataLength(), - ssi_array_variant); - + GVariantBuilder builder; + GVariant * args = nullptr; + g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_add(&builder, "{sv}", "handle", g_variant_new_uint32(mpaf_tx_info.id)); + g_variant_builder_add(&builder, "{sv}", "req_instance_id", g_variant_new_uint32(mpaf_tx_info.peer_id)); + g_variant_builder_add(&builder, "{sv}", "peer_addr", g_variant_new_string(peer_mac)); + g_variant_builder_add(&builder, "{sv}", "ssi", ssi_array_variant); + args = g_variant_builder_end(&builder); wpa_fi_w1_wpa_supplicant1_interface_call_nantransmit_sync(mWpaSupplicant.iface, args, nullptr, &err.GetReceiver()); + ChipLogProgress(Controller, "WiFi-PAF: Outbound message (%lu) done", msgBuf->DataLength()); return ret; } diff --git a/src/platform/Linux/ConnectivityManagerImpl.h b/src/platform/Linux/ConnectivityManagerImpl.h index 639b9334a76e44..6e3bf88b232d5d 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.h +++ b/src/platform/Linux/ConnectivityManagerImpl.h @@ -145,10 +145,10 @@ class ConnectivityManagerImpl final : public ConnectivityManager, OnConnectionErrorFunct onError); CHIP_ERROR _WiFiPAFCancelConnect(); CHIP_ERROR _WiFiPAFCancelIncompleteConnect(); - void OnDiscoveryResult(gboolean success, GVariant * obj); - void OnReplied(gboolean success, GVariant * obj); + void OnDiscoveryResult(GVariant * obj); + void OnReplied(GVariant * obj); void OnNanReceive(GVariant * obj); - void OnNanSubscribeTerminated(gint term_subscribe_id, gint reason); + void OnNanSubscribeTerminated(guint subscribe_id, gchar * reason); CHIP_ERROR _WiFiPAFSend(chip::System::PacketBufferHandle && msgBuf); WiFiPAF::WiFiPAFLayer * _GetWiFiPAF(); #endif @@ -238,6 +238,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, uint8_t peer_addr[6]; bool fsd; bool fsd_gas; + uint32_t srv_proto_type; uint32_t ssi_len; }; struct wpa_dbus_reply_info @@ -245,19 +246,22 @@ class ConnectivityManagerImpl final : public ConnectivityManager, uint32_t publish_id; uint32_t peer_subscribe_id; uint8_t peer_addr[6]; + uint32_t srv_proto_type; uint32_t ssi_len; }; uint32_t mpresubscribe_id; struct wpa_dbus_discov_info mpaf_info; - struct wpa_dbus_nanrx_info + struct wpa_dbus_reply_info mpaf_reply_info; + struct wpa_dbus_nantxrx_info { uint32_t id; uint32_t peer_id; uint8_t peer_addr[6]; uint32_t ssi_len; }; - struct wpa_dbus_nanrx_info mpaf_nanrx_info; + struct wpa_dbus_nantxrx_info mpaf_rx_info; + struct wpa_dbus_nantxrx_info mpaf_tx_info; OnConnectionCompleteFunct mOnPafSubscribeComplete; OnConnectionErrorFunct mOnPafSubscribeError; @@ -265,6 +269,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void * mAppState; CHIP_ERROR _SetWiFiPAFAdvertisingEnabled(WiFiPAFAdvertiseParam & args); CHIP_ERROR _WiFiPAFPublish(WiFiPAFAdvertiseParam & args); + CHIP_ERROR _WiFiPAFUpdatePublish(); CHIP_ERROR _WiFiPAFCancelPublish(); #endif diff --git a/src/platform/Linux/dbus/wpa/DBusWpaInterface.xml b/src/platform/Linux/dbus/wpa/DBusWpaInterface.xml index e65f48208a5356..4ea5f2d9e1d7cb 100644 --- a/src/platform/Linux/dbus/wpa/DBusWpaInterface.xml +++ b/src/platform/Linux/dbus/wpa/DBusWpaInterface.xml @@ -57,57 +57,24 @@ - - + - + - - + - - + @@ -145,24 +112,22 @@ - - - + + - - - + + - - + + - - - + + + - - - + + +