sputnikdev / eclipse-smarthome-bluetooth-binding

Eclipse SmartHome Bluetooth Binding
46 stars 10 forks source link

Trouble integrating a BLE esp32 sensor with custom GATT specisfications #72

Closed haesslo closed 5 years ago

haesslo commented 5 years ago

Hi Vlad

I looked at all the instructions for custom GATT incl. the issue of RL00li and played around for a day, but am still stuck.

In bluetoothctl I have: [NEW] Device 30:AE:A4:26:3D:82 MyESP32 [NEW] Primary Service /org/bluez/hci0/dev_30_AE_A4_26_3D_82/service0028 17170000-1fb5-459e-8fcc-c5c9c331914b Vendor specific [NEW] Characteristic /org/bluez/hci0/dev_30_AE_A4_26_3D_82/service0028/char002c 17170002-1fb5-459e-8fcc-c5c9c331914b Vendor specific [NEW] Characteristic /org/bluez/hci0/dev_30_AE_A4_26_3D_82/service0028/char0029 17170001-1fb5-459e-8fcc-c5c9c331914b Vendor specific [NEW] Descriptor /org/bluez/hci0/dev_30_AE_A4_26_3D_82/service0028/char0029/desc002b 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Primary Service /org/bluez/hci0/dev_30_AE_A4_26_3D_82/service0001 00001801-0000-1000-8000-00805f9b34fb Generic Attribute Profile [NEW] Characteristic /org/bluez/hci0/dev_30_AE_A4_26_3D_82/service0001/char0002 00002a05-0000-1000-8

I configured the path in : image

I have the services an characteristics files, but not sure (no log on it) if they get parsed:

in : \home\openhabian.ble\service\com.myesp32.service.test2.xml:

<Service xsi:noNamespaceSchemaLocation="http://schemas.bluetooth.org/Documents/service.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="myEsp32t"
         type="com.myesp32.service.test" uuid="17170000-1fb5-459e-8fcc-c5c9c331914b">
<InformativeText>
    <Abstract> Test for myEsp32</Abstract>
    <Summary> Testing BLE on esp32</Summary>
</InformativeText>
<Dependencies>
    <Dependency>This service has no dependencies on other GATT-based services.</Dependency>
</Dependencies>
<GATTRequirements>
    <Requirement subProcedure="Write Characteristic Value">Mandatory</Requirement>
    <Requirement subProcedure="Notification">Mandatory</Requirement>
    <Requirement subProcedure="Read Characteristic Descriptors">Mandatory</Requirement>
    <Requirement subProcedure="Write Characteristic Descriptors">Mandatory</Requirement>
</GATTRequirements>
<Transports>
    <Classic>false</Classic>
    <LowEnergy>true</LowEnergy>
</Transports>
<ErrorCodes>
</ErrorCodes>
<Characteristics>
        <Characteristic name="ESP32_test V1" type="com.myesp32.characteristic.test_value1">
            <InformativeText>Test32 Val1
            </InformativeText>
            <Requirement>Mandatory</Requirement>
            <Properties>
                <Read>Mandatory</Read>
                <Write>Excluded</Write>
                <WriteWithoutResponse>Excluded</WriteWithoutResponse>
                <SignedWrite>Excluded</SignedWrite>
                <ReliableWrite>Excluded</ReliableWrite>
                <Notify>Mandatory</Notify>
                <Indicate>Excluded</Indicate>
                <WritableAuxiliaries>Excluded</WritableAuxiliaries>
                <Broadcast>Excluded</Broadcast>
            </Properties>
            <Descriptors>
                <Descriptor name="Client Characteristic Configuration"
                            type="org.bluetooth.descriptor.gatt.client_characteristic_configuration">
                    <Requirement>Mandatory</Requirement>
                    <Properties>
                        <Read>Mandatory</Read>
                    </Properties>
                </Descriptor>
            </Descriptors>
        </Characteristic>
        <Characteristic name="ESP32_test V2" type="com.myesp32.characteristic.test_value2">
        <InformativeText>Test32 Val2
        </InformativeText>
        <Requirement>Mandatory</Requirement>
        <Properties>
            <Read>Mandatory</Read>
            <Write>Excluded</Write>
            <WriteWithoutResponse>Excluded</WriteWithoutResponse>
            <SignedWrite>Excluded</SignedWrite>
            <ReliableWrite>Excluded</ReliableWrite>
            <Notify>Excluded</Notify>
            <Indicate>Excluded</Indicate>
            <WritableAuxiliaries>Excluded</WritableAuxiliaries>
            <Broadcast>Excluded</Broadcast>
        </Properties>
        <Descriptors>
                <Descriptor name="Client Characteristic Configuration"
                            type="org.bluetooth.descriptor.gatt.client_characteristic_configuration">
                    <Requirement>Mandatory</Requirement>
                    <Properties>
                        <Read>Mandatory</Read>
                    </Properties>
                </Descriptor>
            </Descriptors>
    </Characteristic>
</Characteristics>
</Service>

In \home\openhabian.ble\characteristic\com.myesp32.characteristic.test_value1.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Characteristic xsi:noNamespaceSchemaLocation="http://schemas.bluetooth.org/Documents/characteristic.xsd"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Value1"
                type="com.myesp32.characteristic.test_value1" uuid="17170001-1fb5-459e-8fcc-c5c9c331914b">
    <Value>
        <Field name="TestV1">
            <Format>uint16</Format>
        </Field>
    </Value>
</Characteristic>

and in \home\openhabian.ble\characteristic\com.myesp32.characteristic.test_value2.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Characteristic xsi:noNamespaceSchemaLocation="http://schemas.bluetooth.org/Documents/characteristic.xsd"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Value2"
                type="com.myesp32.characteristic.test_value2" uuid="17170002-1fb5-459e-8fcc-c5c9c331914b">
    <Value>
        <Field name="TestV2">
            <Format>utf8s</Format>
        </Field>
    </Value>
</Characteristic>

But what I get in openhab is : image

Any good idea, where I made a stupid misstake ? I turned on the debugging in the console for your handler, but zero feedback...so I am simply not sure if the file get found/parsed or not

Thanks - If anyone interested I can share the esp32 code.

haesslo

haesslo commented 5 years ago

Hi Vlad

I did still find some configuration issues in my code (incl. one file not readable by openhab due to permission). However I only got it going with the first 8 digits of the UUID - and not with the full UUID, right ? Also (might be wrong) I had the feeling that something is caching file massively as at one point I had to do a "clear-cache" in openhab to get it going.... By the way, do we know why marketplace bindings get removed and not reinstalled at clear-chache ?

Last question would be if it is correct to run these kind of things with 'Connection Control' enabled ?

Sorry for bothering

haesslo