How to get local device address from "bluez" library

28 views Asked by At

I can retrieve local device name using these functions:

sock = hci_open_dev(dev_id );
result = hci_read_local_name(sock,sizeof(name),name,0);
  1. Why do I have to use socket instead just dev_id?
  2. How do I retrieve same local device address?

This is my TEST code, and it compiles and runs, but fails to get the address:

bdaddr_t *bdaddr_1={0};

result = hci_devba(sock, bdaddr_1);
if(result == 0)
{
    text = "SUCCESs local device address ";
    //CONVERT char to string
    ba2str(bdaddr_1, addr);
    text = addr;
}
else
{
    text = "FAILED to get local device address (socket) ";
}
qDebug()<< text;
0

There are 0 answers