Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1221615pxb; Sun, 21 Feb 2021 16:51:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJweakXST7xmY4JPD+eSHgYn+8xHsUFRHkdGKmVaHZLdblMSm996MakAJKLYqibT+KUdgeBL X-Received: by 2002:a05:6402:499:: with SMTP id k25mr20065469edv.294.1613955078371; Sun, 21 Feb 2021 16:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613955078; cv=none; d=google.com; s=arc-20160816; b=p7MSwLqHZCHYD/UywiSf0sLeQPVEGMmG3dlZaYdgtqVwnljs9etgFcJzvImwpD+nR1 zYDEEEd06T7sO1L/aJ3xwmWLuGCB/nRDYjs9Q7aARr0A2jUdR28JMgYmA3glTLgUjyaz 17Atl0YlbjLdSwZgGvfN351rHjZZFU38zLplN/Qc+N4NvD72/hTFmHu8AeSfb0iObLIi ksf/3CXQY/0BcqatqH850hr2Rb9H8NlpwQ2T+zC28jrE191Tqe63cDLpEu9wVJ81c5OZ dg7pczzCDfedCeLZjsvIiJL0N6ziNEUGuP1kS/tSK0B4jGb5kgvJOGkiP8hZjY2Ft6gq qkDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aGP3r2f4zPW3GtaZ9hFWR2PWzu1ogKxejTXf/7WVcyQ=; b=dzwW5qzojXhY+w/K+U0feBU1HJVTzi/FKvG8XYM+INK2yXAiVN1BKS/mClOvDfo0A0 znprvL3ckuohgPqYE+B7v2lkfY/RCvTtQMXEfuS4jXMIczpHj/vLVkwme1/SFDL96Qfy PQCcJvbbtAV+rETeSR0fJxvrMTq+A30miUiohBZ3rekRBKxpf8yMcQ88pwp1F9fUhpPJ ZzwXxxd7vXLIFqVZ5Don9r0jh+mlnVVFM6zopc3E4USNYWvBiuFJKqvab7L0iXPsx070 yMHVAgvz8lo3sNnRulmGBh5dOrFJhcgEJoPFu1wU8c6CR5Gl1zwI8aUHZF6Yf5oI1qN6 UE+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZQEG8oOw; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x9si10547840ejb.735.2021.02.21.16.50.36; Sun, 21 Feb 2021 16:51:18 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=ZQEG8oOw; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234205AbhBUXr4 (ORCPT + 99 others); Sun, 21 Feb 2021 18:47:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234199AbhBUXry (ORCPT ); Sun, 21 Feb 2021 18:47:54 -0500 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFEC2C061786 for ; Sun, 21 Feb 2021 15:47:13 -0800 (PST) Received: by mail-oi1-x236.google.com with SMTP id q186so12240073oig.12 for ; Sun, 21 Feb 2021 15:47:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aGP3r2f4zPW3GtaZ9hFWR2PWzu1ogKxejTXf/7WVcyQ=; b=ZQEG8oOwrz+IyPbefiACvnZy26YQL1b5cqZlYXRcHzZPJ6E8w/YIpMxKQPbcoa/8Ej 2pqOXAKLBNZmABIHqPrUwmlenNEXSG2ahuN7Mm6i62Z+NiF+qE34kLvIuqKhdxysm4Bc SquhzH1VGE2a89p1wYVmubReWVL+urGMMvfP9vGsvire08NNNiJc9YKU3E/MxE07IYt9 koXJc5e0qUTY++ME/6ziaa7J/QZZ0o3tTI0AkuGbuNiPoxoi35ReNQNhIkgePcTJTPYF Qd77xSo0BaTeMb/PLUXVhjhJCV0UIXJhovLwfhJjkIX6FnSANqSfzlm3V/vOoHdUdgm8 i78A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aGP3r2f4zPW3GtaZ9hFWR2PWzu1ogKxejTXf/7WVcyQ=; b=rYQskXKTud7QNdqBgZ8MkhkFeZaKznPFBjQPZBdO0UJgPp9TwFcpy3jvUIOOeqp4CP usQ8hGRR6OeJEyzT1W7Yg7WzTYN58Zcn/0Sm0/lulzp8Z4rGW0cgUB2m175IKsvHYkoU w/xRPeD/qWi4XSwvvF7W+Vb62Q/qntf1YefvGLnUnnWG5hYQ5KHhDgHe9Zrka/0YkKxE +zkArCnbfurCG8e53pZl+L7dpNKp37ZpOx63d8YFFVyQZmsZhfacJGpZkKuV4kOVFXsz cFWB8yPXMMFdNnnfFsBLL3pNhsc1JVlIAeGvSgUZEtO3/w88LvipNpj+m0dW2EF7+LcD zA3w== X-Gm-Message-State: AOAM5334uGLmSLEnKIytz0z2zs8OLBkb+gigL6L5oZMKOGszryxuY0Z5 EZn8x+JsVpi/EJMe0ECRF6b8vj8b5MQ3jL9/E84= X-Received: by 2002:aca:c109:: with SMTP id r9mr13817576oif.64.1613951233228; Sun, 21 Feb 2021 15:47:13 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Luiz Augusto von Dentz Date: Sun, 21 Feb 2021 15:47:02 -0800 Message-ID: Subject: Re: How to receive notifications after calling StartNotify To: Mihai Emilian Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Mihai, On Sun, Feb 21, 2021 at 9:13 AM Mihai Emilian wrote: > > Dear linux-bluetooth community, > > I am writing a bluetooth client in C which receives notifications from > a bluetooth device (server). I am able to call StartNotify() from the > bluez api and the Notifying property changes to true. However, I am > not sure how I should listen for the notifications, or where. > > There are several questions: > a) How do I provide a callback function to this? > b) async or sync method call? Does it matter? > c) Do I need the main loop to do this and why? You will need to subscribe for signals, e.g. using g_signal_connect: https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/gio/GDBusProxy.html Signals are async so typically that would be handled by a mainloop. > Here's my source code https://pastebin.com/KEGTatsL > > Is there an example? I tried looking at the different files such as > client in bluez kernel source and gatttool source, but I couldn't > figure this out. > > Many thanks, > Regards, > Mihai -- Luiz Augusto von Dentz