]> granicus.if.org Git - esp-idf/blob - components/bt/host/bluedroid/btc/profile/esp/include/wx_airsync_prf.h
Bluetooth component refactoring
[esp-idf] / components / bt / host / bluedroid / btc / profile / esp / include / wx_airsync_prf.h
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 #include "prf_defs.h"
16
17 #if (WX_AIRSYNC_CFG)
18
19 #include "common/bt_target.h"
20 #include "stack/gatt_api.h"
21 #include "stack/gattdefs.h"
22 #include "bt_app_api.h"
23
24
25 /// Maximum Transmission Unit
26 #define ATT_DEFAULT_MTU                                 (23)
27
28 #define BLE_WECHAT_MAX_DATA_LEN            (ATT_DEFAULT_MTU - 3)
29
30
31 //define the key serivce uuid
32 #define ATT_SVC_AIRSYNC 0xFEE7
33 //define the airsync Char uuid
34 #define ATT_CHAR_AIRSYNC_WIT    0xFEC7
35 #define ATT_CHAR_AIRSYBC_NTF    0xFEC8
36 #define ATT_CHAR_AIRSYNC_READ   0xFEC9
37
38
39 typedef void (tAIRSYNC_CBACK)(UINT8 app_id, UINT8 event, UINT8 len, UINT8 *data);
40
41
42 /// WX AirSync Service Attributes Indexes
43 enum {
44     WX_IDX_SVC,
45     WX_IDX_AIRSYNC_WIT_CHAR,
46     WX_IDX_AIRSYNC_WIT_VAL,
47     WX_IDX_AIRSYNC_NTF_CHAR,
48     WX_IDX_AIRSYNC_NTF_VAL,
49     WX_IDX_AIRSYNC_READ_CHAR,
50     WX_IDX_AIRSYNC_READ_VAL,
51     WX_IDX_AIRSYNC_NTF_CFG,
52
53     WX_IDX_NB,
54 };
55
56 typedef struct {
57     BD_ADDR remote_bda;
58     BOOLEAN need_rsp;
59     UINT16  clt_cfg;
60 } tAirSync_WRITE_DATA;
61
62 typedef struct {
63     BOOLEAN      in_use;
64     BOOLEAN      congest;
65     UINT16       conn_id;
66     BOOLEAN      connected;
67     BD_ADDR      remote_bda;
68     UINT32       trans_id;
69     UINT8            cur_srvc_id;
70
71 } tAirSync_CLCB;
72
73
74 typedef struct {
75     UINT8            app_id;
76     UINT16       airsync_wirt_hdl;
77     UINT16       airsync_ntf_hdl;
78     UINT16           airsync_read_hdl;
79     UINT16       airsync_cfg_hdl;
80
81     tAIRSYNC_CBACK       *p_cback;
82
83 } tAirSync_INST;
84
85
86 /* service engine control block */
87 typedef struct {
88     tAirSync_CLCB            clcb;           /* connection link*/
89     tGATT_IF                 gatt_if;
90     BOOLEAN              enabled;
91     BOOLEAN              is_primery;
92     tAirSync_INST            airsync_inst;
93     UINT8                    inst_id;
94 } tAIRSYNC_CB_ENV;
95
96 void AirSync_CreateService(void);
97
98 tAirSync_CLCB *airsync_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda);
99
100 UINT16 AirSync_env_find_conn_id_by_bd_adddr(BD_ADDR bda);
101
102 BOOLEAN AirSync_env_clcb_dealloc(UINT16 conn_id);
103
104 tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back);
105
106 void AirSync_msg_notify(UINT8 len, UINT8 *button_msg);
107
108 extern tAIRSYNC_CB_ENV airsync_cb_env;
109
110 #endif  ///WX_AIRSYNC_CFG