Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1989158ybb; Thu, 9 Apr 2020 12:49:36 -0700 (PDT) X-Google-Smtp-Source: APiQypKNthFy4jT2/6xrTChiqbdmVrTTEi+KgSRCZPsMhGz4wVKJyTi6ols2s/YPvjuzDKZ9CFwO X-Received: by 2002:a0c:c187:: with SMTP id n7mr1872695qvh.240.1586461776236; Thu, 09 Apr 2020 12:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586461776; cv=none; d=google.com; s=arc-20160816; b=G9gFxKTWfMa6G9TZnI+i6QXMb3X/3MXEhhRYvkBJGFg8TFDJY6CDhKhjHO3HxLgeMM YgYhS7VZjjYInlRDCvPUC99lgXFT2tSRQEFNPn5WHsTIMWDOBCOTthTo/kKwUXxfanzZ 0oO1JrdqV/0B12Z8QT4CvvnT78gUlur7Rv82V1orcN8Si4kUWeek9MoYjWEMAjgp8iLx XvwnxQwmz6CXoIpVFXBroESwXw4vczX2AxGrW8RZ0hCXq5J8IAPbliTkg7+fDva6Qy5l AeOp0Xfxx9nWMPcUalQZz4UO+t5Bif6FYxgCTcRv2HLciVVw/6mmMG7vVfW3pMpk5CIi mMhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f//NAxK7NVQLTDEd9r9V523X8NWIwjJbsxXRfwRbPxg=; b=MkT5hqa4EtJercjfy7Dx2ZMO9vn4rL9zAe/HYgFu5jzdIiq9GudNQ9p8U2S+y5t0vN 29Lk0pyYTHj+zCz/rcnj1gS11TDnZT25gdwl5BP0t/cH9GJb9PMNAqEnk89RwcvL96XK 5jdAlI2wnC3EPi7zMY15aqafhtBONI5MeWXA+eu1Stor9naZYe60kRbEYeFl2m2pOit8 NmjHJA/BPMIrN99KzUVOuZQfUG48fdMWTNj3XHC20ZRt7IH0o+ig4DAD+wPdzXp0I/8j JAaAEqt4/Amh+gC95Gfv+dbyVp1y9r3EzhGIU1qcJ3dfmC2y6pxHoNSKXUcOipYmDVX2 g2hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=ZHWxYUK3; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si6152259qti.20.2020.04.09.12.49.11; Thu, 09 Apr 2020 12:49:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=ZHWxYUK3; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725970AbgDITrt (ORCPT + 99 others); Thu, 9 Apr 2020 15:47:49 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42438 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726875AbgDITrt (ORCPT ); Thu, 9 Apr 2020 15:47:49 -0400 Received: by mail-lj1-f195.google.com with SMTP id q19so971836ljp.9 for ; Thu, 09 Apr 2020 12:47:46 -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=f//NAxK7NVQLTDEd9r9V523X8NWIwjJbsxXRfwRbPxg=; b=ZHWxYUK39uU/dyfu/Z2V04FsoVQOI3NCWzyslqo3K9N5JFvbUPxqHD5ipq8yxXo/8M uwyCucbThnOaVYbV8Kv+7pSs7PG4r4PjMDtPcbIJYLOyZ3bi7aj56Vqs8N5dTCN9UKvB /HtCqODLBGmU9KKRG5Sq0CkBWWiR6tEARpjvvRoAvDdiMk1vd4HUUyQKQrPNw1LYfI7s x+PjyKSlxlGwPF6KesFHQkkNgdaPHHX4jdHQ9/3YPzuspwFL7N+SS3fVgFcnm+4BwIvl 2WqRWuRRF3lFmzNeWBScPg+51q7ci6i/ikC1GWXp5FrVVvAUyQEDmpq6czjMxje0NQ27 qCjw== 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=f//NAxK7NVQLTDEd9r9V523X8NWIwjJbsxXRfwRbPxg=; b=Mxv8jLUpTn1f1n9CoYyKo7BQ4WdF0Pyr7+YGy7HbL5AgCiGcb6fx+sCGQR/f5KukaV 3oHgjMcnYimr9HK5eXwUpPP3EP4RsfyvO4DJQm6kXwQLy5/l73OTKpjrAVjvzGxM3cwR QR8xEqcVgz0meLbSl8gnefJsqrhlGOtLX9xSZM0d2f6Ys+vUAvtD/dvACoBtrpXJxeSF l3d7rKPe4KOTMY+NYyYzTM8AgmGE9aESgxVty3P7okSaSxwxB+eaEApF4GJXzDhXr5yX eJ3lEHKGikJ9T1ciR9UFmfaKPKuDw5GWZXYYIOWj1LO97DMqix6KVAnTrAxCOXKdGmaa 3iEg== X-Gm-Message-State: AGi0PuaqEsJ/6dh0c/CnWYYWKaS5hEYPSJl8py2lXlwxB5u/8Tp+/r7f cKVUpCPg45OEFRFMQd6ctRJY8t+G0ko= X-Received: by 2002:a2e:8195:: with SMTP id e21mr858581ljg.49.1586461665772; Thu, 09 Apr 2020 12:47:45 -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 l13sm15915895ljc.84.2020.04.09.12.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2020 12:47:45 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Cc: =?UTF-8?q?Przemys=C5=82aw=20Fierek?= Subject: [PATCH BlueZ v2 4/4] tools/mesh-cfgclient: Add waiting for 'JoinComplete' Date: Thu, 9 Apr 2020 21:47:33 +0200 Message-Id: <20200409194733.18039-5-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200409194733.18039-1-michal.lowas-rzechonek@silvair.com> References: <20200409194733.18039-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 78 +++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 5b018eb4a..6db65cd49 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,48 @@ static bool crpl_getter(struct l_dbus *dbus, return true; } +static void attach_node(void *user_data) +{ + l_dbus_proxy_method_call(net_proxy, "Attach", attach_node_setup, + attach_node_reply, NULL, + NULL); +} + +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_idle_oneshot(attach_node, 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 +1800,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 */ } -- 2.26.0