summaryrefslogtreecommitdiffstats
path: root/test/suite/support/gatt.c
blob: 1ccc5b18ba36d98d95441a0e924dc22c30110ad5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/******************************************************************************
 *
 *  Copyright (C) 2014 Google, Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#include "base.h"
#include "btcore/include/bdaddr.h"
#include "support/callbacks.h"
#include "support/gatt.h"

const btgatt_interface_t *gatt_interface;
static int gatt_client_interface;
static int gatt_server_interface;
static int gatt_status;

bool gatt_init() {
  gatt_interface = bt_interface->get_profile_interface(BT_PROFILE_GATT_ID);
  return gatt_interface->init(callbacks_get_gatt_struct()) == BT_STATUS_SUCCESS;
}

int gatt_get_client_interface() {
  return gatt_client_interface;
}

int gatt_get_server_interface() {
  return gatt_server_interface;
}

int gatt_get_status() {
  return gatt_status;
}

// GATT client callbacks
void btgattc_register_app_cb(int status, int clientIf, bt_uuid_t *app_uuid) {
  gatt_status = status;
  gatt_client_interface = clientIf;
  CALLBACK_RET();
}

void btgattc_scan_result_cb(bt_bdaddr_t* bda, int rssi, uint8_t* adv_data) {
  CALLBACK_RET();
}

void btgattc_open_cb(int conn_id, int status, int clientIf, bt_bdaddr_t* bda) {
  CALLBACK_RET();
}

void btgattc_close_cb(int conn_id, int status, int clientIf, bt_bdaddr_t* bda) {
  CALLBACK_RET();
}

void btgattc_search_complete_cb(int conn_id, int status) {
  CALLBACK_RET();
}

void btgattc_search_result_cb(int conn_id, btgatt_srvc_id_t *srvc_id) {
  CALLBACK_RET();
}

void btgattc_get_characteristic_cb(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int char_prop) {
  CALLBACK_RET();
}

void btgattc_get_descriptor_cb(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id) {
  CALLBACK_RET();
}

void btgattc_get_included_service_cb(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *incl_srvc_id) {
  CALLBACK_RET();
}

void btgattc_register_for_notification_cb(int conn_id, int registered, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id) {
  CALLBACK_RET();
}

void btgattc_notify_cb(int conn_id, btgatt_notify_params_t *p_data) {
  CALLBACK_RET();
}

void btgattc_read_characteristic_cb(int conn_id, int status, btgatt_read_params_t *p_data) {
  CALLBACK_RET();
}

void btgattc_write_characteristic_cb(int conn_id, int status, btgatt_write_params_t *p_data) {
  CALLBACK_RET();
}

void btgattc_execute_write_cb(int conn_id, int status) {
  CALLBACK_RET();
}

void btgattc_read_descriptor_cb(int conn_id, int status, btgatt_read_params_t *p_data) {
  CALLBACK_RET();
}

void btgattc_write_descriptor_cb(int conn_id, int status, btgatt_write_params_t *p_data) {
  CALLBACK_RET();
}

void btgattc_remote_rssi_cb(int client_if,bt_bdaddr_t* bda, int rssi, int status) {
  CALLBACK_RET();
}

void btgattc_advertise_cb(int status, int client_if) {
  gatt_status = status;
  gatt_client_interface = client_if;
  CALLBACK_RET();
}

// GATT server callbacks
void btgatts_register_app_cb(int status, int server_if, bt_uuid_t *uuid) {
  gatt_status = status;
  gatt_server_interface = server_if;
  CALLBACK_RET();
}

void btgatts_connection_cb(int conn_id, int server_if, int connected, bt_bdaddr_t *bda) {
  CALLBACK_RET();
}

void btgatts_service_added_cb(int status, int server_if, btgatt_srvc_id_t *srvc_id, int srvc_handle) {
  CALLBACK_RET();
}

void btgatts_included_service_added_cb(int status, int server_if, int srvc_handle, int incl_srvc_handle) {
  CALLBACK_RET();
}

void btgatts_characteristic_added_cb(int status, int server_if, bt_uuid_t *char_id, int srvc_handle, int char_handle) {
  CALLBACK_RET();
}

void btgatts_descriptor_added_cb(int status, int server_if, bt_uuid_t *descr_id, int srvc_handle, int descr_handle) {
  CALLBACK_RET();
}

void btgatts_service_started_cb(int status, int server_if, int srvc_handle) {
  CALLBACK_RET();
}

void btgatts_service_stopped_cb(int status, int server_if, int srvc_handle) {
  CALLBACK_RET();
}

void btgatts_service_deleted_cb(int status, int server_if, int srvc_handle) {
  CALLBACK_RET();
}

void btgatts_request_read_cb(int conn_id, int trans_id, bt_bdaddr_t *bda, int attr_handle, int offset, bool is_long) {
  CALLBACK_RET();
}

void btgatts_request_write_cb(int conn_id, int trans_id, bt_bdaddr_t *bda, int attr_handle, int offset, int length, bool need_rsp, bool is_prep, uint8_t* value) {
  CALLBACK_RET();
}

void btgatts_request_exec_write_cb(int conn_id, int trans_id, bt_bdaddr_t *bda, int exec_write) {
  CALLBACK_RET();
}

void btgatts_response_confirmation_cb(int status, int handle) {
  CALLBACK_RET();
}