Bluetooth RFC Protocol

group BT_RFC

Provide BT RFC protocol interfaces.

Typedefs

typedef enum t_bt_rfc_msg_type T_BT_RFC_MSG_TYPE

BT RFCOMM message type.

typedef struct t_bt_rfc_conn_ind T_BT_RFC_CONN_IND

Indication of RFCOMM connection request from remote device. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_CONN_IND.

typedef struct t_bt_rfc_conn_cmpl T_BT_RFC_CONN_CMPL

Indication of completion of creating RFCOMM connection. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_CONN_CMPL.

typedef struct t_bt_rfc_disconn_cmpl T_BT_RFC_DISCONN_CMPL

Indication of completion of breaking RFCOMM connection. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_DISCONN_CMPL.

typedef struct t_bt_rfc_data_ind T_BT_RFC_DATA_IND

Indication of RFCOMM data. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_DATA_IND.

typedef struct t_bt_rfc_data_rsp T_BT_RFC_DATA_RSP

Indication RFCOMM data has been sent out. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_DATA_RSP.

typedef struct t_bt_rfc_credit_info T_BT_RFC_CREDIT_INFO

Indication of RFCOMM credits info. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_CREDIT_INFO.

typedef void (*P_BT_RFC_SERVICE_CBACK)(uint8_t bd_addr[6], T_BT_RFC_MSG_TYPE msg_type, void *msg)

RFCOMM message callback definition.

Param bd_addr:

[in] Remote BT address.

Param msg_type:

[in] RFCOMM message type.

Param msg:

[in] Message buffer address.

Enums

enum t_bt_rfc_msg_type

BT RFCOMM message type.

Values:

enumerator BT_RFC_MSG_CONN_IND

RFCOMM connect indicate.

enumerator BT_RFC_MSG_CONN_CMPL

RFCOMM connect successful.

enumerator BT_RFC_MSG_DISCONN_CMPL

RFCOMM disconnect successful.

enumerator BT_RFC_MSG_DATA_IND

RFCOMM data indicate.

enumerator BT_RFC_MSG_CREDIT_INFO

RFCOMM remote credits infomation.

enumerator BT_RFC_MSG_DATA_RSP

RFCOMM data sent out.

Functions

bool bt_rfc_service_register(uint8_t server_chann, P_BT_RFC_SERVICE_CBACK cback)

Register service to RFCOMM.

Parameters:
  • server_chann[in] Server channel number of the registered service.

  • cback[in] Callback function used to handle RFCOMM message.

Return values:
  • true – Registration has been completed successfully.

  • false – Registration was failed to complete.

Returns:

The result of registration.

bool bt_rfc_conn_req(uint8_t bd_addr[6], uint8_t local_server_chann, uint8_t remote_server_chann, uint16_t frame_size, uint8_t init_credits)

Send a request to create a RFCOMM connection.

Parameters:
  • bd_addr[in] Remote BT address.

  • local_server_chann[in] The local server channel of the service that sending this request.

  • remote_server_chann[in] The remote server channel which can be found from the SDP info.

  • frame_size[in] The maximum frame_size supported by local device.

  • init_credits[in] The number of packet that remote can be send. This parameter is used for flow control. A sending entity may send as many frames on a RFCOMM channel as it has credits; if the credit count reaches zero, the sender will stop and wait for further credits from peer.

Return values:
  • true – Request has been sent successfully.

  • false – Request was fail to send.

Returns:

The status of sending connection request.

bool bt_rfc_conn_cfm(uint8_t bd_addr[6], uint8_t local_server_chann, bool accept, uint16_t frame_size, uint8_t init_credits)

Send a confirmation to accept or reject the received RFCOMM connection request.

Parameters:
  • bd_addr[in] Remote BT address.

  • local_server_chann[in] Local server channel.

  • accept[in] Confirmation message.

    • true Accept the received RFCOMM connection request.

    • false Reject the received RFCOMM connection request.

  • frame_size[in] The maximum frame_size supported by local device.

  • credits[in] The number of packet that remote can be send. This parameter is used for flow control. A sending entity may send as many frames on a RFCOMM channel as it has credits; if the credit count reaches zero, the sender will stop and wait for further credits from peer.

Return values:
  • true – The confirmation has been sent successfully.

  • false – The confirmation was fail to send.

Returns:

The result of sending confirmation.

bool bt_rfc_data_send(uint8_t bd_addr[6], uint8_t local_server_chann, uint8_t *buf, uint16_t buf_len, bool ack)

Send a request to send data to remote device.

Parameters:
  • bd_addr[in] Remote BT address.

  • local_server_chann[in] Local server channel.

  • buf[in] The start address of the data buffer.

  • buf_len[in] The length of the data to be sent.

  • ack[in] Enable/disable ACK after data sent.

Return values:
  • true – Data has been sent successfully.

  • false – Data was fail to send.

Returns:

The status of sending data.

bool bt_rfc_credits_give(uint8_t bd_addr[6], uint8_t local_server_chann, uint8_t credits)

Send a confirmation to indicate the number of received packets.

Parameters:
  • bd_addr[in] Remote BT address.

  • local_server_chann[in] Local server channel.

  • credits[in] The number of credit.

Return values:
  • true – The confirmation has been sent successfully.

  • false – The confirmation was fail to send.

Returns:

The result of sending confirmation.

bool bt_rfc_disconn_req(uint8_t bd_addr[6], uint8_t local_server_chann)

Send a request to disconnect a RFCOMM channel.

Parameters:
  • bd_addr[in] Remote BT address.

  • local_server_chann[in] Local server channel.

Return values:
  • true – The request has been sent successfully.

  • false – The request was fail to send.

Returns:

The result of sending request.

struct t_bt_rfc_conn_ind

Indication of RFCOMM connection request from remote device. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_CONN_IND.

Public Members

uint8_t local_server_chann
uint16_t frame_size
struct t_bt_rfc_conn_cmpl

Indication of completion of creating RFCOMM connection. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_CONN_CMPL.

Public Members

uint8_t local_server_chann
uint16_t frame_size
uint8_t remain_credits
struct t_bt_rfc_disconn_cmpl

Indication of completion of breaking RFCOMM connection. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_DISCONN_CMPL.

Public Members

uint8_t local_server_chann
uint16_t cause
struct t_bt_rfc_data_ind

Indication of RFCOMM data. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_DATA_IND.

Public Members

uint8_t local_server_chann
uint8_t remain_credits
uint16_t length
uint8_t *buf
struct t_bt_rfc_data_rsp

Indication RFCOMM data has been sent out. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_DATA_RSP.

Public Members

uint8_t local_server_chann
struct t_bt_rfc_credit_info

Indication of RFCOMM credits info. It will be received in the callback function registered by bt_rfc_service_register with message type as BT_RFC_MSG_CREDIT_INFO.

Public Members

uint8_t local_server_chann
uint8_t remain_credits