-
Notifications
You must be signed in to change notification settings - Fork 28
/
mible_mesh_api.c
executable file
·180 lines (151 loc) · 4.39 KB
/
mible_mesh_api.c
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
177
178
179
180
/*
* mible_mesh_api.c
*
* Created on: 2020Äê11ÔÂ26ÈÕ
* Author: mi
*/
#include "mible_mesh_api.h"
static mible_mesh_event_cb_t mible_mesh_event_callback_handler;
int mible_mesh_event_callback(mible_mesh_event_type_t type, void * data)
{
if(mible_mesh_event_callback_handler != NULL){
mible_mesh_event_callback_handler(type, (mible_mesh_event_params_t *)data);
}
return 0;
}
int mible_mesh_device_register_event_callback(mible_mesh_event_cb_t mible_mesh_event_cb)
{
mible_mesh_event_callback_handler = mible_mesh_event_cb;
return 0;
}
int mible_mesh_device_unregister_event_callback(mible_mesh_event_cb_t mible_mesh_event_cb)
{
if(mible_mesh_event_callback_handler == mible_mesh_event_cb){
mible_mesh_event_callback_handler = NULL;
return 0;
}
return -1;
}
static mible_user_event_cb_t mible_mesh_user_state_callback_handler;
int mible_mesh_user_event_callback(uint8_t type, void * data)
{
if(mible_mesh_user_state_callback_handler != NULL){
mible_mesh_user_state_callback_handler(type, data);
}
return 0;
}
int mible_mesh_user_event_register_event_callback(mible_user_event_cb_t user_event_cb)
{
mible_mesh_user_state_callback_handler = user_event_cb;
return 0;
}
int mible_mesh_user_event_unregister_event_callback(mible_user_event_cb_t user_event_cb)
{
if(mible_mesh_user_state_callback_handler == user_event_cb){
mible_mesh_user_state_callback_handler = NULL;
return 0;
}
return -1;
}
__WEAK int mible_mesh_device_init_stack(void)
{
// init your mesh stack, thread, memory, prepare for provisioner initilization.
return 0;
}
__WEAK int mible_mesh_device_deinit_stack(void)
{
// deinit your mesh stack, close thread,free memory, and release firmware bt resource.
return 0;
}
__WEAK int mible_mesh_device_init_node(void)
{
/**********************************************************************//**
* init provisioner, init models/opcodes.
* load seq_num, iv_index, replay list
**********************************************************************/
return 0;
}
__WEAK int mible_mesh_device_set_provsion_data(mible_mesh_provisioning_data_t *param)
{
return 0;
}
__WEAK int mible_mesh_device_provsion_done(void)
{
return 0;
}
__WEAK int mible_mesh_node_reset(void)
{
return 0;
}
__WEAK int mible_mesh_device_unprovsion_done(void)
{
return 0;
}
__WEAK int mible_mesh_device_login_done(uint8_t status)
{
return 0;
}
__WEAK int mible_mesh_device_set_network_transmit_param(uint8_t count, uint8_t interval_steps)
{
// set adv interval and adv transmit times
return 0;
}
__WEAK int mible_mesh_device_set_relay(uint8_t enabled,uint8_t count,uint8_t interval)
{
return 0;
}
__WEAK int mible_mesh_device_get_relay(uint8_t *enabled, uint8_t *count, uint8_t *step)
{
return 0;
}
__WEAK int mible_mesh_device_get_seq(uint16_t element, uint32_t* seq, uint32_t* iv, uint8_t* flags)
{
return 0;
}
__WEAK int mible_mesh_device_update_iv_info(uint32_t iv_index, uint8_t flags)
{
// sync and load iv_index from application
return 0;
}
__WEAK int mible_mesh_device_set_netkey(mible_mesh_op_t op, uint16_t netkey_index, uint8_t *netkey)
{
if(op == MIBLE_MESH_OP_ADD){
// add netkey
}else{
// delete netkey
}
return 0;
}
__WEAK int mible_mesh_device_set_appkey(mible_mesh_op_t op, uint16_t netkey_index, uint16_t appkey_index, uint8_t * appkey)
{
if(op == MIBLE_MESH_OP_ADD){
// add app_key, bind netkey index
}else{
// delete netkey, unbind netkey index
}
return 0;
}
__WEAK int mible_mesh_device_set_model_app(mible_mesh_op_t op, uint16_t elem_index, uint16_t company_id,
uint16_t model_id, uint16_t appkey_index)
{
if(op == MIBLE_MESH_OP_ADD){
// bind model appkey_index
}else{
// unbind model appkey_index
}
return 0;
}
__WEAK int mible_mesh_device_set_sub_address(mible_mesh_op_t op, uint16_t element, uint16_t company_id,
uint16_t model_id, uint16_t sub_addr)
{
if(op == MIBLE_MESH_OP_ADD){
// add subscription
}else{
// delete subscription
}
return 0;
}
__WEAK int mible_mesh_node_generic_control(mible_mesh_access_message_t *param)
{
return 0;
}