linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* low energy: does gatt client/server work in current version? How to test?
@ 2018-10-01 10:24 Pavel Machek
  2018-10-01 13:53 ` Barry Byford
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Machek @ 2018-10-01 10:24 UTC (permalink / raw)
  To: luiz.dentz, linux-bluetooth, marcel

[-- Attachment #1: Type: text/plain, Size: 2917 bytes --]

Hi!

I'm trying to get gatt client/server to run; my ultimate goal is to
turn Linux machine into "low-energy device", providing services
similar to heartbeat measurement.

I do have existing qt application (running on Android and PC) I'd like
"device" to talk to.

TODO says:

- Add complete GATT test coverage in unit/test-gatt following the GATT
  test
    spec. This could use shared/gatt-client and shared/gatt-server at
  the same
    time to test both against each other. We should definitely have
  tests for
    gatt-server and gatt-client simultaneously on one side of the
  connection.

  Priority: High
    Complexity: C4

Which tells me that maybe I should consider helping with that. But so
far I was not able to get it to work...

I can use gatt-server and connect to it using gatttool, but depending
on details during the server start (?) and phase of moon, either
device is not enumerated by the QT code, or it is not detected as
low-energy device, or no UUIDs are detected.

My attempt at launching server is below (using python gatt-server, (1)
). I was doing "hciconfig leadv 0" manually at some point.

Using hciconfig while bluetoothd is running sounds kind-of
dangerous. Stackoverflow (2) suggests using btmgmt (3) instead, and
things got slightly different, but did not start to work for me. Is
there documentation how to get this to work somewhere?

Thanks and best regards,
							Pavel

(3)
sudo tools/btmgmt -i hci0 power off
sudo tools/btmgmt -i hci0 le on
sudo tools/btmgmt -i hci0 connectable on
sudo tools/btmgmt -i hci0 name "some friendly name"
sudo tools/btmgmt -i hci0 advertising on
sudo tools/btmgmt -i hci0 power on
tools/btgatt-server -i hci0 -s low -t public -r -v

(2)
https://stackoverflow.com/questions/29128586/bluetooth-low-energy-in-c-using-bluez-to-create-a-gatt-server#31030321

(1)
#!/usr/bin/python3
# -*- python -*-

import os
import re
import time

def pcmd(c):
    return os.popen(c).readline()[:-1]

class Ble:
    def down(m):
        print("Shutting down BLEE")
        os.system("sudo killall bluetoohd")
        os.system("sudo killall gatt-server")
        os.system("sudo hciconfig hci0 down")        

    def up(m):
        print("Starting up BLEE")
        os.system("sudo ../bluez/src/bluetoothd -d -n &")
        time.sleep(2)
        os.system("sudo ./gatt-server &")
        time.sleep(2)
        os.system("sudo hciconfig hci0 up")
        ##os.system("../bluez/test/example-gatt-server &")
        while True:
            #os.system("sudo hciconfig hci0 leadv 0")
            time.sleep(5)

    def run(m):
        m.down()
        time.sleep(1)
        m.up()
                
b = Ble()
b.run()



									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-14 21:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-01 10:24 low energy: does gatt client/server work in current version? How to test? Pavel Machek
2018-10-01 13:53 ` Barry Byford
2018-10-02  8:53   ` Luiz Augusto von Dentz
2018-10-02 12:26     ` Pavel Machek
2018-10-05  9:15     ` Pavel Machek
2018-10-14 21:40     ` Pavel Machek
2018-10-02 12:09   ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).