1 /*
2  * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef __BTC_SPP_H__
8 #define __BTC_SPP_H__
9 
10 #include "btc/btc_task.h"
11 #include "esp_bt_defs.h"
12 #include "esp_spp_api.h"
13 #include "common/bt_target.h"
14 #include "bta/bta_jv_api.h"
15 
16 #if (defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE)
17 
18 #define ESP_SPP_MAX_SESSION     BTA_JV_MAX_RFC_SR_SESSION
19 #define ESP_SPP_SERVER_NAME_MAX 32
20 
21 #define BTC_SPP_INVALID_SCN 0x00
22 
23 typedef enum {
24     BTC_SPP_ACT_INIT = 0,
25     BTC_SPP_ACT_UNINIT,
26     BTC_SPP_ACT_START_DISCOVERY,
27     BTC_SPP_ACT_CONNECT,
28     BTC_SPP_ACT_DISCONNECT,
29     BTC_SPP_ACT_START_SRV,
30     BTC_SPP_ACT_STOP_SRV,
31     BTC_SPP_ACT_WRITE,
32     BTC_SPP_ACT_VFS_REGISTER,
33     BTC_SPP_ACT_VFS_UNREGISTER,
34 } btc_spp_act_t;
35 
36 /* btc_spp_args_t */
37 typedef union {
38     //BTC_SPP_ACT_INIT
39     struct init_arg {
40         esp_spp_mode_t mode;
41         bool enable_l2cap_ertm;
42         UINT16 tx_buffer_size;
43     } init;
44     //BTC_SPP_ACT_UNINIT
45     struct uninit_arg {
46     } uninit;
47 
48     //BTC_SPP_ACT_START_DISCOVERY
49     struct start_discovery_arg {
50         BD_ADDR bd_addr;
51         UINT16 num_uuid;
52         tSDP_UUID *p_uuid_list;
53     } start_discovery;
54     //BTC_SPP_ACT_CONNECT
55     struct conn_arg {
56         esp_spp_sec_t sec_mask;
57         esp_spp_role_t role;
58         UINT8 remote_scn;
59         esp_bd_addr_t peer_bd_addr;
60     } connect;
61     //BTC_SPP_ACT_DISCONNECT
62     struct disconn_arg {
63         UINT32 handle;
64     } disconnect;
65     //BTC_SPP_ACT_START_SRV
66     struct start_srv_arg {
67         esp_spp_sec_t sec_mask;
68         esp_spp_role_t role;
69         UINT8 local_scn;
70         UINT8 max_session;
71         char name[ESP_SPP_SERVER_NAME_MAX + 1];
72     } start_srv;
73     //BTC_SPP_ACT_STOP_SRV
74     struct stop_srv_arg {
75         UINT8 scn;
76     } stop_srv;
77     //BTC_SPP_ACT_WRITE
78     struct write_arg {
79         UINT32 handle;
80         int len;
81         UINT8 *p_data;
82     } write;
83 
84 } btc_spp_args_t;
85 
86 
87 void btc_spp_call_handler(btc_msg_t *msg);
88 void btc_spp_cb_handler(btc_msg_t *msg);
89 void btc_spp_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
90 void btc_spp_arg_deep_free(btc_msg_t *msg);
91 
92 esp_err_t spp_send_data_to_btc(uint32_t handle, int len, uint8_t *p_data, esp_spp_mode_t spp_mode);
93 #endif ///defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE
94 #endif ///__BTC_SPP_H__
95