From patchwork Wed Apr 8 20:52:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11480887 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF575912 for ; Wed, 8 Apr 2020 20:53:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C7D22075E for ; Wed, 8 Apr 2020 20:53:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="Ui0VDk8f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729372AbgDHUxJ (ORCPT ); Wed, 8 Apr 2020 16:53:09 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45819 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728913AbgDHUxJ (ORCPT ); Wed, 8 Apr 2020 16:53:09 -0400 Received: by mail-lf1-f65.google.com with SMTP id f8so6202588lfe.12 for ; Wed, 08 Apr 2020 13:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bg5r2aE6Owh4lWMBQuidSHBU9dZmz8nf0T5rM6l2dLo=; b=Ui0VDk8fWlTsv2t+9vHktdZeSpsqJvHtYZAMzz5BxBLuiyh9VSKxUWz3WPnsKBMgOY Gw8oZwh4wy7EdQtqcOeJO42NtnWENbKziaEyOAIsPHBVAq0TBZ0gjqrAQVVbVNHydzgN M0Vddx3kN9EJ1+RCHF0NJjPzsxIU1ceTvIASqqITMsbz29kw8515OqP++AyQJ5neLpzT o7tNZXGTdw0dSWZriTAGpfuT7h7fSnSQH9JLQHboRUQAZfeXo+B9556E/i1WXlZyywW7 oeCtjOKyXJ8wPAKp+0azirSLp6MP9oyR9ANwbjjA2EYAkPajWkoszy/NlnqDBh52ui5E aCPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bg5r2aE6Owh4lWMBQuidSHBU9dZmz8nf0T5rM6l2dLo=; b=ONwQChK9k3m8MwWlqfy8IJDBSXyZrUdhSIOSTyDTSpf3Qi+V8S+3/udapZqANao45/ MUKtChlmJb+MJr3HELkFHwDAe94APaAMgCJzR7BRWBQ4w3XZohsSbpHduXkDRXXu8aah qJcqZfSklF+BcRA7yXbhuPo/q2/tSXN4FvpsSeYgCfwFFq5IUS6TuMgRIsKGScb6sAxI cZTiklEjuHoTtEn62G5LRgMjNb9HJPOYWirrr1zwdfJCNR6bYfQMBhnxtYFaC4fe8/9F AWoazZb7shhCM+TweuOuwUITDRRLyrUZYuUBPf3ln+rCpv/Dpuezt+vmPE6f8QYmQfZj cLjw== X-Gm-Message-State: AGi0PuZyEt2D3Jb4G7Bzd4MyF1yBJXX3AMMRHlQofaFpE8MInsILJ8Jq VTXbNx/CxSLz76ob2QGiocRsCIbytk4= X-Google-Smtp-Source: APiQypIb8VScyYlky5dYDI2jPjWLiiuZzJz0Gnyycbe6QV4bEMxZiGE7Qrdyvhf9c+w/z0YOof1D/g== X-Received: by 2002:a19:c607:: with SMTP id w7mr5632824lff.32.1586379184485; Wed, 08 Apr 2020 13:53:04 -0700 (PDT) Received: from kynes.internet.domowy (apn-37-7-76-34.dynamic.gprs.plus.pl. [37.7.76.34]) by smtp.gmail.com with ESMTPSA id r24sm14168976ljn.25.2020.04.08.13.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 13:53:03 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Cc: =?utf-8?q?Przemys=C5=82aw_Fierek?= Subject: [PATCH BlueZ 1/4] mesh: Fix invalid app_path on 'Join' Date: Wed, 8 Apr 2020 22:52:52 +0200 Message-Id: <20200408205255.45112-2-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200408205255.45112-1-michal.lowas-rzechonek@silvair.com> References: <20200408205255.45112-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Przemysław Fierek This patch fixes invalid app_path on 'Join' method call - the daemon tried to use the value of app_root API argument, while it should use path discovered by scanning result of GetManagedObjects() call. --- mesh/mesh.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mesh/mesh.c b/mesh/mesh.c index 9b3768b69..a9d5d5dea 100644 --- a/mesh/mesh.c +++ b/mesh/mesh.c @@ -72,7 +72,6 @@ struct join_data{ struct l_dbus_message *msg; struct mesh_agent *agent; char *sender; - const char *app_path; struct mesh_node *node; uint32_t disc_watch; uint8_t *uuid; @@ -445,7 +444,7 @@ static bool prov_complete_cb(void *user_data, uint8_t status, return false; owner = join_pending->sender; - path = join_pending->app_path; + path = node_get_app_path(join_pending->node); if (status == PROV_ERR_SUCCESS && !node_add_pending_local(join_pending->node, info)) @@ -551,7 +550,6 @@ static struct l_dbus_message *join_network_call(struct l_dbus *dbus, join_pending->sender = l_strdup(sender); join_pending->msg = l_dbus_message_ref(msg); - join_pending->app_path = app_path; /* Try to create a temporary node */ node_join(app_path, sender, join_pending->uuid, node_init_cb); From patchwork Wed Apr 8 20:52:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11480889 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3E641805 for ; Wed, 8 Apr 2020 20:53:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0840206F7 for ; Wed, 8 Apr 2020 20:53:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="Dtohcq88" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729435AbgDHUxJ (ORCPT ); Wed, 8 Apr 2020 16:53:09 -0400 Received: from mail-lj1-f178.google.com ([209.85.208.178]:43673 "EHLO mail-lj1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729318AbgDHUxJ (ORCPT ); Wed, 8 Apr 2020 16:53:09 -0400 Received: by mail-lj1-f178.google.com with SMTP id g27so9142993ljn.10 for ; Wed, 08 Apr 2020 13:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wb2l5MlE5PDSa/vPETkuDpxKceTJxVH4B42sQMrryig=; b=Dtohcq88cp3mbc2xBG8HFDICPDxPOnk36R65EceeByu6izAKKmSSlJ2KOVUcSThiNU 8fVwXiVgrKWJj1jT5DrE6ef5qSGlst8gY7Lkj+dmO57AZeZ1QdiieHjoStO6O1Aci6q1 CflL6av9edLeDwG0E0MaQZUKn9FkiGn2IxRKdJ27ZkAPjTwJ89g+ZHr1CffkY90Ztn1f 96O92heHqn3h/RvcjYyq+1PQ3OSMxYxqshxefx9myQwa7JqGgd5RuTEi+KP2ihTBfoT+ QHYrYQPOSomd7VmWFHg6VKXb7jylKzXlEoUoRey7v/APioKaAzS7lI03VmRkeqOANcYi 0g/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wb2l5MlE5PDSa/vPETkuDpxKceTJxVH4B42sQMrryig=; b=gCQaGpBGNTj7ogmYBtBaj+iB2K39YSRj8mdWL+isaFFEDELaQTGEqdyCDklk1lUo63 Sn3YcQJtJl/R5ZD7sPXA1vXq6Nrs9RLSvIZjwuaieg20iHaWIlnSQK5irL14HDUpPo9r encmP5K4voUIjAlUajCRsmH9mY3XTDJ1Ei4/inoboHpFcRZeEJ1Ad0otqW0/EZD+RE3C Px8/shxIxyYOubNrV540mxrZBia3+H6cyN6vOuQkzPCaIadTde86yD0RwrraqaK3MMor pP5gB6QZM0yNY8+yL/oTLr2stelXZhZzh8YJJKjXUgqTT1KdTDmm+7qV53E9iyJ1z5u6 X1/w== X-Gm-Message-State: AGi0Puaw+84gzoBR8taLgygFz5eld3L4rKdRNY2bfg35+yvX2TkvRfi6 SAZSnxoAYmrFy+u98n86XfOcejP7Eig= X-Google-Smtp-Source: APiQypKaUCRLwiPP0S/jafkndC6hfIE3mWzLRV3AwYvdsezIRVUT/vm/qP2W0mOxeEV8oQk6lXNZdQ== X-Received: by 2002:a2e:b610:: with SMTP id r16mr6269823ljn.254.1586379185585; Wed, 08 Apr 2020 13:53:05 -0700 (PDT) Received: from kynes.internet.domowy (apn-37-7-76-34.dynamic.gprs.plus.pl. [37.7.76.34]) by smtp.gmail.com with ESMTPSA id r24sm14168976ljn.25.2020.04.08.13.53.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 13:53:05 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/4] doc/mesh: Change API to deliver tokens via JoinComplete Date: Wed, 8 Apr 2020 22:52:53 +0200 Message-Id: <20200408205255.45112-3-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200408205255.45112-1-michal.lowas-rzechonek@silvair.com> References: <20200408205255.45112-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org If Application is not be able to reliably store the token, the daemon will end up with a uncontrollable node in its database. Let's fix the issue by always delivering tokens using JoinComplete call, and expecting a reply - if the application return an error, daemon will get rid of the node. --- doc/mesh-api.txt | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt index c7374703b..08e34096d 100644 --- a/doc/mesh-api.txt +++ b/doc/mesh-api.txt @@ -29,6 +29,10 @@ Methods: therefore attempting to call this function using already registered UUID results in an error. + When provisioning finishes, the daemon will call either + JoinComplete or JoinFailed method on object implementing + org.bluez.mesh.Application1 interface. + PossibleErrors: org.bluez.mesh.Error.InvalidArguments org.bluez.mesh.Error.AlreadyExists, @@ -123,7 +127,7 @@ Methods: PossibleErrors: org.bluez.mesh.Error.InvalidArguments - uint64 token CreateNetwork(object app_root, array{byte}[16] uuid) + void CreateNetwork(object app_root, array{byte}[16] uuid) This is the first method that an application calls to become a Provisioner node, and a Configuration Client on a newly @@ -155,11 +159,14 @@ Methods: unicast address (0x0001), and create and assign a net_key as the primary network net_index (0x000). + When creation finishes, the daemon will call JoinComplete method + on object implementing org.bluez.mesh.Application1 interface. + PossibleErrors: org.bluez.mesh.Error.InvalidArguments org.bluez.mesh.Error.AlreadyExists, - uint64 token Import(object app_root, array{byte}[16] uuid, + void Import(object app_root, array{byte}[16] uuid, array{byte}[16] dev_key, array{byte}[16] net_key, uint16 net_index, dict flags, uint32 iv_index, uint16 unicast) @@ -204,11 +211,8 @@ Methods: The unicast parameter is the primary unicast address of the imported node. - The returned token must be preserved by the application in - order to authenticate itself to the mesh daemon and attach to - the network as a mesh node by calling Attach() method or - permanently remove the identity of the mesh node by calling - Leave() method. + When import finishes, the daemon will call JoinComplete method + on object implementing org.bluez.mesh.Application1 interface. PossibleErrors: org.bluez.mesh.Error.InvalidArguments, @@ -770,6 +774,10 @@ Methods: permanently remove the identity of the mesh node by calling Leave() method. + If this method returns an error, the daemon will assume that the + application failed to preserve the token, and will remove the + freshly created node. + void JoinFailed(string reason) This method is called when the node provisioning initiated by From patchwork Wed Apr 8 20:52:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11480893 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 716F592A for ; Wed, 8 Apr 2020 20:53:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E0BC206F7 for ; Wed, 8 Apr 2020 20:53:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="UeC+3E6U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729466AbgDHUxM (ORCPT ); Wed, 8 Apr 2020 16:53:12 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45823 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729388AbgDHUxL (ORCPT ); Wed, 8 Apr 2020 16:53:11 -0400 Received: by mail-lf1-f66.google.com with SMTP id f8so6202662lfe.12 for ; Wed, 08 Apr 2020 13:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dmoq1matlkF8+x8jlpWK2uxDi9B6sQ2NRp/AlEHi1sQ=; b=UeC+3E6UBeXr3M9G+pHiYFpfGYAMkd5428xaJJHoxvwWAgMNZb2r4LHDQ+jdwve+97 DjJvb9C0PteWUOVG15exL/j1rgtaCeCLnj6Ts0OumitHzXKy+ptfOaaWjp/+f4woi1++ QxuwwQiXlCNKvj7BYpj+mr7SK0dljsg0U0qIkgkQkRfvJPl3oiUaAkvuifr4p/x3I6Di BTUyWPcQIM5xiaz6usXlUPlpyM0WL0APlaizGlk2UNSwtWNS/0yZ6PerLHg2YfSx2Igx KoLQtNf1B5MffwxbSfhI4YLFuAfwRxlppQo/dA/PC2eg5zkK6Vm2TjKO84tkqqFbQu4a vnTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dmoq1matlkF8+x8jlpWK2uxDi9B6sQ2NRp/AlEHi1sQ=; b=DwcYe5diO870oJ8uLiUSFpkIiPo4ps1V7nmcs3Yx6Oa030Y494Vu0grYx0X9bl87hr D3HUQFZX5i83uhh2hlUypaLvU4G5twpxiQ8R82noEwoBj6+xhYlfnnsnTHsOywu67WsR 9ZebqcIygZ5ypbSPG4V7muNx2VrPBuSwf4vcTcQFXJAuqbiGR1tkucPMeDIyIa7fLGCp 2rStMUXpRfon/OnJUysPalb8R9r2H1xbWe+txGAM5nP/fsXeIBaD+XgYRpXJYfyNgarb YyFFYwAsvvGwhoR2SKJN4QpKmH6KLXNOIbl6y9FewJj8GA8mHjeNZGgSH7wR/1+Vf+XJ BrSA== X-Gm-Message-State: AGi0PuatF6N0dJuZqbTnqt0B0Isy0yHGcDntSaWcfxudUXjZDct9jkds NitCmAOlwZnRS0s5TsaIJ08pJ8K/SaY= X-Google-Smtp-Source: APiQypI48wkIMKJVoDBFfsVZtrl/EuxxSQ2NmbRdWdp+Ssqju9e0RChBBflrhFm7cShYLJO8NAPvVA== X-Received: by 2002:ac2:58ee:: with SMTP id v14mr5320420lfo.25.1586379186802; Wed, 08 Apr 2020 13:53:06 -0700 (PDT) Received: from kynes.internet.domowy (apn-37-7-76-34.dynamic.gprs.plus.pl. [37.7.76.34]) by smtp.gmail.com with ESMTPSA id r24sm14168976ljn.25.2020.04.08.13.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 13:53:06 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Cc: =?utf-8?q?Przemys=C5=82aw_Fierek?= Subject: [PATCH BlueZ 3/4] mesh: Change API to deliver tokens via JoinComplete Date: Wed, 8 Apr 2020 22:52:54 +0200 Message-Id: <20200408205255.45112-4-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200408205255.45112-1-michal.lowas-rzechonek@silvair.com> References: <20200408205255.45112-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Przemysław Fierek This patch changes Import and CreateNetwork API to deliver tokens via the JoinComplete method call. When application doesn't raise any error during handling JoinComplete then it is assumed that the token has been saved, otherwise when application replies with an error message then the node is removed. --- mesh/mesh.c | 63 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/mesh/mesh.c b/mesh/mesh.c index a9d5d5dea..6ffeb0c2b 100644 --- a/mesh/mesh.c +++ b/mesh/mesh.c @@ -429,6 +429,17 @@ static void send_join_failed(const char *owner, const char *path, free_pending_join_call(true); } +static void prov_join_complete_reply_cb(struct l_dbus_message *message, + void *user_data) +{ + bool failed = l_dbus_message_is_error(message); + + if (!failed) + node_attach_io(join_pending->node, mesh.io); + + free_pending_join_call(failed); +} + static bool prov_complete_cb(void *user_data, uint8_t status, struct mesh_prov_node_info *info) { @@ -455,7 +466,6 @@ static bool prov_complete_cb(void *user_data, uint8_t status, return false; } - node_attach_io(join_pending->node, mesh.io); token = node_get_token(join_pending->node); msg = l_dbus_message_new_method_call(dbus, owner, path, @@ -463,10 +473,8 @@ static bool prov_complete_cb(void *user_data, uint8_t status, "JoinComplete"); l_dbus_message_set_arguments(msg, "t", l_get_be64(token)); - - l_dbus_send(dbus, msg); - - free_pending_join_call(false); + l_dbus_send_with_reply(dbus, msg, + prov_join_complete_reply_cb, NULL, NULL); return true; } @@ -660,11 +668,28 @@ static struct l_dbus_message *leave_call(struct l_dbus *dbus, return l_dbus_message_new_method_return(msg); } +static void create_join_complete_reply_cb(struct l_dbus_message *message, + void *user_data) +{ + struct mesh_node *node = user_data; + + if (l_dbus_message_is_error(message)) { + node_remove(node); + return; + } + + node_attach_io(node, mesh.io); +} + static void create_node_ready_cb(void *user_data, int status, struct mesh_node *node) { + struct l_dbus *dbus = dbus_get_bus(); struct l_dbus_message *reply; struct l_dbus_message *pending_msg; + struct l_dbus_message *msg; + const char *owner; + const char *path; const uint8_t *token; pending_msg = l_queue_find(pending_queue, simple_match, user_data); @@ -673,20 +698,28 @@ static void create_node_ready_cb(void *user_data, int status, if (status != MESH_ERROR_NONE) { reply = dbus_error(pending_msg, status, NULL); - goto done; - } - node_attach_io(node, mesh.io); + l_dbus_send(dbus_get_bus(), reply); + l_queue_remove(pending_queue, pending_msg); + return; + } reply = l_dbus_message_new_method_return(pending_msg); + + l_dbus_send(dbus, reply); + l_queue_remove(pending_queue, pending_msg); + + owner = l_dbus_message_get_sender(pending_msg); + path = node_get_app_path(node); token = node_get_token(node); - l_debug(); - l_dbus_message_set_arguments(reply, "t", l_get_be64(token)); + msg = l_dbus_message_new_method_call(dbus, owner, path, + MESH_APPLICATION_INTERFACE, + "JoinComplete"); -done: - l_dbus_send(dbus_get_bus(), reply); - l_queue_remove(pending_queue, pending_msg); + l_dbus_message_set_arguments(msg, "t", l_get_be64(token)); + l_dbus_send_with_reply(dbus, msg, + create_join_complete_reply_cb, node, NULL); } static struct l_dbus_message *create_network_call(struct l_dbus *dbus, @@ -840,11 +873,11 @@ static void setup_network_interface(struct l_dbus_interface *iface) "token"); l_dbus_interface_method(iface, "CreateNetwork", 0, create_network_call, - "t", "oay", "token", "app", "uuid"); + "", "oay", "app", "uuid"); l_dbus_interface_method(iface, "Import", 0, import_call, - "t", "oayayayqa{sv}uq", "token", + "", "oayayayqa{sv}uq", "app", "uuid", "dev_key", "net_key", "net_index", "flags", "iv_index", "unicast"); From patchwork Wed Apr 8 20:52:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11480891 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 011371805 for ; Wed, 8 Apr 2020 20:53:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D18572075E for ; Wed, 8 Apr 2020 20:53:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="nHaAmjpv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729447AbgDHUxL (ORCPT ); Wed, 8 Apr 2020 16:53:11 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:37929 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729318AbgDHUxL (ORCPT ); Wed, 8 Apr 2020 16:53:11 -0400 Received: by mail-lf1-f67.google.com with SMTP id l11so6241126lfc.5 for ; Wed, 08 Apr 2020 13:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ydMliBbxes0uQbQu/87VkkNAw7EAWP1FEHNcgBKJZGY=; b=nHaAmjpvINawhUufhq+BoQJ7UaG2ezYzzGz3Iy04jGSixP2/rnuyr0WJzG15kjPof3 IfMOtQ9ZYoblGpz7bdHBz3y/jWuLWv2TvYAyvwch16WaHoHEcay520p1fOfiFzIEyXiC GUIk1OYTgmOwR2kJ2+tSc3rQUby/n1X+onzGjI4QxQ14vZSVvYaOvu4hlC9Lh0v0WQcv nvEis4AN9X7URN55hIKHohtj25XtjbLCDeEbUzVSBDg/TUMHkhdGHCQWTBC63T3nLsD9 XB9DW1uNeQs1un7GakTHJRPVDz+bZZhGi1wurVWSRV5KkL5Q6DHk512QXggTDTBtKONS EEhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ydMliBbxes0uQbQu/87VkkNAw7EAWP1FEHNcgBKJZGY=; b=T8zuOCzmoJZf/IKB+/5kXDmnU4n2lEI16XkBZhMoN2Ca2PiMtTfGPlbvFyWlx6fzte VduB1LXT1AVx8Ve7ws7tkr9kq2E3wWmASDCWVyuatt6cwssAotFE88DJmDelD1bJSLoj BZy/2UXAvjtvDJCTkP6AsUHIA2IcF2AfJ7MwYwjYhF5Xzp074EEiFAGbMXT8kiv6W3n4 YdOwFBafl06yLBj8TPad2dI7L3LHSyLwh7OqltOq++tiEpwB1XjMaf0HviPjFfBoBR46 ur4n8TKNI4Xbl4u9IU3qnwCTxAIQ520F0t438S/RhzDOnXRZJ88ejnphWgRl6mcknwbk Ecaw== X-Gm-Message-State: AGi0PuYkuwjpNq8Dsuxjq+ycljV93YTUj63MxzUO2bEAU8Z/JkutR8PX wkqDYZhpYAvdl8siIOF4N0GkGeqQm04= X-Google-Smtp-Source: APiQypLLlfCUcdF38evb4csYqawl3/EiZh/CMYtCXOoU2jrYJ3Ykkx//nIldxePI8p79nAergL/8Mg== X-Received: by 2002:ac2:4350:: with SMTP id o16mr5676730lfl.136.1586379187990; Wed, 08 Apr 2020 13:53:07 -0700 (PDT) Received: from kynes.internet.domowy (apn-37-7-76-34.dynamic.gprs.plus.pl. [37.7.76.34]) by smtp.gmail.com with ESMTPSA id r24sm14168976ljn.25.2020.04.08.13.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 13:53:07 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Cc: =?utf-8?q?Przemys=C5=82aw_Fierek?= Subject: [PATCH BlueZ 4/4] tools/mesh-cfgclient: Add waiting for 'JoinComplete' Date: Wed, 8 Apr 2020 22:52:55 +0200 Message-Id: <20200408205255.45112-5-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200408205255.45112-1-michal.lowas-rzechonek@silvair.com> References: <20200408205255.45112-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Przemysław Fierek --- tools/mesh-cfgclient.c | 73 ++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 5b018eb4a..c5b6938ed 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -707,44 +707,13 @@ static void attach_node_setup(struct l_dbus_message *msg, void *user_data) static void create_net_reply(struct l_dbus_proxy *proxy, struct l_dbus_message *msg, void *user_data) { - char *str; - uint64_t tmp; - if (l_dbus_message_is_error(msg)) { const char *name; l_dbus_message_get_error(msg, &name, NULL); l_error("Failed to create network: %s", name); return; - - } - - if (!l_dbus_message_get_arguments(msg, "t", &tmp)) - return; - - local = l_new(struct meshcfg_node, 1); - local->token.u64 = l_get_be64(&tmp); - str = l_util_hexstring(&local->token.u8[0], 8); - bt_shell_printf("Created new node with token %s\n", str); - l_free(str); - - if (!mesh_db_create(cfg_fname, local->token.u8, - "Mesh Config Client Network")) { - l_free(local); - local = NULL; - return; } - - mesh_db_set_addr_range(low_addr, high_addr); - keys_add_net_key(PRIMARY_NET_IDX); - mesh_db_net_key_add(PRIMARY_NET_IDX); - - remote_add_node(app.uuid, 0x0001, 1, PRIMARY_NET_IDX); - mesh_db_add_node(app.uuid, 0x0001, 1, PRIMARY_NET_IDX); - - l_dbus_proxy_method_call(net_proxy, "Attach", attach_node_setup, - attach_node_reply, NULL, - NULL); } static void create_net_setup(struct l_dbus_message *msg, void *user_data) @@ -1727,7 +1696,7 @@ static struct l_dbus_message *add_node_fail_call(struct l_dbus *dbus, static void setup_prov_iface(struct l_dbus_interface *iface) { l_dbus_interface_method(iface, "ScanResult", 0, scan_result_call, "", - "naya{sv}", "rssi", "data", "options"); + "naya{sv}", "rssi", "data", "options"); l_dbus_interface_method(iface, "RequestProvData", 0, req_prov_call, "qq", "y", "net_index", "unicast", "count"); @@ -1779,6 +1748,43 @@ static bool crpl_getter(struct l_dbus *dbus, return true; } +static struct l_dbus_message *join_complete(struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + char *str; + uint64_t tmp; + + if (!l_dbus_message_get_arguments(message, "t", &tmp)) + return l_dbus_message_new_error(message, dbus_err_args, NULL); + + local = l_new(struct meshcfg_node, 1); + local->token.u64 = l_get_be64(&tmp); + str = l_util_hexstring(&local->token.u8[0], 8); + bt_shell_printf("Created new node with token %s\n", str); + l_free(str); + + if (!mesh_db_create(cfg_fname, local->token.u8, + "Mesh Config Client Network")) { + l_free(local); + local = NULL; + return l_dbus_message_new_error(message, dbus_err_fail, NULL); + } + + mesh_db_set_addr_range(low_addr, high_addr); + keys_add_net_key(PRIMARY_NET_IDX); + mesh_db_net_key_add(PRIMARY_NET_IDX); + + remote_add_node(app.uuid, 0x0001, 1, PRIMARY_NET_IDX); + mesh_db_add_node(app.uuid, 0x0001, 1, PRIMARY_NET_IDX); + + l_dbus_proxy_method_call(net_proxy, "Attach", attach_node_setup, + attach_node_reply, NULL, + NULL); + + return l_dbus_message_new_method_return(message); +} + static void setup_app_iface(struct l_dbus_interface *iface) { l_dbus_interface_property(iface, "CompanyID", 0, "q", cid_getter, @@ -1789,6 +1795,9 @@ static void setup_app_iface(struct l_dbus_interface *iface) NULL); l_dbus_interface_property(iface, "CRPL", 0, "q", crpl_getter, NULL); + l_dbus_interface_method(iface, "JoinComplete", 0, join_complete, + "", "t", "token"); + /* TODO: Methods */ }