Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. hci_get_route and hci_open_dev - few questions

hci_get_route and hci_open_dev - few questions

Scheduled Pinned Locked Moved Hardware & Devices
helptutorialquestion
3 Posts 2 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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;
    }
    
    L 1 Reply Last reply
    0
    • L Lost User

      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;
      }
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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[^].

      W 1 Reply Last reply
      0
      • L Lost User

        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[^].

        W Offline
        W Offline
        wunsch taria
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups