writeDescriptor error

Ask, and ye shall receive.
scottmahr
Posts: 14
Joined: 00:36, 17 Apr 2015

writeDescriptor error

Postby scottmahr » 01:01, 17 Apr 2015

I am trying to write to a descriptor and I am getting an error "writeDescriptor". I am using Android on a galaxy s5. I try

Code: Select all

evothings.ble.writeCharacteristic(
         24, //device.deviceHandle,
         9, //characteristic.handle, found from device.__uuidMap
         new Uint8Array([255,0,0]),
         function()
         {
            console.log('worked!")
         },
         function(errorCode)
         {
            console.log('error code:'+errorCode)
         });


I am not sure where to start troubleshooting. I am able to connect to another descriptor and get notifications.

Scott

scottmahr
Posts: 14
Joined: 00:36, 17 Apr 2015

Re: writeDescriptor error

Postby scottmahr » 05:09, 17 Apr 2015

To add a little bit of info, I get the following info on my device after I discover everything.
When I run my writeCharacteristic, it shows that I am writing to device handle 3 and characteristic handle 7, which I think looks right.

I am able to do a writeDescriptor in exactly the same way and it works great. I receive data back from a callback and everything works.

I am also able to write the characteristic using Nordic's "Master Control Panel", and I can see the effect on the bt device, so I think that part of it is working.



Code: Select all

{
    "scanRecord": "DQlGb3JtIENvbGxhcjICAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
    "address": "EF:E0:23:7C:D3:A7",
    "name": "Form Collar2",
    "rssi": -82,
    "advertisementData": {
        "kCBAdvDataLocalName": "Form Collar2"
    },
    "deviceHandle": 3,
    "__uuidMap": {
        "00001800-0000-1000-8000-00805f9b34fb": {
            "type": 0,
            "uuid": "00001800-0000-1000-8000-00805f9b34fb",
            "handle": 1
        },
        "00001801-0000-1000-8000-00805f9b34fb": {
            "type": 0,
            "uuid": "00001801-0000-1000-8000-00805f9b34fb",
            "handle": 2
        },
        "7a6f0000-40bd-4b77-b7b4-de8a2c3048b7": {
            "type": 0,
            "uuid": "7a6f0000-40bd-4b77-b7b4-de8a2c3048b7",
            "handle": 3,
            "__characteristics": [
                {
                    "permissions": 0,
                    "writeType": 2,
                    "properties": 16,
                    "uuid": "7a6f0001-40bd-4b77-b7b4-de8a2c3048b7",
                    "handle": 6,
                    "__descriptors": [
                        {
                            "permissions": 0,
                            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                            "handle": 10
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                            "handle": 11
                        }
                    ]
                },
                {
                    "permissions": 0,
                    "writeType": 2,
                    "properties": 16,
                    "uuid": "7a6f0002-40bd-4b77-b7b4-de8a2c3048b7",
                    "handle": 7,
                    "__descriptors": [
                        {
                            "permissions": 0,
                            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                            "handle": 12
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                            "handle": 13
                        }
                    ]
                },
                {
                    "permissions": 0,
                    "writeType": 2,
                    "properties": 16,
                    "uuid": "7a6f0003-40bd-4b77-b7b4-de8a2c3048b7",
                    "handle": 8,
                    "__descriptors": [
                        {
                            "permissions": 0,
                            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                            "handle": 14
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                            "handle": 15
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                            "handle": 16
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                            "handle": 17
                        }
                    ]
                },
                {
                    "permissions": 0,
                    "writeType": 2,
                    "properties": 16,
                    "uuid": "7a6f0003-40bd-4b77-b7b4-de8a2c3048b7",
                    "handle": 9,
                    "__descriptors": []
                }
            ]
        },
        "0000180f-0000-1000-8000-00805f9b34fb": {
            "type": 0,
            "uuid": "0000180f-0000-1000-8000-00805f9b34fb",
            "handle": 4
        },
        "0000180a-0000-1000-8000-00805f9b34fb": {
            "type": 0,
            "uuid": "0000180a-0000-1000-8000-00805f9b34fb",
            "handle": 5
        },
        "7a6f0001-40bd-4b77-b7b4-de8a2c3048b7": {
            "permissions": 0,
            "writeType": 2,
            "properties": 16,
            "uuid": "7a6f0001-40bd-4b77-b7b4-de8a2c3048b7",
            "handle": 6,
            "__descriptors": [
                {
                    "permissions": 0,
                    "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                    "handle": 10
                },
                {
                    "permissions": 0,
                    "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                    "handle": 11
                }
            ]
        },
        "7a6f0002-40bd-4b77-b7b4-de8a2c3048b7": {
            "permissions": 0,
            "writeType": 2,
            "properties": 16,
            "uuid": "7a6f0002-40bd-4b77-b7b4-de8a2c3048b7",
            "handle": 7,
            "__descriptors": [
                {
                    "permissions": 0,
                    "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                    "handle": 12
                },
                {
                    "permissions": 0,
                    "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                    "handle": 13
                }
            ]
        },
        "7a6f0003-40bd-4b77-b7b4-de8a2c3048b7": {
            "permissions": 0,
            "writeType": 2,
            "properties": 16,
            "uuid": "7a6f0003-40bd-4b77-b7b4-de8a2c3048b7",
            "handle": 9,
            "__descriptors": []
        },
        "7a6f0001-40bd-4b77-b7b4-de8a2c3048b7:00002901-0000-1000-8000-00805f9b34fb": {
            "permissions": 0,
            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
            "handle": 10
        },
        "7a6f0001-40bd-4b77-b7b4-de8a2c3048b7:00002902-0000-1000-8000-00805f9b34fb": {
            "permissions": 0,
            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
            "handle": 11
        },
        "7a6f0002-40bd-4b77-b7b4-de8a2c3048b7:00002901-0000-1000-8000-00805f9b34fb": {
            "permissions": 0,
            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
            "handle": 12
        },
        "7a6f0002-40bd-4b77-b7b4-de8a2c3048b7:00002902-0000-1000-8000-00805f9b34fb": {
            "permissions": 0,
            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
            "handle": 13
        },
        "7a6f0003-40bd-4b77-b7b4-de8a2c3048b7:00002901-0000-1000-8000-00805f9b34fb": {
            "permissions": 0,
            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
            "handle": 16
        },
        "7a6f0003-40bd-4b77-b7b4-de8a2c3048b7:00002902-0000-1000-8000-00805f9b34fb": {
            "permissions": 0,
            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
            "handle": 17
        }
    },
    "__services": [
        {
            "type": 0,
            "uuid": "00001800-0000-1000-8000-00805f9b34fb",
            "handle": 1
        },
        {
            "type": 0,
            "uuid": "00001801-0000-1000-8000-00805f9b34fb",
            "handle": 2
        },
        {
            "type": 0,
            "uuid": "7a6f0000-40bd-4b77-b7b4-de8a2c3048b7",
            "handle": 3,
            "__characteristics": [
                {
                    "permissions": 0,
                    "writeType": 2,
                    "properties": 16,
                    "uuid": "7a6f0001-40bd-4b77-b7b4-de8a2c3048b7",
                    "handle": 6,
                    "__descriptors": [
                        {
                            "permissions": 0,
                            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                            "handle": 10
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                            "handle": 11
                        }
                    ]
                },
                {
                    "permissions": 0,
                    "writeType": 2,
                    "properties": 16,
                    "uuid": "7a6f0002-40bd-4b77-b7b4-de8a2c3048b7",
                    "handle": 7,
                    "__descriptors": [
                        {
                            "permissions": 0,
                            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                            "handle": 12
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                            "handle": 13
                        }
                    ]
                },
                {
                    "permissions": 0,
                    "writeType": 2,
                    "properties": 16,
                    "uuid": "7a6f0003-40bd-4b77-b7b4-de8a2c3048b7",
                    "handle": 8,
                    "__descriptors": [
                        {
                            "permissions": 0,
                            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                            "handle": 14
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                            "handle": 15
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002901-0000-1000-8000-00805f9b34fb",
                            "handle": 16
                        },
                        {
                            "permissions": 0,
                            "uuid": "00002902-0000-1000-8000-00805f9b34fb",
                            "handle": 17
                        }
                    ]
                },
                {
                    "permissions": 0,
                    "writeType": 2,
                    "properties": 16,
                    "uuid": "7a6f0003-40bd-4b77-b7b4-de8a2c3048b7",
                    "handle": 9,
                    "__descriptors": []
                }
            ]
        },
        {
            "type": 0,
            "uuid": "0000180f-0000-1000-8000-00805f9b34fb",
            "handle": 4
        },
        {
            "type": 0,
            "uuid": "0000180a-0000-1000-8000-00805f9b34fb",
            "handle": 5
        }
    ]
}

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: writeDescriptor error

Postby Fredrik » 11:36, 17 Apr 2015

You must not hard-code deviceHandles or characteristic.handles, like you've done in the first post. Those values are likely to change between runs of your program.

scottmahr
Posts: 14
Joined: 00:36, 17 Apr 2015

Re: writeDescriptor error

Postby scottmahr » 16:17, 17 Apr 2015

Right, initially I used the code exactly as I found it in easyble.js. To try to troubleshoot further I tried hard coding the values. Is there any initialization that needs to happen before I write to a characteristic?

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: writeDescriptor error

Postby Fredrik » 16:31, 17 Apr 2015

Not as far as I know. Perhaps you could try running one of our examples (for which you have the appropriate hardware), to see if your phone can do any writeCharacteristic operations at all.

scottmahr
Posts: 14
Joined: 00:36, 17 Apr 2015

Re: writeDescriptor error

Postby scottmahr » 18:54, 17 Apr 2015

OK, I was able to send data to a RFduino from within the app I am developing. I noticed that when I look at the ble devices in the Master Control Panel from nordic, I see that on the RFduino the uuid for the characteristics are shown as 4 digits, and the uuid on my custom service are shown as 32 digits.

This is from my hardware developer.
it sounds like your library doesn't support custom full length UUIDs
adopted services only use 2 octets out of the base Bluetooth UUID
and they call that a 16-bit UUID
since we have a custom service we are required to use the full 128 bits


Does this make sense? Is there any way this could be tripping me up?

Thanks much,

Scott

DonPancoe
Posts: 25
Joined: 06:53, 20 Nov 2014
Location: Philadelphia, PA, USA
Contact:

Re: writeDescriptor error

Postby DonPancoe » 13:19, 18 Apr 2015

I'm not completely sure I understand it myself, but I've generally found that you can pad 16 and 32 bit UUIDs with the same digits to make them into 32 bit or 128 bit UUIDs. For example...

The RFduino read characteristic UUID is 2221, but I've found this 128 bit UUID to work
00002221-0000-1000-8000-00805f9b34fb

The RFduino write characteristic is 2222, but I've found this 128 bit UUID to work
00002222-0000-1000-8000-00805f9b34fb

And lastly, the CCCD for the read characteristic is 2902 (BLE standard) but this 128 bit UUID works for me
00002902-0000-1000-8000-00805f9b34fb

You can see that all the added digits in the above examples are the same.

I've heard from application engineers of BLE chip manufacturers that the Bluetooth SIG "requirement" that custom characteristics use 128 bit UUIDs is to avoid UUID conflicts among characteristics from different devices by different manufacturers. However, if you are developing your own app to work specifically with your own device, then you can get away with 16 or 32 bit UUIDs. Now if you are developing, say, a heart rate monitor to work with any 3rd party heart rate app, you will have to be more formal in your UUID assignments.

Don


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 59 guests