dotstack API Reference  1.10.37
Functions
HID Profile (HIDP)

Functions

bt_bool bt_hid_init (void)
 Initialize HID layer. More...
 
bt_bool bt_hid_listen (bt_hid_session_p session, bt_hid_state_callback_fp callback, bt_hid_get_report_callback_fp get_report_callback, bt_hid_set_report_callback_fp set_report_callback)
 Listen for incoming connections. More...
 
bt_bool bt_hid_connect (bt_hid_session_p session, bt_bdaddr_t *remote_addr, bt_hid_state_callback_fp callback, bt_hid_get_report_callback_fp get_report_callback, bt_hid_set_report_callback_fp set_report_callback)
 Connect to a remote device. More...
 
bt_bool bt_hid_disconnect (bt_hid_session_p session)
 Close connection. More...
 
void bt_hid_unplug (bt_hid_session_p session)
 Unplug device. More...
 
bt_hid_session_p bt_hid_allocate_session (bt_l2cap_mgr_t *l2cap_mgr, void *callback_param)
 Allocate HID session. More...
 
void bt_hid_free_session (bt_hid_session_p session)
 Release HID session. More...
 
bt_bool bt_hid_add_report (bt_hid_session_p session, bt_hid_report_t *report)
 Add report definition to local HID device. More...
 
bt_bool bt_hid_send_report (bt_hid_session_p session, bt_byte channel, bt_byte report_type, bt_byte report_id, bt_bool send_report_id, bt_byte *data, bt_int len, bt_byte tran_type, bt_hid_send_report_callback_fp callback)
 Send report. More...
 

Detailed Description

Function Documentation

bt_bool bt_hid_add_report ( bt_hid_session_p  session,
bt_hid_report_t report 
)

Add report definition to local HID device.

This function add a report definitions to the specified HID session.

Parameters
sessionThe HID session which a report definition to be added to.
reportThe report definition to be added.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise.
bt_hid_session_p bt_hid_allocate_session ( bt_l2cap_mgr_t l2cap_mgr,
void *  callback_param 
)

Allocate HID session.

This function allocates a new HID session.

Parameters
l2cap_mgrThe L2CAP manager on which the HID session is to be created.
Returns
  • A pointer to the new HID session structure if the function succeeds.
  • NULL otherwise.
bt_bool bt_hid_connect ( bt_hid_session_p  session,
bt_bdaddr_t *  remote_addr,
bt_hid_state_callback_fp  callback,
bt_hid_get_report_callback_fp  get_report_callback,
bt_hid_set_report_callback_fp  set_report_callback 
)

Connect to a remote device.

This function establishes a HID connection with a remote device. Changes in the session state are reported through a callback function.

Parameters
sessionHID session.
remote_addrAddress of the remote device.
callbackThe callback function that is called when session state changes.
get_report_callbackThe callback function that is called when a remote device requests an INPUT report.
set_report_callbackThe callback function that is called when a remote device sends and OUTPUT report.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise. The callback function is not called in this case.
bt_bool bt_hid_disconnect ( bt_hid_session_p  session)

Close connection.

This function closes a HID connection with a remote device. Changes in the session state are reported through a callback function set when connection was created by calling bt_hid_connect.

Parameters
sessionHID session.
void bt_hid_free_session ( bt_hid_session_p  session)

Release HID session.

This function deallocated the specified HID session. This function does not disconnect the session. It just frees the memory used by the bt_hid_session structure. The session has to be disconnected by calling bt_hid_disconnect or bt_hid_unplug first.

Parameters
sessionThe HID session to be deallocated.
bt_bool bt_hid_init ( void  )

Initialize HID layer.

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

bt_bool bt_hid_listen ( bt_hid_session_p  session,
bt_hid_state_callback_fp  callback,
bt_hid_get_report_callback_fp  get_report_callback,
bt_hid_set_report_callback_fp  set_report_callback 
)

Listen for incoming connections.

This function enables incoming connections on the specified HID session. Changes in the session state are reported through a callback function.

Parameters
sessionHID session.
callbackThe callback function that is called when session state changes.
get_report_callbackThe callback function that is called when a remote device requests an INPUT report.
set_report_callbackThe callback function that is called when a remote device sends and OUTPUT report.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise. The callback function is not called in this case.
bt_bool bt_hid_send_report ( bt_hid_session_p  session,
bt_byte  channel,
bt_byte  report_type,
bt_byte  report_id,
bt_bool  send_report_id,
bt_byte *  data,
bt_int  len,
bt_byte  tran_type,
bt_hid_send_report_callback_fp  callback 
)

Send report.

This function sends a report to a remote device

Parameters
sessionThe HID session.
channelThe type of the channel (CONTROL or INTERRUPT) used to send the report.
report_typeThe type of the report (INPUT, OUTPUR, or FEATURE).
report_idThe id of the report.
send_report_idThe flag that specifies weather the report id is included in the data packet.
dataThe pointer to the report data.
lenThe length of the report data.
tran_typeThe type of the transaction (see definition of the HID_TRANTYPE constants).
callbackThe callback function that is called when sending the report has been completed.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise. The callback function is not called in this case.
void bt_hid_unplug ( bt_hid_session_p  session)

Unplug device.

This function unplugs a virtually-cabled device Changes in the session state are reported through a callback function set when connection was created by calling bt_hid_connect.

Parameters
sessionHID session.