bluez5: update gatt server example to master version

https://jira.digi.com/browse/DEL-5023

Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
Isaac Hermida 2017-09-27 10:14:20 +02:00
parent d434043447
commit 16a99ac65c
2 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,124 @@
From: Isaac Hermida <isaac.hermida@digi.com>
Date: Wed, 27 Sep 2017 10:00:15 +0200
Subject: [PATCH] example-gatt-server: update example to master version
Current test example was not registering correctly the services, so the BLEGATT
server was not working properly.
Update this example to current version in master (commit ed63d7e5a9f6).
Note: In order to run it, the bluetoothd daemon needs to be started with the
experimental (-E) flag and needs to enable and advertise the BLE
functionallity (btmgmt le on/connectable on/advertisement on).
https://jira.digi.com/browse/DEL-5023
Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
---
test/example-gatt-server | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/test/example-gatt-server b/test/example-gatt-server
index 84905f3d0856..24aaff973b11 100755
--- a/test/example-gatt-server
+++ b/test/example-gatt-server
@@ -42,6 +42,9 @@ class FailedException(dbus.exceptions.DBusException):
class Application(dbus.service.Object):
+ """
+ org.bluez.GattApplication1 interface implementation
+ """
def __init__(self, bus):
self.path = '/'
self.services = []
@@ -74,6 +77,9 @@ class Application(dbus.service.Object):
class Service(dbus.service.Object):
+ """
+ org.bluez.GattService1 interface implementation
+ """
PATH_BASE = '/org/bluez/example/service'
def __init__(self, bus, index, uuid, primary):
@@ -121,6 +127,9 @@ class Service(dbus.service.Object):
class Characteristic(dbus.service.Object):
+ """
+ org.bluez.GattCharacteristic1 interface implementation
+ """
def __init__(self, bus, index, uuid, flags, service):
self.path = service.path + '/char' + str(index)
self.bus = bus
@@ -195,6 +204,9 @@ class Characteristic(dbus.service.Object):
class Descriptor(dbus.service.Object):
+ """
+ org.bluez.GattDescriptor1 interface implementation
+ """
def __init__(self, bus, index, uuid, flags, characteristic):
self.path = characteristic.path + '/desc' + str(index)
self.bus = bus
@@ -222,7 +234,7 @@ class Descriptor(dbus.service.Object):
if interface != GATT_DESC_IFACE:
raise InvalidArgsException()
- return self.get_properties()[GATT_CHRC_IFACE]
+ return self.get_properties()[GATT_DESC_IFACE]
@dbus.service.method(GATT_DESC_IFACE,
in_signature='a{sv}',
@@ -426,7 +438,7 @@ class TestService(Service):
TEST_SVC_UUID = '12345678-1234-5678-1234-56789abcdef0'
def __init__(self, bus, index):
- Service.__init__(self, bus, index, self.TEST_SVC_UUID, False)
+ Service.__init__(self, bus, index, self.TEST_SVC_UUID, True)
self.add_characteristic(TestCharacteristic(bus, 0, self))
self.add_characteristic(TestEncryptCharacteristic(bus, 1, self))
self.add_characteristic(TestSecureCharacteristic(bus, 2, self))
@@ -523,11 +535,11 @@ class TestEncryptCharacteristic(Characteristic):
CharacteristicUserDescriptionDescriptor(bus, 3, self))
def ReadValue(self, options):
- print('TestCharacteristic Read: ' + repr(self.value))
+ print('TestEncryptCharacteristic Read: ' + repr(self.value))
return self.value
def WriteValue(self, value, options):
- print('TestCharacteristic Write: ' + repr(value))
+ print('TestEncryptCharacteristic Write: ' + repr(value))
self.value = value
class TestEncryptDescriptor(Descriptor):
@@ -564,16 +576,16 @@ class TestSecureCharacteristic(Characteristic):
['secure-read', 'secure-write'],
service)
self.value = []
- self.add_descriptor(TestEncryptDescriptor(bus, 2, self))
+ self.add_descriptor(TestSecureDescriptor(bus, 2, self))
self.add_descriptor(
CharacteristicUserDescriptionDescriptor(bus, 3, self))
def ReadValue(self, options):
- print('TestCharacteristic Read: ' + repr(self.value))
+ print('TestSecureCharacteristic Read: ' + repr(self.value))
return self.value
def WriteValue(self, value, options):
- print('TestCharacteristic Write: ' + repr(value))
+ print('TestSecureCharacteristic Write: ' + repr(value))
self.value = value
@@ -636,6 +648,8 @@ def main():
mainloop = GObject.MainLoop()
+ print('Registering GATT application...')
+
service_manager.RegisterApplication(app.get_path(), {},
reply_handler=register_app_cb,
error_handler=register_app_error_cb)

View File

@ -8,6 +8,7 @@ SRC_URI += " \
file://0001-hcitool-do-not-show-unsupported-refresh-option.patch \
file://0002-hcitool-increase-the-shown-connection-limit-to-20.patch \
file://0025-port-test-discovery-to-python3.patch \
file://0027-example-gatt-server-update-example-to-master-version.patch \
"
SRC_URI_append_ccimx6ul = " \