dotstack API Reference  1.10.37
Modules | Data Structures | Typedefs | Functions
Audio/Video Control Transport Protocol (AVCTP)

AVCTP is the transport mechanisms used to exchange messages for controlling Audio and/or Video devices. More...

Modules

 Configuration
 This module describes parameters used to configure AVCTP layer.
 

Data Structures

struct  bt_avctp_evt_channel_connected_t
 Parameter to AVCTP_EVT_CHANNEL_CONNECTED event. More...
 
struct  bt_avctp_evt_channel_disconnected_t
 Parameter to AVCTP_EVT_CHANNEL_DISCONNECTED event. More...
 
struct  bt_avctp_evt_connection_failed_t
 Parameter to AVCTP_EVT_CONNECTION_FAILED event. More...
 
struct  bt_avctp_evt_command_received_t
 Parameter to AVCTP_EVT_COMMAND_RECEIVED event. More...
 
struct  bt_avctp_evt_response_received_t
 Parameter to AVCTP_EVT_RESPONSE_RECEIVED event. More...
 
struct  bt_avctp_evt_command_sent_t
 Parameter to AVCTP_EVT_COMMAND_SENT event. More...
 
struct  bt_avctp_evt_command_cancelled_t
 Parameter to AVCTP_EVT_COMMAND_CANCELLED event. More...
 
struct  bt_avctp_evt_response_sent_t
 Parameter to AVCTP_EVT_RESPONSE_SENT event. More...
 
struct  bt_avctp_evt_response_cancelled_t
 Parameter to AVCTP_EVT_RESPONSE_CANCELLED event. More...
 
union  bt_avctp_event_t
 Parameter to an application callback. More...
 
struct  bt_avctp_message_t
 AVCTP message description. More...
 
struct  bt_avctp_transport_t
 AVCTP transport description. More...
 
struct  bt_avctp_channel_t
 AVCTP channel description. More...
 
struct  bt_avctp_mgr_t
 AVCTP manager. More...
 

Typedefs

typedef void(* bt_avctp_mgr_callback_fp) (struct _bt_avctp_mgr_t *mgr, bt_byte evt, bt_avctp_event_t *evt_param, void *callback_param)
 AVCTP application callback. More...
 

Functions

bt_avctp_mgr_t * bt_avctp_get_mgr (void)
 Return a pointer to an instance of the AVCTP manager. More...
 
void bt_avctp_init (void)
 Initialize the AVCTP layer. More...
 
void bt_avctp_set_callback (bt_avctp_mgr_t *mgr, bt_avctp_mgr_callback_fp callback, void *callback_param)
 Register a AVCTP application callback. More...
 
bt_avctp_channel_t * bt_avctp_create_channel (bt_avctp_mgr_t *mgr, bt_uint profile_id, bt_int psm, bt_byte l2cap_mode)
 Allocate AVCTP channel. More...
 
bt_avctp_channel_t * bt_avctp_create_outgoing_channel (bt_avctp_mgr_t *mgr, bt_uint profile_id, bt_int psm, bt_byte l2cap_mode)
 Allocate AVCTP channel. More...
 
bt_bool bt_avctp_destroy_channel (bt_avctp_channel_t *channel)
 Destroy AVCTP channel. More...
 
bt_bool bt_avctp_listen (bt_avctp_channel_t *channel)
 Listen for incoming connections. More...
 
void bt_avctp_cancel_listen (bt_avctp_channel_t *channel)
 Cancel listening for incoming connections. More...
 
bt_byte bt_avctp_get_channel_state (bt_avctp_channel_t *channel)
 Get channel state. More...
 
bt_bdaddr_t * bt_avctp_get_channel_remote_address (bt_avctp_channel_t *channel)
 Get channel's remote BT address. More...
 
bt_bool bt_avctp_connect (bt_avctp_channel_t *channel, bt_bdaddr_t *remote_address, bt_uint acl_config)
 Connect to a remote device. More...
 
bt_bool bt_avctp_disconnect (bt_avctp_channel_t *channel)
 Disconnect from a remote device. More...
 
bt_bool bt_avctp_send_command (bt_avctp_channel_t *channel, bt_byte *data, bt_uint data_len, bt_byte *tran_id)
 Send a command message to a remote device. More...
 
bt_bool bt_avctp_send_response (bt_avctp_channel_t *channel, bt_byte tran_id, bt_byte *data, bt_uint data_len)
 Send a response message to a remote device. More...
 
void bt_avctp_cancel_command (bt_avctp_channel_t *channel, bt_byte tran_id)
 Cancel a command message. More...
 
void bt_avctp_cancel_response (bt_avctp_channel_t *channel, bt_byte tran_id)
 Cancel a response message. More...
 
bt_hci_conn_state_t * bt_avctp_get_hci_connection (bt_avctp_channel_t *channel)
 Get HCI connection for a channel. More...
 

Detailed Description

AVCTP is the transport mechanisms used to exchange messages for controlling Audio and/or Video devices.

The actual message contents are defined in the applicable A/V control profiles.

Typedef Documentation

typedef void(* bt_avctp_mgr_callback_fp) (struct _bt_avctp_mgr_t *mgr, bt_byte evt, bt_avctp_event_t *evt_param, void *callback_param)

AVCTP application callback.

In order to be notified of various events a consumer of the AVCTP layer has to register a callback function (done with bt_avctp_set_callback()). The stack will call that function whenever a new event has been generated.

Parameters
mgrAVCTP manager.
evtAVCTP event. The event can be one of the following values:
  • AVCTP_EVT_CHANNEL_CONNECTED Channel connected.
  • AVCTP_EVT_CHANNEL_DISCONNECTED Channel disconnected.
  • AVCTP_EVT_CONNECTION_FAILED Channel connection failed (generated only if connection has been initiated by the local device).
  • AVCTP_EVT_COMMAND_RECEIVED Command received.
  • AVCTP_EVT_RESPONE_RECEIVED Response received.
  • AVCTP_EVT_COMMAND_SENT Command sent.
  • AVCTP_EVT_RESPONSE_SENT Response sent.
  • AVCTP_EVT_COMMAND_CANCELLED Command canceled.
  • AVCTP_EVT_RESPONSE_CANCELLED Response canceled.
evt_paramEvent parameter. Which member of the bt_avctp_event_t union is valid depends on the event:
callback_paramA pointer to an arbitrary data set by a call to bt_avctp_set_callback.

Function Documentation

void bt_avctp_cancel_command ( bt_avctp_channel_t *  channel,
bt_byte  tran_id 
)

Cancel a command message.

If a message has not yet been sent to the remote device, it can be canceled (i.e. removed from send queue) by calling this function.

Parameters
channelAVCTP channel.
tran_idTransaction Id. This value is obtained by calling bt_avctp_send_command.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise. No events will be generated.
void bt_avctp_cancel_listen ( bt_avctp_channel_t *  channel)

Cancel listening for incoming connections.

This function stops listening for incoming connections on the specified channel.

Parameters
channelAVCTP channel.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise.
void bt_avctp_cancel_response ( bt_avctp_channel_t *  channel,
bt_byte  tran_id 
)

Cancel a response message.

If a message has not yet been sent to the remote device, it can be canceled (i.e. removed from send queue) by calling this function.

Parameters
channelAVCTP channel.
tran_idTransaction Id. This value is obtained by calling bt_avctp_send_command.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise. No events will be generated.
bt_bool bt_avctp_connect ( bt_avctp_channel_t *  channel,
bt_bdaddr_t *  remote_address,
bt_uint  acl_config 
)

Connect to a remote device.

This function establishes a connection to a remote device specified by the remote_address. If connection cannot be initiated for some reason, for example, there is not enough resources, it returns FALSE and no events are generated. Otherwise the result of an attempt to connect to the remote device is reported via the AVCTP callback. The events generated will either be AVCTP_EVT_CHANNEL_CONNECTED or AVCTP_EVT_CONNECTION_FAILED.

Parameters
channelAVCTP channel.
remote_addressThe address of a remote device.
acl_configACL link configuration. This can be a combination of the following values:
  • HCI_CONFIG_ENABLE_AUTHENTICATION
  • HCI_CONFIG_ENABLE_ENCRYPTION
  • HCI_CONFIG_BECOME_MASTER
Returns
  • TRUE if connection establishment has been started.
  • FALSE otherwise.
bt_avctp_channel_t* bt_avctp_create_channel ( bt_avctp_mgr_t *  mgr,
bt_uint  profile_id,
bt_int  psm,
bt_byte  l2cap_mode 
)

Allocate AVCTP channel.

This function allocates a new incoming AVCTP channel. The channel is intended to be used to accept a connection from a remote device. There can be only one channel for each combination of profile_id and psm.

Parameters
mgrAVCTP manager.
profile_idProfile Id
psmThe PSM on which the underlying L2CAP channel will listen and accept incoming connections.
l2cap_modeUnderlying L2CAP channel mode. This currently can only be CMODE_BASIC.
Returns
  • A pointer to the new AVCTP channel if the function succeeds.
  • NULL otherwise.
bt_avctp_channel_t* bt_avctp_create_outgoing_channel ( bt_avctp_mgr_t *  mgr,
bt_uint  profile_id,
bt_int  psm,
bt_byte  l2cap_mode 
)

Allocate AVCTP channel.

This function allocates a new outgoing AVCTP channel. The channel is intended to be used to create a connection to a remote device. There can be multiple channels with the same profile_id and psm.

Parameters
mgrAVCTP manager.
profile_idProfile Id
psmThe PSM on which the underlying L2CAP channel will listen and accept incoming connections.
l2cap_modeUnderlying L2CAP channel mode. This currently can only be CMODE_BASIC.
Returns
  • A pointer to the new AVCTP channel if the function succeeds.
  • NULL otherwise.
bt_bool bt_avctp_destroy_channel ( bt_avctp_channel_t *  channel)

Destroy AVCTP channel.

This function frees memory used by the channel. The channel has to exist and be in the "idle" state for this function to succeed. I.e. the channel has to be disconnected before this function can be called.

Parameters
channelAVCTP channel.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise.
bt_bool bt_avctp_disconnect ( bt_avctp_channel_t *  channel)

Disconnect from a remote device.

This function closes a connection to a remote device.

Parameters
channelAVCTP channel.
Returns
  • TRUE if disconnection has been started.
  • FALSE otherwise. No events will be generated.
bt_bdaddr_t* bt_avctp_get_channel_remote_address ( bt_avctp_channel_t *  channel)

Get channel's remote BT address.

This function returns the address of the remote device associated with the channel.

Parameters
channelAVCTP channel.
Returns
  • The address of the remote device if channel is connected.
  • NULL otherwise.
bt_byte bt_avctp_get_channel_state ( bt_avctp_channel_t *  channel)

Get channel state.

This function return current state of the specified channel

Parameters
channelAVCTP channel.
Returns
  • AVCTP_CHANNEL_STATE_FREE
  • AVCTP_CHANNEL_STATE_IDLE
  • AVCTP_CHANNEL_STATE_CONNECTING
  • AVCTP_CHANNEL_STATE_CONNECTED
  • AVCTP_CHANNEL_STATE_DISCONNECTING
bt_hci_conn_state_t* bt_avctp_get_hci_connection ( bt_avctp_channel_t *  channel)

Get HCI connection for a channel.

This function returns a pointer to a structure that describes an HCI connection a channel is open on. The return value can be used to call various function from the HCI layer. For example, if an app wants to force disconnection from a remote device it can call bt_hci_disconnect.

Parameters
channelAVCTP channel.
Returns
  • Pointer to a structure that describes an HCI connection if the function succeeds.
  • NULL otherwise. The function fails only if a channel specified by the channel parameter
  • does not exist or there is no HCI connection between local and remote devices associated with the channel.
bt_avctp_mgr_t* bt_avctp_get_mgr ( void  )

Return a pointer to an instance of the AVCTP manager.

This function returns a pointer to an instance of the AVCTP manager. There is only one instance of the manager allocated by the stack.

void bt_avctp_init ( void  )

Initialize the AVCTP layer.

This function initializes the AVCTP layer of the stack. It must be called prior to any other AVCTP function can be called.

bt_bool bt_avctp_listen ( bt_avctp_channel_t *  channel)

Listen for incoming connections.

This function enables incoming connections on the specified AVCTP channel.

Parameters
channelAVCTP channel.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise.
bt_bool bt_avctp_send_command ( bt_avctp_channel_t *  channel,
bt_byte *  data,
bt_uint  data_len,
bt_byte *  tran_id 
)

Send a command message to a remote device.

This function sends a command message to a remote device.

Parameters
channelAVCTP channel.
dataMessage body.
data_lenMessage body length.
tran_idPointer to a bt_byte where AVRCP will write transaction id assigned to the message.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise. No events will be generated.
bt_bool bt_avctp_send_response ( bt_avctp_channel_t *  channel,
bt_byte  tran_id,
bt_byte *  data,
bt_uint  data_len 
)

Send a response message to a remote device.

This function sends a response message to a remote device.

Parameters
channelAVCTP channel.
tran_idTransaction Id. This value is obtained by calling bt_avctp_send_command.
dataMessage body.
data_lenMessage body length.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise. No events will be generated.
void bt_avctp_set_callback ( bt_avctp_mgr_t *  mgr,
bt_avctp_mgr_callback_fp  callback,
void *  callback_param 
)

Register a AVCTP application callback.

In order to be notified of various events a consumer of the AVCTP layer has to register a callback function. The stack will call this function whenever a new event has been generated passing the code of the event as the second parameter. The event can be one of the following values:

  • AVCTP_EVT_CHANNEL_CONNECTED Channel connected.
  • AVCTP_EVT_CHANNEL_DISCONNECTED Channel disconnected.
  • AVCTP_EVT_CONNECTION_FAILED Channel connection failed (generated only if connection has been initiated by the local device).
  • AVCTP_EVT_COMMAND_RECEIVED Command received.
  • AVCTP_EVT_RESPONE_RECEIVED Response received.
  • AVCTP_EVT_COMMAND_SENT Command sent.
  • AVCTP_EVT_RESPONSE_SENT Response sent.
  • AVCTP_EVT_COMMAND_CANCELLED Command canceled.
  • AVCTP_EVT_RESPONSE_CANCELLED Response canceled.
Parameters
mgrAVCTP manager.
callbackThe callback function that will be called when the AVCTP generates an event.
callback_paramA pointer to arbitrary data to be passed to the callback callback.