The following functions are related to the Bluetooth Device API.
hci_attach(hci_if, dev)
Attach Bluetooth HCI device
dev to the protocol stack in the manner described by
hci_if. Driver quirks may be registered by passing the corresponding
BTF_xxxx flag in the
flags argument.
hci_attach() will return a
struct hci_unit handle to be passed to the protocol stack in other calls.
hci_detach(unit)
Detach Bluetooth HCI unit from the device.
hci_input_event(unit, mbuf)
This function should be called by the device when it has an event packet to present to the protocol stack. It may be called from an interrupt routine at the ipl value given in the hci_if descriptor.
hci_input_acl(unit, mbuf)
This function should be called by the device when it has an ACL data packet to present to the protocol stack. It may be called from an interrupt routine at the ipl value given in the hci_if descriptor.
hci_input_sco(unit, mbuf)
This function should be called by the device when it has an SCO data packet to present to the protocol stack. It may be called from an interrupt routine at the ipl value given in the hci_if descriptor.
(*enable)(dev)
This will be called when the protocol stack wishes to enable the device.
(*disable)(dev)
This will be called when the protocol stack wishes to disable the device.
(*output_cmd)(dev, mbuf)
Will be called to output command packets on the device. The device is responsible for arbitrating access to the output queue, and output commands should be sent asynchronously. The device owns the mbuf and should release it when sent.
(*output_acl)(dev, mbuf)
Will be called to output ACL data packets on the device. The device is responsible for arbitrating access to the output queue, and ACL data packets should be sent asynchronously. The device owns the mbuf and should release it when sent.
(*output_sco)(dev, mbuf)
Will be called to output SCO data packets on the device. The device is responsible for arbitrating access to the output queue, and SCO data packets should be sent asynchronously. When the SCO data packet has been placed on the device and the mbuf is no longer required, it should be returned to the Bluetooth protocol stack via the hci_complete_sco() call.
(*get_stats)(dev, dest, flush)
Will be called when IO statistics are requested. The bt_stats structure dest should be filled in, and if the flush argument is true, statistics should be reset.
The following function definitions are related to the Bluetooth Protocol API. Note that the "btproto" prefix is representative only, the protocol being used will have a more specific prefix with prototypes being declared in the appropriate
<netbt/btproto.h> file.
btproto_attach(handle_ptr, proto, ref)
Allocate and initialize a new protocol object at the handle_ptr address that should subsequently be passed into the other functions. proto is a pointer to the btproto structure as described above containing relevant callbacks, and ref is the argument that will be supplied to those calls.
btproto_bind(handle, addr)
Set the local address of the protocol object described by handle to addr.
btproto_sockaddr(handle, addr)
Copy the local address of the protocol object described by handle into addr
btproto_connect(handle, addr)
Initiate a connection by the protocol object described by handle to the remote device described by addr. This will result in a call to either proto->connected() or proto->disconnected(), and optionally proto->connecting() with the appropriate reference as given to btproto_attach().
btproto_peeraddr(handle, addr)
Copy the remote address of the protocol object described by handle into addr.
btproto_disconnect(handle, linger)
Schedule a disconnection by the protocol object described by handle. This will result in a call to proto->disconnected() with the appropriate reference when the connection is torn down. If linger is zero, the disconnection will be initiated immediately and any outstanding data may be lost.
btproto_detach(handle_ptr)
Detach the protocol object described by the value in the location of handle_ptr, and free any related memory. The pointer in the location is cleared.
btproto_listen(handle)
Use the protocol object described by handle as a listening post. This will result in calls to the proto->newconn() function when incoming connections are detected.
btproto_send(handle, mbuf)
Send data on the connection described by the protocol object.
btproto_rcvd(handle, space)
Indicate to the protocol that space is now available in the input buffers so that flow control may be deasserted. This should also be called to indicate initial buffer space. Note that space is an absolute value.
btproto_setopt(handle, optarg, arg)
Set options on the protocol object described by handle.
btproto_getopt(handle, optarg, arg)
Get options for the protocol object described by handle.
(*connecting)(ref)
This function will be called when the protocol receives information that the connection described by ref is pending.
(*connected)(ref)
This function will be called when the connection described by ref is successful and indicates that data may now be sent.
(*disconnected)(ref, error)
This function will be called when the connection described by ref is disconnected.
*(*newconn)(ref, laddr, raddr)
This function will be called when the protocol receives a new incoming connection on the local device described by laddr from the remote device described by raddr. The protocol should decide if it wishes to accept the connection and should attach and return a new instance of the relevant protocol handle or NULL.
(*complete)(ref, count)
This function will be called when the protocol has completed sending data. Complete will usually mean that the data has successfully left the device though for guaranteed protocols it can mean that the data has arrived at the other end and been acknowledged, and that count amount of data can be removed from the socket buffer. The units of the count value will be dependent on the protocol being used (e.g. RFCOMM is bytes, but L2CAP is packets)
(*linkmode)(ref, mode)
This function will be called for established connections, when the link mode of the baseband link has changed. mode is the new mode.
(*input)(ref, mbuf)
This function is called to supply new data on the connection described by ref.