Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
crazycoder1999
Posts: 14
Registered: ‎12-06-2012
My Device: Dev Alpha
My Carrier: Vodafone
Accepted Solution

Bluetooth LE and Texas Sensor Tag: wrong gatt services list?

Hello,

   I'm doing some experiment with my Dev ALpha C and the Texas Sensor Tag.

Actually I'm following this guide: https://www.bluetooth.org/en-us/Documents/Bluetooth%20SIG%20developer%20Training%20day%20-%20Woolley...

 

I would like to list all the available services on the Sensor Tag

 

I have a  a function inside my app that do something like this:

 

//initializing BT
    if(bt_device_init(ApplicationUI::btEvent)==0) {
        qDebug() << "device init ok";
        if(bt_ldev_get_power())
            bt_ldev_set_power(true); //turning bt on
        if(bt_gatt_init(&m_gatt_cb)!=0) {
            qDebug() << "gatt init failed";
        }

        searchLab->setProperty("text","starting inquiry!"); //a label

        if(bt_disc_start_inquiry(BT_INQUIRY_GIAC)==0) {
            int deviceCount=0,i,z;
            bt_remote_device_t **remote_device_array = bt_disc_retrieve_devices(BT_DISCOVERY_CACHED,&deviceCount);
            QString newDevs = QString("Devices Found %1").arg(deviceCount);
            searchLab->setProperty("text",newDevs);
            if(deviceCount>0) {
                for(i=0;i<deviceCount;i++) {
                    char devName[256];
                    bt_rdev_get_remote_name( remote_device_array[i], devName, 256);
                    qDebug()<< "FOUND: " << devName ;
                    const bt_remote_device_t *found = remote_device_array[i];

                    if(bt_rdev_get_type(found) == BT_DEVICE_TYPE_LE_PUBLIC ){
                        if(bt_rdev_pair(found)!=0) {
                            qDebug()<< "Failed Pairing...";
                        }
                        char** gattServices =  bt_rdev_get_services_gatt(found);
                        qDebug() << "...services for: " <<devName;

                        if(gattServices) {
                            z=0;
                            while(gattServices[z]!=NULL){
                                qDebug()<<gattServices[z];
                                z++;
                            }
                        } else {
                            qDebug() << "NO GATT SERVICES FOUND";
                        }
                        break;
                    }
                }
                bt_rdev_free_array(remote_device_array);
            }
        }

    } else {
        qDebug() << "device bt init failed";
    }

This code search for a Bluetooth LE device around and than it try to list on the console every service found on the devce.

The output is:

 

Searching services for:  SensorTag
0x1800
0x1801
0x180A
0xF000AA00-0451-4000-B000-000000000000
0xF000AA10-0451-4000-B000-000000000000
0xF000AA20-0451-4000-B000-000000000000
0xF000AA30-0451-4000-B000-000000000000
0xF000AA40-0451-4000-B000-000000000000
0xF000AA50-0451-4000-B000-000000000000
0xFFE0
0xF000AA60-0451-4000-B000-000000000000
0xF000FFC0-0451-4000-B000-000000000000

I have 2 problems:

1st: Is it Pairing necessary? if I try to use a usb bluetooth le dongle under linux following this guide: http://joost.damad.be/2013/08/experiments-with-bluetooth-low-energy.html it works and it doesn't need to make pairing between Sensor Tag and Dev Alpha C... If I don't pair the devices .. I have 0 services back.

 

2nd: quering the device with the command explained here http://joost.damad.be/2013/08/experiments-with-bluetooth-low-energy.html I have these list of services

 


attr handle: 0x0001, end grp handle: 0x000b uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0x000f uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x0010, end grp handle: 0x0022 uuid: 0000180a-0000-1000-8000-00805f9b34fb
attr handle: 0x0023, end grp handle: 0x002a uuid: f000aa00-0451-4000-b000-000000000000
attr handle: 0x002b, end grp handle: 0x0035 uuid: f000aa10-0451-4000-b000-000000000000
attr handle: 0x0036, end grp handle: 0x003d uuid: f000aa20-0451-4000-b000-000000000000
attr handle: 0x003e, end grp handle: 0x0048 uuid: f000aa30-0451-4000-b000-000000000000
attr handle: 0x0049, end grp handle: 0x0054 uuid: f000aa40-0451-4000-b000-000000000000
attr handle: 0x0055, end grp handle: 0x005c uuid: f000aa50-0451-4000-b000-000000000000
attr handle: 0x005d, end grp handle: 0x0061 uuid: 0000ffe0-0000-1000-8000-00805f9b34fb
attr handle: 0x0062, end grp handle: 0x0068 uuid: f000aa60-0451-4000-b000-000000000000
attr handle: 0x0069, end grp handle: 0xffff uuid: f000ffc0-0451-4000-b000-000000000000

 

It's different from my query... why?

Thanks you

Please use plain text.
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Bluetooth LE and Texas Sensor Tag: wrong gatt services list?

Hi

 

glad you're finding our presentation useful :-)

 

As far as listing services on your sensor tag is concerned, I recommend you download and review our BlackBerryBleExplorer application which is something we developed for the Bluetooth SIG to offer as a reference application for BlackBerry 10. It will list devices and then if you select one by moving its icon to the middle of the screen and touching it, all the services on the device. Touch the central service icon and it lists all the characteristics.

 

https://github.com/blackberry/Cascades-Community-Samples/tree/master/blackberrybleexplorer

 

You'll also see how we distinguish between known and not known devices. This is not quite the same as "paired".

 

Let me take a closer look at your post regarding your second questiom and get back to you.

 

Regards

 

Martin

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Bluetooth LE and Texas Sensor Tag: wrong gatt services list?

1. Pairing is not always necessary. It depends on the device. What you should do in general is go into Settings-Bluetooth on your BlackBerry and when you see the TI Sensor Tag for the first time, select it. If you're required to enter a PIN, you'll be prompted to at this point. The status of the device in the Settings should change now to Connected or Paired depending on whether or not a PIN was required. Other devices in the list will probably have a status of "Saved" meaning that they were connected to or paired with previously and their details saved in the BlackBerry Bluetooth device cache. If a device is in the Settings list and in the right state (connected or paired) then you do need need to programmatically pair with it.

 

2. Regarding your apparently different service lists, they're actually equivalent. I'm interleaved the BlackBerry API output with that from your Linux tool below:

 

                                                                              0x1800
ATTR HANDLE: 0x0001, END GRP HANDLE: 0x000B UUID: 00001800-0000-1000-8000-00805F9B34FB


                                                                              0x1801
ATTR HANDLE: 0x000C, END GRP HANDLE: 0x000F UUID: 00001801-0000-1000-8000-00805F9B34FB

                                                                              0x180A
ATTR HANDLE: 0x0010, END GRP HANDLE: 0x0022 UUID: 0000180A-0000-1000-8000-00805F9B34FB


                                                                         0xF000AA00-0451-4000-B000-000000000000
ATTR HANDLE: 0x0023, END GRP HANDLE: 0x002A UUID: F000AA00-0451-4000-B000-000000000000


                                                                        0xF000AA10-0451-4000-B000-000000000000
ATTR HANDLE: 0x002B, END GRP HANDLE: 0x0035 UUID: F000AA10-0451-4000-B000-000000000000


                                                                         0xF000AA20-0451-4000-B000-000000000000
ATTR HANDLE: 0x0036, END GRP HANDLE: 0x003D UUID: F000AA20-0451-4000-B000-000000000000

                                                                         0xF000AA30-0451-4000-B000-000000000000
ATTR HANDLE: 0x003E, END GRP HANDLE: 0x0048 UUID: F000AA30-0451-4000-B000-000000000000


                                                                        0xF000AA40-0451-4000-B000-000000000000
ATTR HANDLE: 0x0049, END GRP HANDLE: 0x0054 UUID: F000AA40-0451-4000-B000-000000000000

                                                                        0xF000AA50-0451-4000-B000-000000000000
ATTR HANDLE: 0x0055, END GRP HANDLE: 0x005C UUID: F000AA50-0451-4000-B000-000000000000

                                                                               0xFFE0
ATTR HANDLE: 0x005D, END GRP HANDLE: 0x0061 UUID: 0000FFE0-0000-1000-8000-00805F9B34FB

                                                                        0xF000AA60-0451-4000-B000-000000000000
ATTR HANDLE: 0x0062, END GRP HANDLE: 0x0068 UUID: F000AA60-0451-4000-B000-000000000000

                                                                         0xF000FFC0-0451-4000-B000-000000000000
ATTR HANDLE: 0x0069, END GRP HANDLE: 0xFFFF UUID: F000FFC0-0451-4000-B000-000000000000

 

The reason some of them are "short" is that both 16 bit UUIDs and 128 bit UUIDs are defined and the spec defines a base UUID with which to convert the 16 bit versions into 128 bit versions. That's what your Linux tool is probably doing.

 

 

Regards

 

Martin

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
Contributor
crazycoder1999
Posts: 14
Registered: ‎12-06-2012
My Device: Dev Alpha
My Carrier: Vodafone

Re: Bluetooth LE and Texas Sensor Tag: wrong gatt services list?

Thanks Martin, wonderful answers! :Rockon:

Please use plain text.