MT2523 API Reference  LinkIt SDK v4

The Serial Port Profile (SPP) can be used to emulate a serial port connection using Radio Frequency Communication(RFCOMM) protocol between two peer devices. More...

Overview

The Serial Port Profile (SPP) can be used to emulate a serial port connection using Radio Frequency Communication(RFCOMM) protocol between two peer devices.

It supports server and client roles. The SPP server is implemented for a server side connection (Acceptor). It can wait for another device to take initiative to connect. The SPP client is implemented for a client side connection (Initiator) to initiate a connection with another device.

Terms and Acronyms

Terms Details
UUID A Universally Unique Identifier. For more information, please refer to Wikipedia.
SPP Serial Port Profile. For more information, please refer to Wikipedia.
RFCOMM The Radio Frequency Communication. For more information, please refer to Wikipedia.
SDP Service Discovery Protocol. For more information, please refer to Wikipedia.

How to use this module

Functions

bt_status_t bt_spp_connect (uint32_t *handle, const bt_bd_addr_t *address, const uint8_t *uuid128)
 This function is for the SPP client to connect to a remote server, the BT_SPP_CONNECT_CNF event is reported to indicate the result of the connection. More...
 
bt_status_t bt_spp_connect_response (uint32_t handle, bool accept)
 This function is for the SPP server to accept or reject connection from a remote client, the BT_SPP_CONNECT_CNF event is reported to indicate the result of the response. More...
 
bt_status_t bt_spp_send (uint32_t handle, uint8_t *packet, uint16_t packet_length)
 This function sends data to a remote device. More...
 
bt_status_t bt_spp_disconnect (uint32_t handle)
 This function disconnects an existing connection, the BT_SPP_DISCONNECT_IND event is reported to indicate the result of the disconnection. More...
 
void bt_spp_hold_data (uint8_t *data)
 This function holds the SPP packet until it is fully consumed. More...
 
void bt_spp_release_data (uint8_t *data)
 This function releases the SPP packet after it is consumed. More...
 

Modules

 Define
 This section defines the macros for the SPP.
 
 Struct
 This section defines the structures for the SPP.
 

Function Documentation

bt_status_t bt_spp_connect ( uint32_t *  handle,
const bt_bd_addr_t address,
const uint8_t *  uuid128 
)

This function is for the SPP client to connect to a remote server, the BT_SPP_CONNECT_CNF event is reported to indicate the result of the connection.

Note that this API can only be used by an SPP client.

Parameters
[out]handleis the SPP handle of the current connection.
[in]addressis the Bluetooth address of a remote device.
[in]uuid128is a 128-bit UUID of remote server, such as {0x00,0x00,0x11,0x01,0x00,0x00, 0x10,0x00,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB}.
Returns
BT_STATUS_SUCCESS, the operation completed successfully. BT_STATUS_OUT_OF_MEMORY, out of memory.
bt_status_t bt_spp_connect_response ( uint32_t  handle,
bool  accept 
)

This function is for the SPP server to accept or reject connection from a remote client, the BT_SPP_CONNECT_CNF event is reported to indicate the result of the response.

Note that this API can only be used by the SPP server.

Parameters
[in]handleis the SPP handle of the current connection.
[in]acceptdefines whether the connection is accepted.
Returns
BT_STATUS_SUCCESS, the operation completed successfully. BT_STATUS_FAIL, the operation has failed.
bt_status_t bt_spp_disconnect ( uint32_t  handle)

This function disconnects an existing connection, the BT_SPP_DISCONNECT_IND event is reported to indicate the result of the disconnection.

Parameters
[in]handleis the SPP handle of the current connection.
Returns
BT_STATUS_SUCCESS, the operation completed successfully. BT_STATUS_FAIL, the operation has failed.
void bt_spp_hold_data ( uint8_t *  data)

This function holds the SPP packet until it is fully consumed.

Parameters
[in]datais the initialization parameter. The value is provided once it is called by the SPP.
Returns
None.
void bt_spp_release_data ( uint8_t *  data)

This function releases the SPP packet after it is consumed.

Parameters
[in]datais the initialization parameter. The value is provided once it is called by the SPP.
Returns
None.
bt_status_t bt_spp_send ( uint32_t  handle,
uint8_t *  packet,
uint16_t  packet_length 
)

This function sends data to a remote device.

Parameters
[in]handleis the SPP handle of the current connection.
[in]packetis a pointer to the packet to send to a remote device.
[in]packet_lengthis the length of a packet to send.
Returns
BT_STATUS_SUCCESS, the operation completed successfully. BT_STATUS_FAIL, the operation has failed. BT_STATUS_SPP_TX_NOT_AVAILABLE, if the TX buffer in the local device or the RX buffer in the remote device has no space available. The application should wait for the BT_SPP_READY_TO_SEND_IND event before the next send operation.