SPP flow control

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
maze_1672671
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

Hello guys,

 

I am looking at spp.c

 

spp_rx_data_callback is very simple, it returns the result of echoing the data:

return wiced_bt_spp_send_session_data(handle, p_data, data_len);

 

What happens when the callback returns WICED_FALSE?

What is the role of wiced_bt_spp_rx_flow_enable()?

1 Solution
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

1. The credit number is different for each connection. It is a negotiated value during the connection.

2. You may use a software ack mechanism for such function. The host ack for each packet from the spp. If there is no ACK, the peer device can stop to send data.

View solution in original post

0 Likes
9 Replies
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

Please refer to the description for the API. If data is scheduled for transmission, it will return WICED_TRUE, otherwise WICED_FALSE.

/**
* Send data over the established External Accessory connection. The session must
* be SPP_EA_SESSION_ID. The first 2 octets of the p_data must be the handle
* passed to the application in the wiced_bt_spp_connection_up_callback in the big
* endian format.
*
* @param[in] handle : Connection handle indicated in the connection up callback
* @param[in] p_data : Pointer to buffer with data to send.
* @param[in] len : Length of the data + handle
* @return WICED_TRUE: if data is scheduled for transmission, otherwise WICED_FALSE
*/
wiced_bool_t wiced_bt_spp_send_session_data(uint16_t handle, uint8_t *p_data, uint32_t len);

 

The flow control API is used to enable/disable the local RX flow control.

0 Likes
maze_1672671
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

Hello Owen_Zhang123,

I believe there was a misunderstanding, so I will answer the same things differently

Please tell me if these sentences are right or wrong:

1) when wiced_bt_spp_reg_t.wiced_bt_spp_rx_data_callback_t return WICED_FALSE, the remote device stops sending its data

2) wiced_bt_spp_reg_t.wiced_bt_spp_rx_data_callback_t return value is ignored

3) when wiced_bt_spp_rx_flow_enable(h, WICED_FALSE) is called, the remote device stops sending its data. We must call wiced_bt_spp_rx_flow_enable(h, WICED_TRUE) to resume reception

0 Likes

The return value is ignored, please refer to the following description:

/**
* Rx Data callback passed to the application data received over the SPP
* session.
*
* @param[in] handle : Handle that identifies the external accessory session
* @param[in] p_data : Pointer to buffer with data.
* @param[in] data_len : Length of the data
* @return none
*/
typedef wiced_bool_t (*wiced_bt_spp_rx_data_callback_t)(uint16_t handle, uint8_t* data, uint32_t data_len);

 

when wiced_bt_spp_rx_flow_enable(h, WICED_FALSE) is called, the flow control is disabled. The API is used to enable/disable the flow control for SPP.

0 Likes
maze_1672671
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

The description is an example of a bad comment: return none means that the return type is void

Below an example of a disabled flow control:

maze_1672671_0-1644400603740.png

I would like to know how to stop the remote from sending data, like RTS# on a wired uart.

0 Likes

You can't stop the remote from sending data. 

As a workaround, you can disconnect the spp connection.

0 Likes
maze_1672671
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

You told me:

when wiced_bt_spp_rx_flow_enable(h, WICED_FALSE) is called, the flow control is disabled. The API is used to enable/disable the flow control for SPP.

but we don't have a wireless RTS#, so what is the effect of wiced_bt_spp_rx_flow_enable?

0 Likes

The flow control is controlled by the low level RFCOMM. It is a credit-based  and TS 07.10 flow control mechanisms controlled by the stack. It is used to make sure the data buffer will not over flow.

0 Likes
maze_1672671
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

Thank you @Owen_Zhang123 for the clarification

Question 1:

Can you explain how can I choose how many credit to use? As an example, how can I set two credits?

Question 2:

In our device, cyw20706 will be connected to a micro with a full uart; spp will not be used by cyw20706, cyw20706  must route data to the micro.

We must avoid the flooding of data from the remote device, specially during ota update, when the micro must erase its flash.

How can I achieve this goal?

0 Likes
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

1. The credit number is different for each connection. It is a negotiated value during the connection.

2. You may use a software ack mechanism for such function. The host ack for each packet from the spp. If there is no ACK, the peer device can stop to send data.

0 Likes