Hci_write_local_name parameters explanation

Viewed 129

I would like to know the details about the third parameter of the hci_write_local_name function. The first one is thesocket descriptor. Second the local name. And third one is a number which i thought the length of the second parameter. But if i use strlen of the second parameter the function fails. In hciconfig.c the value of third parameter for the same function is 2000. I tested with 100 as value. That worked. Can anybody say what exactly the third parameter implies?

1 Answers

As ukBaz mentioned, the third parameter is the timeout as can be seen in the source code:-

int hci_write_local_name(int dd, const char *name, int to)
{
    change_local_name_cp cp;
    struct hci_request rq;

    memset(&cp, 0, sizeof(cp));
    strncpy((char *) cp.name, name, sizeof(cp.name) - 1);

    memset(&rq, 0, sizeof(rq));
    rq.ogf    = OGF_HOST_CTL;
    rq.ocf    = OCF_CHANGE_LOCAL_NAME;
    rq.cparam = &cp;
    rq.clen   = CHANGE_LOCAL_NAME_CP_SIZE;

    if (hci_send_req(dd, &rq, to) < 0)
        return -1;

    return 0;
}

Most of BlueZ's HCI functions require a timeout parameter as the underlying hci_send_req() requires that.

More information can be found here and the rest of the file.

Related