hci_get_route and hci_open_dev - few questions
-
1. can hci_get_route return anything but 0 or -1 (error) ? 2. does hci_open_dev returns "socket" or "device descriptor" ? 3. as coded in an example can hci_open_dev return 0?
/* get the id of the first bluetooth device. */
device_id = hci_get_route(NULL);
if (device_id < 0) {
perror("hci_get_route");
return 0;
}/\* create a socket to the device \*/ device\_sock = hci\_open\_dev(device\_id); if (device\_sock < 0) { perror("hci\_open\_dev"); return 0; }
-
1. can hci_get_route return anything but 0 or -1 (error) ? 2. does hci_open_dev returns "socket" or "device descriptor" ? 3. as coded in an example can hci_open_dev return 0?
/* get the id of the first bluetooth device. */
device_id = hci_get_route(NULL);
if (device_id < 0) {
perror("hci_get_route");
return 0;
}/\* create a socket to the device \*/ device\_sock = hci\_open\_dev(device\_id); if (device\_sock < 0) { perror("hci\_open\_dev"); return 0; }
-
1.
hci_get_route
returns a device_id [0..n] or -1 on failure. 2.hci_open_dev
returns a socket, or -1 on failure. 3. Yes, zero is a valid device_id. all explained at https://people.csail.mit.edu/albert/bluez-intro/c404.html[^].1. If hci_get_route is unsuccessful, it returns a device_id [0..n] or -1. Hci_open_dev returns a socket or -1 in the event of an error. 3. The device_id zero is legitimate.