Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp94457pxa; Tue, 18 Aug 2020 17:08:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ0etNNAiyIx8mkmQzjbArpTImvMwBRkAwDHb6f/qkEeV07qwCwen7PZkRQ4gKfBSAOzME X-Received: by 2002:a17:906:c1c3:: with SMTP id bw3mr23760683ejb.8.1597795733352; Tue, 18 Aug 2020 17:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597795733; cv=none; d=google.com; s=arc-20160816; b=f9A2dEtXOO4sB5TTow5eYv6N6TehtaMnNIC0lvvhaawQrsAdcayRxv62r2OhU6GDLH KQXJ0csmIjpI+C85r9SoxiWX4CNAmsgwyz9kb6E9ToVOYXpOu7sqZRZFagvxTIrFfTlY 4byyvXkS3nPWfDfh1eneWrbK2eqvoFOEeh/4pg0G8nUpkk5KEmyx46qskK3mMBH+q2YQ omKQHm2vr+gei0A2PDWloS1NfPa6sKQJv0snngq9ckO0jfqLHsI2iSidIBWm4vaHykAV gwSIXy3NoZF6lMwZm8dKAH+Xl1IKVAEMt5uHkVWqxNAR6yO6Z38puMxms+TJk9+pEIQg qMbA== 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=7X+uls88rccAT4N2V4ZR70a3gZiJwbItKIK4d+bIKUQ=; b=XUOIjWuzCw0y5o7P560/TafK4wrT+OGx9s4paqE2G7bDA6Nn+T2w+ic8q6nxUp1HjE aB8wve5dLmSnlOskbJYvxwUsk2XP0kqSz3ubXRA8n3rox89dHjpDkSrs7QYDP3414IQP umPSpbGYAO6LT9BnvNuC1qqXI5ZWEugd2XUVoRV7G8lnovglaISbV5XLt7m0fvDZTPBP Vp80gyh7o5KXDpb+SC74NJN81ghoyhwUJgz8IasSQCKYYGQ5rTHMA18S8lXC0GVbCSJ3 iJqy0J07n/MOMdsmgE2fLUAt+X3dRbZxxjgXrbburatw1g4aecVVprwDCranDVd8stcr uY/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GIu9x6bc; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z61si14356850ede.593.2020.08.18.17.08.24; Tue, 18 Aug 2020 17:08:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GIu9x6bc; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbgHRX2d (ORCPT + 99 others); Tue, 18 Aug 2020 19:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726745AbgHRX2b (ORCPT ); Tue, 18 Aug 2020 19:28:31 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63012C061389 for ; Tue, 18 Aug 2020 16:28:31 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id mt12so242136pjb.4 for ; Tue, 18 Aug 2020 16:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7X+uls88rccAT4N2V4ZR70a3gZiJwbItKIK4d+bIKUQ=; b=GIu9x6bcnut8SKqOskUyIQwIVz1Evdzq/+W0XlMxz8JDgRyipB2SlhZrb0pn7xDfMw kv11IAwUSEl875nIPXhxIUOBp4ghjxJNPWgeLTDdBp8v3T96Y8w7Xw3i4J13E2m7+tbz onGEoAuxQOr/ltOlG/5BfqcoX+F3feNEoH4wI= 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=7X+uls88rccAT4N2V4ZR70a3gZiJwbItKIK4d+bIKUQ=; b=TJIsbAlhPF/8dp+rN1RCSRlrQh13lKIfqYyvY0oGLRqz7YIAvMW/N40O4CMBBUKAIZ 1OlT1pbSosTQhUm6ulAxP4HJ+XmY47KRSKP8Q2dIb3joeNanKr+h6lC6kbZJa6S2If9w eo05waRfNWUe/D9QzEdngdb8vTUOwKr/rHUUoy26PyCDc2QKOkxtBRT7nj09EHL24P+9 N5KDMMDcrLy0KpB3IItaOwt1TPzLb7d+fJJl0OtF20/Ujw/6eAYlXW3p8CzfYlU8LX/4 WOrbXDtzj1GmncEQS77UeQo7xcV2OzsoCeFrOUs35/WfqOfCSJisrEWcGXGBIeTYSAen PfNw== X-Gm-Message-State: AOAM532jQ6kBGzMlTVDMVTsJIO6PrQADiMlqnr3aHhDDimrCzMCd6yLA sYj5iBXqi5Vg+O7E9E0hw0ZgFw== X-Received: by 2002:a17:90a:154e:: with SMTP id y14mr1863601pja.178.1597793310761; Tue, 18 Aug 2020 16:28:30 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 30sm904747pjz.24.2020.08.18.16.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 16:28:30 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi , Sonny Sasaka , Miao-chen Chou Subject: [Bluez PATCH v2 2/3] monitor: Add btmon support for Suspend and Resume events Date: Tue, 18 Aug 2020 16:28:21 -0700 Message-Id: <20200818162807.Bluez.v2.2.Id78b98210807c1326ee2c187af73a325fc97f1e1@changeid> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog In-Reply-To: <20200818232822.1645054-1-abhishekpandit@chromium.org> References: <20200818232822.1645054-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add support to pretty print Suspend and Resume mgmt events in btmon. Example: @ MGMT Event: Controller Suspended (0x002d) plen 1 Suspend state: Page scanning and/or passive scanning (2) @ MGMT Event: Controller Resumed (0x002e) plen 8 Wake reason: Remote wake due to peer device connection (2) LE Address: CD:F3:CD:13:C5:9A (OUI CD-F3-CD) Reviewed-by: Sonny Sasaka Reviewed-by: Miao-chen Chou Signed-off-by: Abhishek Pandit-Subedi --- Changes in v2: None monitor/packet.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 431a39b66..451630e04 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -13555,6 +13555,9 @@ static void mgmt_device_disconnected_evt(const void *data, uint16_t size) case 0x04: str = "Connection terminated due to authentication failure"; break; + case 0x05: + str = "Connection terminated by local host for suspend"; + break; default: str = "Reserved"; break; @@ -13782,6 +13785,54 @@ static void mgmt_device_flags_changed_evt(const void *data, uint16_t size) mgmt_print_added_device_flags("Current Flags", current_flags); } +static void mgmt_controller_suspend_evt(const void *data, uint16_t size) +{ + uint8_t state = get_u8(data); + char *str; + + switch (state) { + case 0x0: + str = "Controller running (failed to suspend)"; + break; + case 0x1: + str = "Disconnected and not scanning"; + break; + case 0x2: + str = "Page scanning and/or passive scanning"; + break; + default: + str = "Unknown suspend state"; + break; + } + + print_field("Suspend state: %s (%d)", str, state); +} + +static void mgmt_controller_resume_evt(const void *data, uint16_t size) +{ + uint8_t addr_type = get_u8(data + 6); + uint8_t wake_reason = get_u8(data + 7); + char *str; + + switch (wake_reason) { + case 0x0: + str = "Resume from non-Bluetooth wake source"; + break; + case 0x1: + str = "Wake due to unexpected event"; + break; + case 0x2: + str = "Remote wake due to peer device connection"; + break; + default: + str = "Unknown wake reason"; + break; + } + + print_field("Wake reason: %s (%d)", str, wake_reason); + mgmt_print_address(data, addr_type); +} + static const struct mgmt_data mgmt_event_table[] = { { 0x0001, "Command Complete", mgmt_command_complete_evt, 3, false }, @@ -13863,6 +13914,10 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_exp_feature_changed_evt, 20, true }, { 0x002a, "Device Flags Changed", mgmt_device_flags_changed_evt, 15, true }, + { 0x002d, "Controller Suspended", + mgmt_controller_suspend_evt, 1, true }, + { 0x002e, "Controller Resumed", + mgmt_controller_resume_evt, 8, true }, { } }; -- 2.28.0.297.g1956fa8f8d-goog