-
Notifications
You must be signed in to change notification settings - Fork 28
/
mible_api.h
166 lines (107 loc) · 5.3 KB
/
mible_api.h
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
#ifndef MIBLE_API_H__
#define MIBLE_API_H__
// Copyright [2017] [Beijing Xiaomi Mobile Software Co., Ltd]
//
// 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 "mible_port.h"
#include "mible_type.h"
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
void mible_gap_event_callback(mible_gap_evt_t evt, mible_gap_evt_param_t* param);
void mible_gatts_event_callback(mible_gatts_evt_t evt,
mible_gatts_evt_param_t* param);
void mible_gattc_event_callback(mible_gattc_evt_t evt,
mible_gattc_evt_param_t* param);
void mible_arch_event_callback(mible_arch_event_t evt,
mible_arch_evt_param_t* param);
mible_status_t mible_gap_address_get(mible_addr_t mac);
mible_status_t mible_gap_scan_start(mible_gap_scan_type_t scan_type,
mible_gap_scan_param_t scan_param);
mible_status_t mible_gap_scan_stop(void);
mible_status_t mible_gap_scan_param_get(mible_gap_scan_param_t *scan_param);
mible_status_t mible_gap_adv_start(mible_gap_adv_param_t *p_adv_param);
mible_status_t mible_gap_adv_data_set(uint8_t const * p_data, uint8_t dlen,
uint8_t const *p_sr_data, uint8_t srdlen);
mible_status_t mible_gap_adv_stop(void);
mible_status_t mible_gap_connect(mible_gap_scan_param_t scan_param,
mible_gap_connect_t conn_param);
mible_status_t mible_gap_update_conn_params(uint16_t conn_handle,
mible_gap_conn_param_t conn_params);
mible_status_t mible_gap_disconnect(uint16_t conn_handle);
mible_status_t mible_gatts_service_init(
mible_gatts_db_t *mible_service_database);
mible_status_t mible_gatts_value_set(uint16_t srv_handle, uint16_t char_handle,
uint8_t offset, uint8_t* buf, uint8_t len);
mible_status_t mible_gatts_value_get(uint16_t srv_handle, uint16_t char_handle,
uint8_t* pdata, uint8_t *plen);
mible_status_t mible_gatts_notify_or_indicate(uint16_t conn_handle,
uint16_t srv_handle, uint16_t char_value_handle, uint8_t offset,
uint8_t* p_value, uint8_t len, uint8_t type);
mible_status_t mible_gatts_rw_auth_reply(uint16_t conn_handle, uint8_t status,
uint16_t char_value_handle, uint8_t offset, uint8_t* p_value,
uint8_t len, uint8_t type);
mible_status_t mible_gattc_primary_service_discover_by_uuid(
uint16_t conn_handle, mible_handle_range_t handle_range,
mible_uuid_t* p_srv_uuid);
mible_status_t
mible_gattc_char_discover_by_uuid(uint16_t conn_handle,
mible_handle_range_t handle_range, mible_uuid_t* p_char_uuid);
mible_status_t
mible_gattc_clt_cfg_descriptor_discover(uint16_t conn_handle,
mible_handle_range_t handle_range);
mible_status_t
mible_gattc_read_char_value_by_uuid(uint16_t conn_handle,
mible_handle_range_t handle_range, mible_uuid_t *p_char_uuid);
mible_status_t mible_gattc_write_with_rsp(uint16_t conn_handle, uint16_t handle,
uint8_t* p_value, uint8_t len);
mible_status_t mible_gattc_write_cmd(uint16_t conn_handle, uint16_t handle,
uint8_t* p_value, uint8_t len);
mible_status_t mible_timer_create(void** p_timer_id,
mible_timer_handler timeout_handler, mible_timer_mode mode);
mible_status_t mible_user_timer_create(void** p_timer_id,
mible_timer_handler timeout_handler, mible_timer_mode mode);
mible_status_t mible_timer_delete(void* timer_id);
mible_status_t mible_timer_start(void* timer_id, uint32_t timeout_value,
void* p_context);
mible_status_t mible_timer_stop(void* timer_id);
mible_status_t mible_record_create(uint16_t record_id, uint8_t len);
mible_status_t mible_record_delete(uint16_t record_id);
mible_status_t mible_record_read(uint16_t record_id, uint8_t* p_data,
uint8_t len);
mible_status_t mible_record_write(uint16_t record_id, const uint8_t* p_data,
uint8_t len);
mible_status_t mible_rand_num_generator(uint8_t* p_buf, uint8_t len);
mible_status_t mible_aes128_encrypt(const uint8_t* key,
const uint8_t* plaintext, uint8_t plen, uint8_t* ciphertext);
mible_status_t mible_task_post(mible_handler_t handler, void *param);
void mible_tasks_exec(void);
mible_status_t mible_iic_init(const iic_config_t * p_config, mible_handler_t handler);
void mible_iic_uninit(void);
mible_status_t mible_iic_tx(uint8_t addr, uint8_t * p_out, uint16_t len,
bool no_stop);
mible_status_t mible_iic_rx(uint8_t addr, uint8_t * p_in, uint16_t len);
int mible_iic_scl_pin_read(uint8_t port, uint8_t pin);
int mible_gap_register(mible_gap_callback_t cb);
int mible_gattc_register(mible_gattc_callback_t cb);
int mible_gatts_register(mible_gatts_callback_t cb);
int mible_arch_register(mible_arch_callback_t cb);
mible_status_t mible_nvm_init(void);
mible_status_t mible_nvm_write(void * p_data, uint32_t length, uint32_t address);
mible_status_t mible_nvm_read(void * p_data, uint32_t length, uint32_t address);
mible_status_t mible_upgrade_firmware(void);
mible_status_t mible_reboot(void);
mible_status_t mible_set_tx_power(int16_t power);
int mible_log_printf(const char * sFormat, ...);
int mible_log_hexdump(void* array_base, uint16_t array_size);
#endif