2

I'm using bluez on a GATT client (laptop) and TI's SimpleBLEPeripheral code on a GATT server (TI's CC2541-based PCB). The PCB's UUID is:

0000fff0-0000-1000-8000-00805f9b34fb

Using bluez, I have the following

static GAttrib *attrib = NULL;
...
static void cmd_primary(int argcp, char **argvp)
{
    bt_uuid_t uuid;

    if (conn_state != STATE_CONNECTED) {
        resp_error(err_BAD_STATE);
        return;
    }

    if (argcp == 1) {
        gatt_discover_primary(attrib, NULL, primary_all_cb, NULL);
        return;
    }

    if (bt_string_to_uuid(&uuid, argvp[1]) < 0) {
        resp_error(err_BAD_PARAM);
        return;
    }

    gatt_discover_primary(attrib, &uuid, primary_by_uuid_cb, NULL);
}

static void primary_by_uuid_cb(uint8_t status, GSList *ranges, void *user_data)
{
    GSList *l;

    if (status) {
        resp_error(err_COMM_ERR); // Todo: status
        return;
    }

    resp_begin(rsp_DISCOVERY);
    for (l = ranges; l; l = l->next) {
        struct att_range *range = l->data;
        send_uint(tag_RANGE_START, range->start);
        send_uint(tag_RANGE_END, range->end);
    }
    resp_end();
}

After successfully connecting to the PCB, running cmd_primary(2, (char* []){"svcs", "0000fff0-0000-1000-0000-000000000000"} leads the callback primary_by_uuid_cb() to be called with the parameter ranges being NULL. If the service is recognised, ranges shouldn't be NULL - correct?

If that's the case, does anyone know why the service is not found (or why ranges is NULL if it shouldn't be)?

Any help will be appreciated.

Youssif Saeed
  • 11,789
  • 4
  • 44
  • 72
John M.
  • 2,642
  • 7
  • 26
  • 55
  • 2
    Just asking. Are you sure that UUID is a primary service? Perhaps run `gatttool` to verify everything is as you expect before trying your own code. If `gatttool` correctly shows all the primary services then you know that part is fine and can then be confident the issue is in your code. Also, any reason you are using these unofficial APIs rather than the official bluez DBUS APIs? I find the latter easier to use (once you get over the DBUS learning curve). – kaylum Dec 20 '15 at 23:12
  • 1
    Kaylum is right, you should really use that DBus API! Check my included answers in [this](http://stackoverflow.com/questions/29767053/bluez-programming/32958792#32958792) post where I explain some aspects of getting started the BlueZ DBus API; hope it helps! :) – Zimano Dec 23 '15 at 10:34

0 Answers0