sputnikdev / eclipse-smarthome-bluetooth-binding

Eclipse SmartHome Bluetooth Binding
46 stars 10 forks source link

Not recognizing custom characteristic/service #67

Open r00li opened 5 years ago

r00li commented 5 years ago

Hi! So, I am very new to Openhab (just installed it yesterday on my RPI 0W) and I am having some issues getting this binding to work with my custom devices.

So I have a few custom BLE devices (built by me) - powered by either a Microchip BLE module or the nordic nrf51822. Temperature sensors, blind controllers, switches and dimmers basically. I can get my devices to connect just fine, but I can't seem to get my own characteristics to show up.

For instance this is my device when connected (I have enabled for unknown channels to display as binary): screenshot 2018-11-10 at 18 36 57

This is my switch module. It has a single characteristic - you write 255 to turn the light on and you write 0 to turn the light off. It has read/write/notify properties.

This is my service xml file that I added:

<Service xsi:noNamespaceSchemaLocation="http://schemas.bluetooth.org/Documents/service.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="RSwitch V1 service"
         type="com.itag.service.simple_button" uuid="6a741280-71d6-11e5-952a-0002a5d5c51b" last-modified="2018-02-22">
<InformativeText>
    <Abstract>
        RSwitch V1 bluetooth service
    </Abstract>
    <Summary>
        RSwitch V1 bluetooth service
    </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="RSwitch_V1"
                    type="com.r00li.bluetooth.characteristic.rswitchv1">
        <InformativeText>Button
        </InformativeText>
        <Requirement>Mandatory</Requirement>
        <Properties>
            <Read>Mandatory</Read>
            <Write>Mandatory</Write>
            <WriteWithoutResponse>Excluded</WriteWithoutResponse>
            <SignedWrite>Excluded</SignedWrite>
            <ReliableWrite>Excluded</ReliableWrite>
            <Notify>Mandatory</Notify>
            <Indicate>Excluded</Indicate>
            <WritableAuxiliaries>Excluded</WritableAuxiliaries>
            <Broadcast>Excluded</Broadcast>
        </Properties>
    </Characteristic>
</Characteristics>
</Service>

And this is my characteristic:

<?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="RSwitch_V1"
                type="com.r00li.bluetooth.characteristic.rswitchv1" uuid="9ed90c00-71d7-11e5-977a-0002a5d5c51b" last-modified="2018-11-10"
                approved="No">
    <Value>
        <Field name="Switch">
            <Format>uint8</Format>
            <InformativeText>Switch status</InformativeText>
            <Enumerations>
                <Enumeration key="0" value="Off"/>
                <Enumeration key="255" value="On"/>
            </Enumerations>
        </Field>
    </Value>
</Characteristic>

To be honest, I am not entirely sure if what I am doing is correct, but going from examples this is what I came up with. Now I think that the binding loads my xmls correctly - the logs show that it was complaining when I had an error in the XML, and it's not complaining now.

One other thing that I find weird is that changing the value for the binary characteristic from that UI does nothing. At least it doesn't look like it does anything - the light doesn't turn on/off.

r00li commented 5 years ago

I just finished testing the build... My devices seem to be working just fine with 128bit uuids now.

r00li commented 5 years ago

Here is that pull request: https://github.com/sputnikdev/bluetooth-gatt-parser/pull/11

Sorry that I didn't make it sooner.

geeks-r-us commented 5 years ago

Hey, @r00li , @vkolotov I build a custom BLE device based on en ESP32 with ArduinoBLE that offers basically the same service and characteristics like the discussed and experiencing the same issue with custom characteristics...

services

Also setup the service and characteristic with an nrf52 DK and nRF Connect and got the same result. So hopefully the ESP32 code works fine.

I set parsing strategy to Recognized + System + Unkown + unrecognized as binary restarted and deleted the device multiple times but my service does not show up.

Also tried it with xml descriptions with the advises from above but this does not change anything.

I assume the problem takes place in a point before the xml files are used because it also does not show up without the files?

Is there somewhere a log file with log messages that could be helpful?