1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef __BTC_SPP_H__
16 #define __BTC_SPP_H__
17 
18 #include "btc/btc_task.h"
19 #include "esp_bt_defs.h"
20 #include "esp_spp_api.h"
21 #include "common/bt_target.h"
22 #include "bta/bta_jv_api.h"
23 
24 #if (defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE)
25 
26 #define ESP_SPP_MAX_SESSION     BTA_JV_MAX_RFC_SR_SESSION
27 #define ESP_SPP_SERVER_NAME_MAX 32
28 
29 #define ESP_SPP_RINGBUF_SIZE 1000
30 
31 #define BTC_SPP_INVALID_SCN 0x00
32 
33 typedef enum {
34     BTC_SPP_ACT_INIT = 0,
35     BTC_SPP_ACT_UNINIT,
36     BTC_SPP_ACT_START_DISCOVERY,
37     BTC_SPP_ACT_CONNECT,
38     BTC_SPP_ACT_DISCONNECT,
39     BTC_SPP_ACT_START_SRV,
40     BTC_SPP_ACT_STOP_SRV,
41     BTC_SPP_ACT_WRITE,
42 } btc_spp_act_t;
43 
44 /* btc_spp_args_t */
45 typedef union {
46     //BTC_SPP_ACT_INIT
47     struct init_arg {
48         esp_spp_mode_t mode;
49     } init;
50     //BTC_SPP_ACT_UNINIT
51     struct uninit_arg {
52     } uninit;
53 
54     //BTC_SPP_ACT_START_DISCOVERY
55     struct start_discovery_arg {
56         BD_ADDR bd_addr;
57         UINT16 num_uuid;
58         tSDP_UUID *p_uuid_list;
59     } start_discovery;
60     //BTC_SPP_ACT_CONNECT
61     struct connect_arg {
62         esp_spp_sec_t sec_mask;
63         esp_spp_role_t role;
64         UINT8 remote_scn;
65         esp_bd_addr_t peer_bd_addr;
66     } connect;
67     //BTC_SPP_ACT_DISCONNECT
68     struct disconnect_arg {
69         UINT32 handle;
70     } disconnect;
71     //BTC_SPP_ACT_START_SRV
72     struct start_srv_arg {
73         esp_spp_sec_t sec_mask;
74         esp_spp_role_t role;
75         UINT8 local_scn;
76         UINT8 max_session;
77         char name[ESP_SPP_SERVER_NAME_MAX + 1];
78     } start_srv;
79     //BTC_SPP_ACT_STOP_SRV
80     struct stop_srv_arg {
81         UINT8 scn;
82     } stop_srv;
83     //BTC_SPP_ACT_WRITE
84     struct write_arg {
85         UINT32 handle;
86         int len;
87         UINT8 *p_data;
88     } write;
89 
90 } btc_spp_args_t;
91 
92 
93 void btc_spp_call_handler(btc_msg_t *msg);
94 void btc_spp_cb_handler(btc_msg_t *msg);
95 void btc_spp_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
96 
97 esp_err_t btc_spp_vfs_register(void);
98 #endif ///defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE
99 #endif ///__BTC_SPP_H__
100