Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

bt_devreq(3) [netbsd man page]

BT_DEV(3)						   BSD Library Functions Manual 						 BT_DEV(3)

NAME
bt_devaddr, bt_devname, bt_devenum, bt_devinfo, bt_devopen, bt_devsend, bt_devrecv, bt_devreq, bt_devfilter, bt_devfilter_pkt_set, bt_devfilter_pkt_clr, bt_devfilter_pkt_tst, bt_devfilter_evt_set, bt_devfilter_evt_clr, bt_devfilter_evt_tst, bt_devinquiry -- Bluetooth device access routines LIBRARY
Bluetooth Library (libbluetooth, -lbluetooth) SYNOPSIS
#include <bluetooth.h> 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); DESCRIPTION
These routines are designed to provide access to locally configured Bluetooth devices in an operating system independent manner via a socket providing access to Bluetooth HCI packets. FUNCTIONS
bt_devaddr(name, bdaddr) Return a Bluetooth device address. bt_devaddr() will return 1 if the NUL-terminated name string refers to a Bluetooth device present in the system, otherwise 0. The name may be given as a device name (eg "ubt0") or Bluetooth device address (eg "00:11:22:33:44:55") and the actual device address will be written to bdaddr if not NULL. bt_devname(name, bdaddr) Return a Bluetooth device name. bt_devname() returns 1 if the bdaddr refers to a Bluetooth device present in the system, otherwise 0. The name buffer, if given, should have space for at least HCI_DEVNAME_SIZE bytes and the string will be NUL-terminated. bt_devenum(cb, arg) Enumerate Bluetooth devices present in the system. For each device found, the cb function (if not NULL) will be called with the arg argument provided, a fully populated bt_devinfo structure and, where the device is enabled, a socket handle as returned by bt_devopen(). The callback function can halt the enumeration by returning a non-zero value, and bt_devenum() returns the number of successfully enumerated devices. bt_devinfo(name, info) Obtain information from a Bluetooth device present in the system. The info argument is a pointer to a bt_devinfo structure into which information about device name is placed. The bt_devinfo structure contains at least the following members: 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. bt_devopen(name, flags) Return a Bluetooth HCI socket handle bound and connected to the named Bluetooth device or, if name is NULL, enabled to receive packets from any device. The socket should be closed using close(2) after use. Any combination of the following flags may be used to pre-set the socket options: BTOPT_DIRECTION Enable control messages on each packet indicating the direction of travel. BTOPT_TIMESTAMP Enable control messages providing packet timestamps. The default filter on the socket will only allow the HCI Event packets "Command Status" and "Command Complete" to be received. bt_devsend(s, opcode, param, plen) Send an HCI command packet on the socket s. The opcode should be in host byte order and the param and plen arguments can be used to provide command parameter data. bt_devsend() will return the number of bytes successfully written. bt_devrecv(s, buf, size, timeout) Receive a single HCI packet on the socket s. bt_devrecv() will return the number of bytes successfully received unless the provided buffer could not contain the entire packet, or if a timeout was requested with a non-negative timeout value. bt_devreq(s, req, timeout) Make an HCI request on the socket s. The req argument is a pointer to a bt_devreq structure, defined as: 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. bt_devfilter(s, new, old) Update or extract the packet filter on HCI socket s. Filters can be set to indicate packet types (Commands, Events, ACL and SCO data), and individual event IDs. Where old is given, the currently set filter will be extracted first, then if new is given, the filter will be updated. bt_devfilter_pkt_set(filter, type) Set packet type in filter. bt_devfilter_pkt_clr(filter, type) Clear packet type from filter. bt_devfilter_pkt_tst(filter, type) Test if filter has packet type set. bt_devfilter_evt_set(filter, event) Set event ID in filter. bt_devfilter_evt_clr(filter, event) Clear event ID from filter. bt_devfilter_evt_tst(filter, event) Test if filter has event ID set. bt_devinquiry(name, timeout, max_rsp, iip) Perform a Bluetooth Inquiry using the device name, or the first available device if NULL is passed. The inquiry length will be timeout seconds, and the number of responses (up to a limit of max_rsp) will be returned. A pointer to an array of bt_devinquiry structures, defined as: 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). RETURN VALUES
These Bluetooth device access routines return -1 on failure, and errno will be set to indicate the error. ERRORS
In addition to errors returned by the standard C library IO functions, the following errors may be indicated by device access routines. [EINVAL] A provided function argument was not valid. [EIO] A device response was not properly understood. [ETIMEDOUT] An operation exceeded the given time limit. SEE ALSO
bluetooth(3) HISTORY
The Bluetooth device access API was created by Maksim Yevmenkin and first appeared in FreeBSD. This implementation written for NetBSD by Iain Hibbert. BSD
October 25, 2011 BSD
Man Page