I have a BLE SoC (QN9021)
connected to a linux system (beagle bone running openwrt
) via UART interface. I want linux to recognize BLE connected with system and commands like gatttool, hcitool
should work with my BLE.
Also, i am using Bluez
and i want BlueZ libraries should find and communicates directly with my BLE
.
It looks like source files in bluez
uses socket()
function call to communicate with the bluetooth adapter. I have posted section of hcitool.c
source file which includes socket call:
/* Open HCI device.
* Returns device descriptor (dd). */
int hci_open_dev(int dev_id)
{
struct sockaddr_hci a;
int dd, err;
/* Check for valid device id */
if (dev_id < 0) {
errno = ENODEV;
return -1;
}
/* Create HCI socket */
dd = socket(AF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC, BTPROTO_HCI);
if (dd < 0)
return dd;
/* Bind socket to the HCI device */
memset(&a, 0, sizeof(a));
a.hci_family = AF_BLUETOOTH;
a.hci_dev = dev_id;
if (bind(dd, (struct sockaddr *) &a, sizeof(a)) < 0)
goto failed;
return dd;
failed:
err = errno;
close(dd);
errno = err;
return -1;
}
As previously mentioned, i am connecting BLE SoC via UART. How can i make my BLE recognized as a bluetooth and function call like socket() should open descriptor of my BLE?