Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp5392358ybx; Sun, 10 Nov 2019 12:16:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyHZ4VEuHY3Rmb8oPIpEWE8o6fgCnAyywrjzCoPW1zKlVpMFwgAn6+wfN4lr7FQGC4SiTnT X-Received: by 2002:a05:6402:2042:: with SMTP id bc2mr22367740edb.167.1573416971537; Sun, 10 Nov 2019 12:16:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573416971; cv=none; d=google.com; s=arc-20160816; b=yC2JOpiqxEMnPDS1xYO9nNpxhQPuaDHvacAYUNMXIH3bZryzeKjBiYgdmQynrvdWdw w9zh7XxMpdZgSQPxEwwkYXVnpWKuquAc6yXd0gtEL8q9U0nWiL1KBzYockiDD01BE98B Qu/vfphjzBsRFkQBugrJpozr0Jcf0arNgoBOwfHVf/jQ+A+MeK/yIb+LJbzkUaIgjpOj wu8JT7q5Xd76uCLU3F+E8InwnM2ceSNw0O7cdUxsYFYNrT96c/FoO8fzjxgcT3aCsYXp xCSTCLHAStWaeszhCHXRQ4ojY/SNLh69VliunKCKjn5SHAJfUhqdiJOPE14ykFbjZNvB zxHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date; bh=jS/aipIj8pJ6Pi30NcSE7u/v77k5a1e+w0lrnLRrazo=; b=Qmwa6iuVu2H0WvcOwEPgvpuYM0UdeLtKjSyFcvQp3FaxzvRjh3xP2OU1ELRX6Wb1p3 tZ0ZFJU9XrLnwq+nory5M8lYdFFW3aSUWIJw1iEXrMQNepeqnst4FdDDH2S5hwHr18Ie hs4309AGBmg/ahiTx09AGYkVG7OSqSLUGMVWiJcXIULA9s2mD+o37q4TXWe1ILSSLCL4 ffs2lgK6bnLAOVqjp+7h814tjgwzuuSzigrNfGD/bKGUd8R6A9O1p+Xji+K0vPXWVDkD H4CT88cfelKkqcgNHt1uCZ5cj3Er8a3mmDKQ7jm2znnUJ6Eyvc+HMx7T51aeuW84yNHC JX1A== ARC-Authentication-Results: i=1; mx.google.com; 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 ov16si3109019ejb.274.2019.11.10.12.15.29; Sun, 10 Nov 2019 12:16:11 -0800 (PST) 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; 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 S1726882AbfKJUIv (ORCPT + 99 others); Sun, 10 Nov 2019 15:08:51 -0500 Received: from hall.aurel32.net ([195.154.113.88]:47194 "EHLO hall.aurel32.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbfKJUIv (ORCPT ); Sun, 10 Nov 2019 15:08:51 -0500 Received: from [2a01:e35:2fdd:a4e1:fe91:fc89:bc43:b814] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iTtVx-0002e4-B9 for linux-bluetooth@vger.kernel.org; Sun, 10 Nov 2019 21:08:49 +0100 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.92.3) (envelope-from ) id 1iTtVw-0002R2-TA for linux-bluetooth@vger.kernel.org; Sun, 10 Nov 2019 21:08:48 +0100 Date: Sun, 10 Nov 2019 21:08:48 +0100 From: Aurelien Jarno To: linux-bluetooth@vger.kernel.org Subject: BlueZ/mesh: RX not working after daemon restart (with workaround) Message-ID: <20191110200848.GA28864@aurel32.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi all, On my system (Raspberry PI 3), the RX path doesn't work anymore following a restart of the bluetooth-meshd daemon. I have tracked down that to the fact that the receive callbacks are setup before the HCI is fully initialized. Said otherwise, BT_HCI_CMD_LE_SET_SCAN_PARAMETERS is called before BT_HCI_CMD_RESET and the callback calling BT_HCI_CMD_LE_SET_SCAN_ENABLE is not called. This timing dependent and probably not reproducible on all hardware. I have workarounded the issue by adding a small delay between the HCI initialization and the call to node_attach_io_all(): diff --git a/mesh/mesh.c b/mesh/mesh.c index 9b2b2073b..1c06060f9 100644 --- a/mesh/mesh.c +++ b/mesh/mesh.c @@ -167,6 +167,10 @@ bool mesh_init(const char *config_dir, enum mesh_io_type type, void *opts) mesh_io_get_caps(mesh.io, &caps); mesh.max_filters = caps.max_num_filters; + for (int i = 0 ; i < 100 ; i++) { + l_main_iterate(10); + } + node_attach_io_all(mesh.io); return true; I guess there is a better way to do that by waiting for the HCI to be fully initialized before calling node_attach_io_all() or by using a callback instead. However I do not know the codebase good enough to fix that properly. Aurelien -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://www.aurel32.net