Return-Path: MIME-Version: 1.0 In-Reply-To: References: <4CF902B9-8221-45E7-9868-52BF18A5EC5D@gmail.com> <969738CC-B335-4E2F-BF3C-441110279871@gmail.com> From: Luiz Augusto von Dentz Date: Fri, 19 May 2017 15:46:17 +0300 Message-ID: Subject: Re: How to use GattProfile1 To: Krasi Georgiev Cc: Barry Byford <31baz66@gmail.com>, Bluez mailing list Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi, On Thu, May 18, 2017 at 8:00 PM, Krasi Georgiev wrot= e: > Thanks > > I watched this video 3 times, but he talks about profile registration and= the auto connect very briefly so I tried everything that comes to mind, bu= t can=E2=80=99t make it to work > > If you have done it can you post some pseudo code for the code execution = ? > > I am sure it is not very complicated , just still too new to the whole co= ncept. So what is the role you want the system to assume? As central: bluetoothctl> scan on *** Wait for the device you want to connect to show up *** bluetoothctl> connect
bluetoothctl> select-attribute For peripheral: GATT application is not supported yet by bluetoothctl, but I have some plans to include support for it at some point (patch are of course welcome), in case you are looking for a C example you can find it here: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/tools/gatt-service.= c tools/gatt-service: gatt-service unique name: :1.152 Registered service: /service1 Get Primary: True Get UUID: 00001802-0000-1000-8000-00805f9b34fb Exist Includes: 00001802-0000-1000-8000-00805f9b34fb Characteristic(00002a06-0000-1000-8000-00805f9b34fb): Get("Value") Descriptor(8260c653-1a54-426b-9e36-e84c238bc669): Get("Value") Get Primary: True Get UUID: 00001802-0000-1000-8000-00805f9b34fb Exist Includes: 00001802-0000-1000-8000-00805f9b34fb Characteristic(00002a06-0000-1000-8000-00805f9b34fb): Get("Value") Descriptor(8260c653-1a54-426b-9e36-e84c238bc669): Get("Value") Get Primary: True Get UUID: 00001802-0000-1000-8000-00805f9b34fb Exist Includes: 00001802-0000-1000-8000-00805f9b34fb Characteristic(00002a06-0000-1000-8000-00805f9b34fb): Get("Value") Descriptor(8260c653-1a54-426b-9e36-e84c238bc669): Get("Value") RegisterApplication: OK RegisterApplication: OK bluetoothctl> advertise on > >> On 18 May 2017, at 18:41, Barry Byford <31baz66@gmail.com> wrote: >> >> Szymon Janc talks through using BlueZ for BLE on this video: >> https://youtu.be/VMDyebKT5c4 >> Slides at: >> http://events.linuxfoundation.org/sites/events/files/slides/Doing%20Blue= tooth%20Low%20Energy%20on%20Linux.pdf >> >> Should be helpful for you to understand the logic. >> >> >> On 17 May 2017 at 11:35, Krasi Georgiev wrote: >>> 3 hours later and still no luck :( >>> >>> I am reading all api documents over and over again and can=E2=80=99t un= derstand the logic. >>> >>> I think I need to register an object that implements the org.bluez.Gatt= Profile1 interface, but what should be the bus name and object path for thi= s object I am completely unsure... >>> >>> Desperate for any useful info so thanks in advance :) >>> >>>> On 16 May 2017, at 23:31, Krasi Georgiev wrote: >>>> >>>> Thanks >>>> I already looked at these, but they don=E2=80=99t cover what I need an= d also a but high level with the dbus python package which hides most of th= e important details. >>>> >>>> Anyway I think I got a better idea now. I think I need to register the= org.bluez.GattProfile1 interface in the dbus and then call org.bluez.Pro= fileManager1.RegisterProfile , will test it tomorrow and hopefully I will g= et it going. >>>> >>>> >>>>> On 16 May 2017, at 22:08, Barry Byford <31baz66@gmail.com> wrote: >>>>> >>>>> Hello Krasi, >>>>> >>>>> >>>>> On 16 May 2017 at 12:42, Krasi Georgiev wrote: >>>>>> Hi all >>>>>> >>>>>> Can you give me a quick example with a pseudo code (or using qdbus) = for workflow steps how to setup an >>>>>> auto connect to a device that supports given UUID service (0000180f-= 0000-1000-8000-00805f9b34fb - Battery Service) >>>>> >>>>> The examples for BlueZ are in the test directory. The ones you might >>>>> find useful are: >>>>> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/test-dis= covery >>>>> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-= gatt-client >>>>> >>>>> >>>>> >>>>>> >>>>>> From what I understand all I need to do is send a call to the sytemb= us to register the hci0 adapter to auto connect >>>>>> >>>>>> org.bluez.ProfileManager1.RegisterProfile , /org/bluez/Test (ObjPath= ), "00001802-0000-1000-8000-00805f9b34fb=E2=80=9D (service UUID) >>>>>> >>>>>> and if the discovery finds a device with such service it should auto= connect right ? >>>>>> >>>>>> >>>>>> I am not sure what is the ObjPath parameter for and when i introspec= t I don=E2=80=99t even see the /org/bluez/GattProfile1 >>>>>> >>>>>> I am using bluez Version 5.45 on a Raspberry Pi zero >>>>>> Linux 4.4.50+ armv6l >>>>>> >>>>>> >>>>>> I tried making the call using with gdbus, but couldn=E2=80=99t figur= e out how to structure the osa{sv} paramters >>>>>> also tried dbus-send , but the tool doesn=E2=80=99t seem to support = this structures (no nesting) >>>>>> >>>>>> >>>>>> I am using golang godbus bindings and the call gets executed without= an error , but the bluetooth adapter doesn=E2=80=99t auto connect >>>>>> >>>>>> >>>>>> here is the gist >>>>>> https://gist.githubusercontent.com/krasi-georgiev/56f88cd18893578fa8= 3c328f038479d6/raw/25f11f2fd7b55d82590732fa8f253febda623645/main.go >>>>>> >>>>>> go get github.com/godbus/dbus >>>>>> wget https://gist.githubusercontent.com/krasi-georgiev/56f88cd188935= 78fa83c328f038479d6/raw/25f11f2fd7b55d82590732fa8f253febda623645/main.go >>>>>> go run main.go >>>>>> >>>>>> >>>>>> I would really appreciate some useful info. >>>>>> Thanks-- >>>>>> To unsubscribe from this list: send the line "unsubscribe linux-blue= tooth" in >>>>>> the body of a message to majordomo@vger.kernel.org >>>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html >>>> >>> >>> -- >>> To unsubscribe from this list: send the line "unsubscribe linux-bluetoo= th" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- > To unsubscribe from this list: send the line "unsubscribe linux-bluetooth= " in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --=20 Luiz Augusto von Dentz