Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2929610rwe; Mon, 29 Aug 2022 02:54:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5AkxtKSNStQXu2QX32V3ffrck/IsIzFW4GljJ9nTgiPSullNEbqowfE+yzM1R2Bzi4ztCW X-Received: by 2002:a17:90b:3c4e:b0:1fd:ce4e:94bb with SMTP id pm14-20020a17090b3c4e00b001fdce4e94bbmr4412974pjb.105.1661766845063; Mon, 29 Aug 2022 02:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661766845; cv=none; d=google.com; s=arc-20160816; b=LlBxfP16hvCfTFCtGf/1a6cH/UIGlT122RtSPT067aYmGLWMY56jmN1L2NrP7B3+B4 +fEczw/FX3hBqZ7SxSsgh12ygiZWPjaM+37YH8ftKXZRMtxOCMkKB+hzHlJ/mmls9wMs AYr1GMjLaap22J2e+a1VYyox9Axu7w4S8ZE0DqVALKWVCJhXftKi7utCbbxSI2Un8mMm LHhDuLhLNcdRRf5Y4o8xPyeoL0EC07BmItVA108trUXVhdEHlw2ZrZVRSrQ4/walCfnj PE0WNIfCP5l4XdYkfDJRJByh0VwegcjjyWUB33xc+bdU3E6qnLAlBzarhwtY2nFOi0lN zLhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=5lMUfJQvTIcFM0Jm+9pBy4MMmk6xE2qJkKwU1Eko6ZA=; b=NWGZ8DkWCB1fU0wk8R7sLDf9KRXQKjpQv4i8Mj+SyB2J2sbU8fQdRFvcRU40HewoQq hciBBYYsa1FoqlwYzUzQR3uiu64qVSvSS5/z2e7In+l8oUZLVe78jc8XP8goULPh+s1C iv/tg36OPGQhIZv5QQGIBLWHV0x/WEQ+SdOZ4dkfcVue+36ABNqBa6HdrK1SoMW3nfOL H072MxxTery8eu4ZRL3Gb52Ys21GIIEiKkHg9zqoPEvS1ZD+uYE8W99596fLkSlxO8ra tKCxlkWpP6j2kZo5CH9dgNWhuJg73GsVHvLVBDwUT/8SI3RV/Q+93yT3+ZH6wlm79FTs gwww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q190-20020a632ac7000000b0042ad04f3686si8967800pgq.616.2022.08.29.02.53.39; Mon, 29 Aug 2022 02:54:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229472AbiH2Jrr convert rfc822-to-8bit (ORCPT + 99 others); Mon, 29 Aug 2022 05:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbiH2Jrp (ORCPT ); Mon, 29 Aug 2022 05:47:45 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B87EB5E31F for ; Mon, 29 Aug 2022 02:47:38 -0700 (PDT) Received: (Authenticated sender: hadess@hadess.net) by mail.gandi.net (Postfix) with ESMTPSA id 2D4E6E0004; Mon, 29 Aug 2022 09:47:35 +0000 (UTC) Message-ID: <039331637535e9cb0c1f9df777cd18d5e34cfe27.camel@hadess.net> Subject: Re: [PATCH] adapter: Implement PowerState property From: Bastien Nocera To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Date: Mon, 29 Aug 2022 11:47:35 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Fri, 2022-08-26 at 11:50 -0700, Luiz Augusto von Dentz wrote: > Hi Bastien, > > On Thu, Aug 25, 2022 at 6:40 AM Bastien Nocera > wrote: > > > > This property should allow any program to show the transitional > > state, > > not just the one that requested the change, and will also show > > transitional states that were the results of other system changes, > > like > > rfkill changes. > > --- > > > > Downstream bug in gnome-bluetooth: > > https://gitlab.gnome.org/GNOME/gnome-bluetooth/-/issues/121 > > > > Note that this probably doesn't handle multiple, conflicting > > requests > > for power on, or power off. Is there a good way to protect against > > that? > > > >  client/main.c       |  1 + > >  doc/adapter-api.txt | 14 ++++++++++ > >  src/adapter.c       | 66 > > +++++++++++++++++++++++++++++++++++++++++++++ > >  3 files changed, 81 insertions(+) > > > > diff --git a/client/main.c b/client/main.c > > index 19139d15b..ddd97c23c 100644 > > --- a/client/main.c > > +++ b/client/main.c > > @@ -981,6 +981,7 @@ static void cmd_show(int argc, char *argv[]) > >         print_property(adapter->proxy, "Alias"); > >         print_property(adapter->proxy, "Class"); > >         print_property(adapter->proxy, "Powered"); > > +       print_property(adapter->proxy, "PowerState"); > >         print_property(adapter->proxy, "Discoverable"); > >         print_property(adapter->proxy, "DiscoverableTimeout"); > >         print_property(adapter->proxy, "Pairable"); > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > > index 48466ab75..5bdb9c34e 100644 > > --- a/doc/adapter-api.txt > > +++ b/doc/adapter-api.txt > > @@ -269,6 +269,20 @@ Properties string Address [readonly] > >                         restart or unplugging of the adapter it > > will reset > >                         back to false. > > > > +               string PowerState [readonly] > > + > > +                       The power state of an adapter. > > + > > +                       The power state will show whether the > > adapter is > > +                       turning off, or turning on, as well as > > being on > > +                       or off. > > + > > +                       Possible values: > > +                               "on" - powered on > > +                               "off" - powered off > > +                               "turning-on" - transitioning from > > "off" to "on" > > +                               "turning-off" - transitioning from > > "on" to "off" > > This changes need to be split in its own patch, You want the docs changes to be a separate patch? I can do that, but I thought that having documentation changes be added along with the property itself would have been desirable. > also not long ago I > was discussing with Marcel about MGMT power states vs rfkill, they > don't seem to be inline with each other, while rfkill does reflect on > the MGMT interface powered states doesn't which means the driver are > not aware of it since afaik the MGMT states are not communicated back > to the driver, so perhaps we should reflect this distinction on > PowerState with a dedicated state for rfkill or we start using rfkill > ourselves directly via daemon using a dedicated property. The rfkill calls made by GNOME are usually sent to all the rfkill devices, rather than targeted at blocking a single adapter. So the adapter state isn't super interesting in this case, as all the devices will be either blocked (computer with no platform rfkill), or gone from the USB bus (computer with a platform rfkill). The good thing about using a string property here is that we can extend it. One thing we can do though, to make extensibility easier, is take a leaf out of the icon naming specification, and use prefixes to encode the expected state in case the software isn't new enough to know about a property. For example: - "on" - "off" - "on-disabling" (transitioning from on to off) - "off-enabling" (transitioning from off to on) So we could easily add: - "off-rfkill" (off and blocked) Let me know what you think. Cheers