The following
ioctl(2) calls may be used to manipulate Bluetooth devices. The
ioctl(2) must be made on
BTPROTO_HCI sockets. All of the requests take a
btreq structure defined as follows as their parameter and unless otherwise specified, use the
btr_name field to identify the device.
struct btreq {
char btr_name[HCI_DEVNAME_SIZE]; /* device name */
union {
struct {
bdaddr_t btri_bdaddr; /* device bdaddr */
uint16_t btri_flags; /* flags */
uint16_t btri_num_cmd; /* # of free cmd buffers */
uint16_t btri_num_acl; /* # of free ACL buffers */
uint16_t btri_num_sco; /* # of free SCO buffers */
uint16_t btri_acl_mtu; /* ACL mtu */
uint16_t btri_sco_mtu; /* SCO mtu */
uint16_t btri_link_policy; /* Link Policy */
uint16_t btri_packet_type; /* Packet Type */
} btri;
struct bt_stats btrs; /* unit stats */
} btru;
};
#define btr_flags btru.btri.btri_flags
#define btr_bdaddr btru.btri.btri_bdaddr
#define btr_num_cmd btru.btri.btri_num_cmd
#define btr_num_acl btru.btri.btri_num_acl
#define btr_num_sco btru.btri.btri_num_sco
#define btr_acl_mtu btru.btri.btri_acl_mtu
#define btr_sco_mtu btru.btri.btri_sco_mtu
#define btr_link_policy btru.btri.btri_link_policy
#define btr_packet_type btru.btri.btri_packet_type
#define btr_stats btru.btrs
/* btr_flags */
#define BTF_UP (1<<0) /* unit is up */
#define BTF_RUNNING (1<<1) /* unit is running */
#define BTF_XMIT_CMD (1<<2) /* transmitting CMD packets */
#define BTF_XMIT_ACL (1<<3) /* transmitting ACL packets */
#define BTF_XMIT_SCO (1<<4) /* transmitting SCO packets */
#define BTF_INIT_BDADDR (1<<5) /* waiting for bdaddr */
#define BTF_INIT_BUFFER_SIZE (1<<6) /* waiting for buffer size */
#define BTF_INIT_FEATURES (1<<7) /* waiting for features */
#define BTF_NOOP_ON_RESET (1<<8) /* wait for No-op on reset */
#define BTF_INIT_COMMANDS (1<<9) /* waiting for supported commands */
#define BTF_MASTER (1<<10) /* request Master role */
struct bt_stats {
uint32_t err_tx;
uint32_t err_rx;
uint32_t cmd_tx;
uint32_t evt_rx;
uint32_t acl_tx;
uint32_t acl_rx;
uint32_t sco_tx;
uint32_t sco_rx;
uint32_t byte_tx;
uint32_t byte_rx;
};
SIOCGBTINFO
Get Bluetooth device Info. Given the device name, fill in the btreq structure including the address field for use with socket addressing as above.
SIOCGBTINFOA
Get Bluetooth device Info from Address. Given the device address, fill in the btreq structure including the name field.
SIOCNBTINFO
Next Bluetooth device Info. If name field is empty, the first device will be returned. Otherwise, the next device will be returned. Thus, you can cycle through all devices in the system.
SIOCSBTFLAGS
Set Bluetooth device Flags. Not all flags are settable.
SIOCSBTPOLICY
Set Bluetooth device Link Policy. Link Policy bits are defined in
<netbt/hci.h>, though you can only set bits that the device supports.
SIOCSBTPTYPE
Set Bluetooth device Packet Types. You can only set packet types that the device supports.
SIOCGBTSTATS
Read device statistics.
SIOCZBTSTATS
Read device statistics, and zero them.
Only the super-user may change device configurations.