@@ -36,7 +36,7 @@ extern "C" {
36
36
typedef enum {
37
37
ESP_PEER_STATE_CLOSED = 0 , /*!< Closed */
38
38
ESP_PEER_STATE_DISCONNECTED = 1 , /*!< Disconnected */
39
- ESP_PEER_STATE_NEW_CONNECTION = 2 , /*!< New connection comming */
39
+ ESP_PEER_STATE_NEW_CONNECTION = 2 , /*!< New connection coming */
40
40
ESP_PEER_STATE_PAIRING = 3 , /*!< Under candidate pairing */
41
41
ESP_PEER_STATE_PAIRED = 4 , /*!< Candidate pairing success */
42
42
ESP_PEER_STATE_CONNECTING = 5 , /*!< Building connection with peer */
@@ -45,7 +45,7 @@ typedef enum {
45
45
ESP_PEER_STATE_DATA_CHANNEL_CONNECTED = 8 , /*!< Data channel is connected */
46
46
ESP_PEER_STATE_DATA_CHANNEL_OPENED = 9 , /*!< Data channel is opened */
47
47
ESP_PEER_STATE_DATA_CHANNEL_CLOSED = 10 , /*!< Data channel is closed */
48
- ESP_PEER_STATE_DATA_CHANNEL_DISCONNECTED = 11 , /*!< Data channel is disconencted */
48
+ ESP_PEER_STATE_DATA_CHANNEL_DISCONNECTED = 11 , /*!< Data channel is disconnected */
49
49
} esp_peer_state_t ;
50
50
51
51
/**
@@ -161,10 +161,25 @@ typedef struct {
161
161
} esp_peer_msg_t ;
162
162
163
163
/**
164
- * @brief Peer data channel configuration for create
164
+ * @brief Reliable type for peer data channel
165
+ */
166
+ typedef enum {
167
+ ESP_PEER_DATA_CHANNEL_RELIABLE , /*!< Reliable data channel with guaranteed delivery */
168
+ ESP_PEER_DATA_CHANNEL_PARTIAL_RELIABLE_TIMEOUT , /*!< Unreliable by lifetime (maxPacketLifeTime) */
169
+ ESP_PEER_DATA_CHANNEL_PARTIAL_RELIABLE_RETX , /*!< Unreliable by max retransmits (maxRetransmits) */
170
+ } esp_peer_data_channel_reliable_type_t ;
171
+
172
+ /**
173
+ * @brief Configuration for peer data channel
165
174
*/
166
175
typedef struct {
167
- char * label ; /*!< Data channel label */
176
+ esp_peer_data_channel_reliable_type_t type ; /*!< Reliability type */
177
+ bool ordered ; /*!< true = ordered delivery, false = unordered */
178
+ char * label ; /*!< Data channel label */
179
+ union {
180
+ uint16_t max_retransmit_count ; /*!< Only valid if type is ESP_PEER_DATA_CHANNEL_PARTIAL_RELIABLE_RETX */
181
+ uint16_t max_packet_lifetime ; /*!< Only valid if type is ESP_PEER_DATA_CHANNEL_PARTIAL_RELIABLE_TIMEOUT (in milliseconds) */
182
+ };
168
183
} esp_peer_data_channel_cfg_t ;
169
184
170
185
/**
@@ -196,6 +211,7 @@ typedef struct {
196
211
bool enable_data_channel ; /*!< Enable data channel */
197
212
bool manual_ch_create ; /*!< Manual create data channel
198
213
When SCTP role is client, it will try to send DCEP automatically
214
+ The default configuration are ordered, partial reliable timeout when use peer_default
199
215
To disable this behavior can create data channel manually and set this flag
200
216
*/
201
217
void * extra_cfg ; /*!< Extra configuration */
@@ -257,7 +273,7 @@ typedef struct {
257
273
* @return Status code indicating success or failure.
258
274
*/
259
275
int (* on_channel_open )(esp_peer_data_channel_info_t * ch , void * ctx );
260
-
276
+
261
277
/**
262
278
* @brief Peer data frame callback
263
279
* @param[in] frame Data frame information
@@ -414,7 +430,7 @@ int esp_peer_new_connection(esp_peer_handle_t peer);
414
430
* @brief Manually create data channel
415
431
*
416
432
* @note It will send DCEP event to peer until data channel created
417
- *
433
+ *
418
434
* @param[in] peer Peer handle
419
435
* @param[in] ch_cfg Configuration for data channel creation
420
436
*
@@ -505,6 +521,7 @@ int esp_peer_send_audio(esp_peer_handle_t peer, esp_peer_audio_frame_t *info);
505
521
* - ESP_PEER_ERR_NONE Open peer connection success
506
522
* - ESP_PEER_ERR_INVALID_ARG Invalid argument
507
523
* - ESP_PEER_ERR_NOT_SUPPORT Not support
524
+ * - ESP_PEER_ERR_WOULD_BLOCK Data channel buffer is full, need sleep some time and retry later
508
525
*/
509
526
int esp_peer_send_data (esp_peer_handle_t peer , esp_peer_data_frame_t * frame );
510
527
0 commit comments