C/C++ code to listen and act of BlueZ HCI event packet
I trying to program a C/C++ software to interact with the BlueZ HCI.
Created a HCI socket
sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
Set socket option for HCI event and stack
hci_filter_set_ptype(HCI_EVENT_PKT, &flt);
hci_filter_set_event(EVT_STACK_INTERNAL, &flt);
setsockopt(hcid.sock, SOL_HCI, HCI_FILTER, &flt, sizeof(flt));
Bind it to dev = 0
addr.hci_family = AF_BLUETOOTH;
addr.hci_dev = 0;
bind(sock, (struct sockaddr *) &addr, sizeof(addr));
How do I listen to the HCI event packet and execute command on it. I basically need some pairing sequence and code for my local device to pair with remote device or vice versa.
|