BT_DEV(3) | NetBSD Library Functions Manual | BT_DEV(3) |
int
bt_devaddr(const char *name, bdaddr_t *bdaddr);
int
bt_devname(char *name, const bdaddr_t *bdaddr);
int
bt_devenum(int (*cb)(int, const struct bt_devinfo *, void *), void *arg);
int
bt_devinfo(const char *name, struct bt_devinfo *info);
int
bt_devopen(const char *name, int flags);
ssize_t
bt_devsend(int s, uint16_t opcode, void *param, size_t plen);
ssize_t
bt_devrecv(int s, void *buf, size_t size, time_t timeout);
int
bt_devreq(int s, struct bt_devreq *req, time_t timeout);
int
bt_devfilter(int s, const struct bt_devfilter *new, struct bt_devfilter *old);
void
bt_devfilter_pkt_set(struct bt_devfilter *filter, uint8_t type);
void
bt_devfilter_pkt_clr(struct bt_devfilter *filter, uint8_t type);
int
bt_devfilter_pkt_tst(const struct bt_devfilter *filter, uint8_t type);
void
bt_devfilter_evt_set(struct bt_devfilter *filter, uint8_t event);
void
bt_devfilter_evt_clr(struct bt_devfilter *filter, uint8_t event);
int
bt_devfilter_evt_tst(const struct bt_devfilter *filter, uint8_t event);
int
bt_devinquiry(const char *name, time_t timeout, int max_rsp, struct bt_devinquiry **iip);
char devname[HCI_DEVNAME_SIZE]; int enabled; /* device is enabled */ /* device information */ bdaddr_t bdaddr; uint8_t features[HCI_FEATURES_SIZE]; uint16_t acl_size; /* max ACL data size */ uint16_t acl_pkts; /* total ACL packet buffers */ uint16_t sco_size; /* max SCO data size */ uint16_t sco_pkts; /* total SCO packet buffers */ /* flow control */ uint16_t cmd_free; /* available CMD packet buffers */ uint16_t acl_free; /* available ACL packet buffers */ uint16_t sco_free; /* available ACL packet buffers */ /* statistics */ uint32_t cmd_sent; uint32_t evnt_recv; uint32_t acl_recv; uint32_t acl_sent; uint32_t sco_recv; uint32_t sco_sent; uint32_t bytes_recv; uint32_t bytes_sent; /* device settings */ uint16_t link_policy_info; uint16_t packet_type_info; uint16_t role_switch_info;
Because a Bluetooth device must be enabled in order to retrieve information, the enabled flag should be tested to be non-zero before relying on further data.
The default filter on the socket will only allow the HCI Event packets “Command Status” and “Command Complete” to be received.
struct bt_devreq { uint16_t opcode; uint8_t event; void *cparam; size_t clen; void *rparam; size_t rlen; };
bt_devreq() sends an HCI command packet with the given opcode and command parameters of clen bytes at cparam then waits up to timeout seconds for the command to return a “Command Complete” event. In the case where the command returns “Command Status” and an additional event, and where the status indicates that the command is in progress, bt_devreq() will wait for the additional event specified in the request. If required, any response will be copied into the buffer of rlen bytes at rparam, and rlen will be adjusted to indicate the number of bytes stored. bt_devreq() temporarily modifies the socket filter.
struct bt_devinquiry { bdaddr_t bdaddr; uint8_t pscan_rep_mode; uint8_t pscan_period_mode; uint8_t dev_class[3]; uint16_t clock_offset; int8_t rssi; uint8_t data[240]; };
will be stored in the location given by iip and this should be released after use with free(3).
August 3, 2009 | NetBSD 5.99 |