1
1
/*
2
- * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
3
- * Licensed under the MIT License (the "License"); you may not use this file except in
4
- * compliance with the License. You may obtain a copy of the License at
5
- * http://opensource.org/licenses/MIT
6
- * Unless required by applicable law or agreed to in writing, software distributed under the License is
7
- * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
8
- * either express or implied. See the License for the specific language governing permissions and
9
- * limitations under the License.
10
- *
11
- */
2
+ * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
3
+ * Licensed under the MIT License (the "License"); you may not use this file except in
4
+ * compliance with the License. You may obtain a copy of the License at
5
+ * http://opensource.org/licenses/MIT
6
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is
7
+ * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
8
+ * either express or implied. See the License for the specific language governing permissions and
9
+ * limitations under the License.
10
+ *
11
+ */
12
12
#ifndef BLE_QIOT_TEMPLATE_H_
13
13
#define BLE_QIOT_TEMPLATE_H_
14
14
#ifdef __cplusplus
@@ -18,7 +18,6 @@ extern "C"{
18
18
#include <stdint.h>
19
19
#include <stdbool.h>
20
20
21
-
22
21
// data type in template, corresponding to type in json file
23
22
enum {
24
23
BLE_QIOT_DATA_TYPE_BOOL = 0 ,
@@ -28,9 +27,14 @@ enum {
28
27
BLE_QIOT_DATA_TYPE_ENUM ,
29
28
BLE_QIOT_DATA_TYPE_TIME ,
30
29
BLE_QIOT_DATA_TYPE_STRUCT ,
30
+ BLE_QIOT_DATA_TYPE_ARRAY ,
31
31
BLE_QIOT_DATA_TYPE_BUTT ,
32
32
};
33
33
34
+ #define BLE_QIOT_ARRAY_INT_BIT_MASK (1 << 4)
35
+ #define BLE_QIOT_ARRAY_STRING_BIT_MASK (1 << 5)
36
+ #define BLE_QIOT_ARRAY_FLOAT_BIT_MASK (1 << 6)
37
+ #define BLE_QIOT_ARRAY_STRUCT_BIT_MASK (1 << 7)
34
38
// message type, reference data template
35
39
enum {
36
40
BLE_QIOT_PROPERTY_AUTH_RW = 0 ,
@@ -44,127 +48,192 @@ enum {
44
48
BLE_QIOT_EFFECT_REPLY ,
45
49
BLE_QIOT_EFFECT_BUTT ,
46
50
};
47
- #define BLE_QIOT_PACKAGE_MSG_HEAD (_TYPE , _REPLY , _ID ) (((_TYPE) << 6) | (((_REPLY) == BLE_QIOT_EFFECT_REPLY) << 5) | ((_ID) & 0X1F))
48
- #define BLE_QIOT_PACKAGE_TLV_HEAD (_TYPE , _ID ) (((_TYPE) << 5) | ((_ID) & 0X1F))
49
51
52
+ #define BLE_QIOT_PACKAGE_MSG_HEAD (_TYPE , _REPLY , _ID ) (((_TYPE) << 6) | (((_REPLY) == BLE_QIOT_EFFECT_REPLY) << 5) | ((_ID) & 0X1F))
53
+ #define BLE_QIOT_PACKAGE_TLV_HEAD (_TYPE , _ID ) (((_TYPE) << 5) | ((_ID) & 0X1F))
50
54
51
55
// define tlv struct
52
- typedef struct {
53
- uint8_t type ;
56
+ typedef struct { uint8_t type ;
54
57
uint8_t id ;
55
58
uint16_t len ;
56
59
char * val ;
57
60
}e_ble_tlv ;
58
- #define BLE_QIOT_INCLUDE_PROPERTY
61
+
62
+
63
+ #define BLE_QIOT_INCLUDE_PROPERTY
59
64
60
65
// define property id
61
66
enum {
62
- BLE_QIOT_PROPERTY_ID_PROPERTY_BOOL = 0 ,
63
- BLE_QIOT_PROPERTY_ID_PROPERTY_INT ,
64
- BLE_QIOT_PROPERTY_ID_PROPERTY_STRING ,
65
- BLE_QIOT_PROPERTY_ID_PROPERTY_FLOAT ,
66
- BLE_QIOT_PROPERTY_ID_PROPERTY_ENUM ,
67
- BLE_QIOT_PROPERTY_ID_PROPERTY_TIME ,
68
- BLE_QIOT_PROPERTY_ID_PROPERTY_STRUCT ,
67
+ BLE_QIOT_PROPERTY_ID_T_BOOL ,
68
+ BLE_QIOT_PROPERTY_ID_T_INT ,
69
+ BLE_QIOT_PROPERTY_ID_T_STRING ,
70
+ BLE_QIOT_PROPERTY_ID_T_FLOAT ,
71
+ BLE_QIOT_PROPERTY_ID_T_ENUM ,
72
+ BLE_QIOT_PROPERTY_ID_T_TIME ,
73
+ BLE_QIOT_PROPERTY_ID_T_STRUCT ,
74
+ BLE_QIOT_PROPERTY_ID_T_ARRAY_INT ,
75
+ BLE_QIOT_PROPERTY_ID_T_ARRAY_STRING ,
76
+ BLE_QIOT_PROPERTY_ID_T_ARRAY_FLOAT ,
77
+ BLE_QIOT_PROPERTY_ID_T_ARRAY_STRUCT ,
69
78
BLE_QIOT_PROPERTY_ID_BUTT ,
70
79
};
71
80
72
- // define property_int attributes
73
- #define BLE_QIOT_PROPERTY_PROPERTY_INT_MIN (-100000)
74
- #define BLE_QIOT_PROPERTY_PROPERTY_INT_MAX (100000)
75
- #define BLE_QIOT_PROPERTY_PROPERTY_INT_START (0)
76
- #define BLE_QIOT_PROPERTY_PROPERTY_INT_STEP (1)
77
-
78
- // define property_string length limit
79
- #define BLE_QIOT_PROPERTY_PROPERTY_STRING_LEN_MIN (0)
80
- #define BLE_QIOT_PROPERTY_PROPERTY_STRING_LEN_MAX (128)
81
-
82
- // define property_float attributes
83
- #define BLE_QIOT_PROPERTY_PROPERTY_FLOAT_MIN (-100)
84
- #define BLE_QIOT_PROPERTY_PROPERTY_FLOAT_MAX (100)
85
- #define BLE_QIOT_PROPERTY_PROPERTY_FLOAT_START (0)
86
- #define BLE_QIOT_PROPERTY_PROPERTY_FLOAT_STEP (0.001)
87
-
88
- // define property property_enum enum
81
+ // define t_int attributes
82
+ #define BLE_QIOT_PROPERTY_T_INT_MIN (-100000)
83
+ #define BLE_QIOT_PROPERTY_T_INT_MAX (100000)
84
+ #define BLE_QIOT_PROPERTY_T_INT_START (0)
85
+ #define BLE_QIOT_PROPERTY_T_INT_STEP (1)
86
+ // define t_string length limit
87
+ #define BLE_QIOT_PROPERTY_T_STRING_LEN_MIN (0)
88
+ #define BLE_QIOT_PROPERTY_T_STRING_LEN_MAX (128)
89
+ // define t_float attributes
90
+ #define BLE_QIOT_PROPERTY_T_FLOAT_MIN (-100)
91
+ #define BLE_QIOT_PROPERTY_T_FLOAT_MAX (100)
92
+ #define BLE_QIOT_PROPERTY_T_FLOAT_START (0)
93
+ #define BLE_QIOT_PROPERTY_T_FLOAT_STEP (0.001)
94
+ // define t_enum enum
89
95
enum {
90
- BLE_QIOT_PROPERTY_PROPERTY_ENUM_ENUM0 = 0 ,
91
- BLE_QIOT_PROPERTY_PROPERTY_ENUM_ENUM1 = 1 ,
92
- BLE_QIOT_PROPERTY_PROPERTY_ENUM_ENUM2 = 2 ,
93
- BLE_QIOT_PROPERTY_PROPERTY_ENUM_ENUM3 = 3 ,
94
- BLE_QIOT_PROPERTY_PROPERTY_ENUM_BUTT = 4 ,
96
+ BLE_QIOT_PROPERTY_T_ENUM_ENUM0 = 0 ,
97
+ BLE_QIOT_PROPERTY_T_ENUM_ENUM1 = 1 ,
98
+ BLE_QIOT_PROPERTY_T_ENUM_ENUM2 = 2 ,
99
+ BLE_QIOT_PROPERTY_T_ENUM_ENUM3 = 3 ,
100
+ BLE_QIOT_PROPERTY_T_ENUM_BUTT ,
95
101
};
96
102
97
- // define property id
103
+ // define t_struct s_int attributes
104
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_INT_MIN (-10000)
105
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_INT_MAX (10000)
106
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_INT_START (0)
107
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_INT_STEP (1)
108
+ // define t_structs_string length limit
109
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_STRING_LEN_MIN (0)
110
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_STRING_LEN_MAX (128)
111
+ // define t_struct s_float attributes
112
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_FLOAT_MIN (-100)
113
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_FLOAT_MAX (100)
114
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_FLOAT_START (0)
115
+ #define BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_FLOAT_STEP (0.001)
116
+ // define t_struct s_enum enum
98
117
enum {
99
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_ID_MEM_BOOL = 0 ,
100
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_ID_MEM_INT ,
101
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_ID_MEM_STRING ,
102
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_ID_MEM_FLOAT ,
103
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_ID_MEM_ENUM ,
104
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_ID_MEM_TIME ,
105
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_ID_BUTT ,
118
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_ENUM_MEM_ENUM0 = 0 ,
119
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_ENUM_MEM_ENUM1 = 1 ,
120
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_ENUM_MEM_ENUM2 = 2 ,
121
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_S_ENUM_BUTT ,
106
122
};
107
123
108
- // define mem_int attributes
109
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_INT_MIN (-10000)
110
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_INT_MAX (10000)
111
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_INT_START (0)
112
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_INT_STEP (1)
113
-
114
- // define mem_string length limit
115
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_STRING_LEN_MIN (0)
116
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_STRING_LEN_MAX (128)
124
+ // define t_struct property id
125
+ enum {
126
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_ID_S_BOOL ,
127
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_ID_S_INT ,
128
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_ID_S_STRING ,
129
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_ID_S_FLOAT ,
130
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_ID_S_ENUM ,
131
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_ID_S_TIME ,
132
+ BLE_QIOT_STRUCT_T_STRUCT_PROPERTY_ID_BUTT ,
133
+ };
117
134
118
- // define mem_float attributes
119
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_FLOAT_MIN (-100)
120
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_FLOAT_MAX (100)
121
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_FLOAT_START (0)
122
- #define BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_FLOAT_STEP (0.001)
135
+ typedef struct {
136
+ bool m_s_bool ;
137
+ int32_t m_s_int ;
138
+ char m_s_str [128 ];
139
+ float m_s_float ;
140
+ uint16_t m_s_enum ;
141
+ uint32_t m_s_time ;
142
+ }struct_property_t_struct ;
143
+
144
+ // define t_array_int attributes
145
+ #define BLE_QIOT_PROPERTY_T_ARRAY_INT_MIN (0)
146
+ #define BLE_QIOT_PROPERTY_T_ARRAY_INT_MAX (100)
147
+ #define BLE_QIOT_PROPERTY_T_ARRAY_INT_START (0)
148
+ #define BLE_QIOT_PROPERTY_T_ARRAY_INT_STEP (1)
149
+ //define the actual size of array
150
+ #define BLE_QIOT_PROPERTY_T_ARRAY_INT_SIZE_MAX (0)
151
+ #if BLE_QIOT_PROPERTY_T_ARRAY_INT_SIZE_MAX == 0
152
+ #error "please define t_array_int array size first"
153
+ #endif
154
+ typedef struct {
155
+ int32_t m_int_arr [BLE_QIOT_PROPERTY_T_ARRAY_INT_SIZE_MAX ];
156
+ uint16_t m_arr_size ;
157
+ }array_struct_t_array_int ;
158
+
159
+ // define t_array_string length limit
160
+ #define BLE_QIOT_PROPERTY_T_ARRAY_STRING_LEN_MIN (0)
161
+ #define BLE_QIOT_PROPERTY_T_ARRAY_STRING_LEN_MAX (2048)
162
+ //define the actual size of array
163
+ #define BLE_QIOT_PROPERTY_T_ARRAY_STRING_SIZE_MAX (0)
164
+ #if BLE_QIOT_PROPERTY_T_ARRAY_STRING_SIZE_MAX == 0
165
+ #error "please define t_array_string array size first"
166
+ #endif
167
+ typedef struct {
168
+ char m_str_arr [BLE_QIOT_PROPERTY_T_ARRAY_STRING_SIZE_MAX ][2048 ];
169
+ uint16_t m_arr_size ;
170
+ }array_struct_t_array_string ;
171
+
172
+ // define t_array_float attributes
173
+ #define BLE_QIOT_PROPERTY_T_ARRAY_FLOAT_MIN (0)
174
+ #define BLE_QIOT_PROPERTY_T_ARRAY_FLOAT_MAX (100)
175
+ #define BLE_QIOT_PROPERTY_T_ARRAY_FLOAT_START (0)
176
+ #define BLE_QIOT_PROPERTY_T_ARRAY_FLOAT_STEP (1)
177
+ //define the actual size of array
178
+ #define BLE_QIOT_PROPERTY_T_ARRAY_FLOAT_SIZE_MAX (0)
179
+ #if BLE_QIOT_PROPERTY_T_ARRAY_FLOAT_SIZE_MAX == 0
180
+ #error "please define t_array_float array size first"
181
+ #endif
182
+ typedef struct {
183
+ float m_float_arr [BLE_QIOT_PROPERTY_T_ARRAY_FLOAT_SIZE_MAX ];
184
+ uint16_t m_arr_size ;
185
+ }array_struct_t_array_float ;
123
186
124
- // define property mem_enum enum
187
+ // define t_array_struct property id
125
188
enum {
126
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_ENUM_MEM_ENUM0 = 0 ,
127
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_ENUM_MEM_ENUM1 = 1 ,
128
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_ENUM_MEM_ENUM2 = 2 ,
129
- BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_ENUM_BUTT = 3 ,
189
+ BLE_QIOT_STRUCT_T_ARRAY_STRUCT_PROPERTY_ID_ARRAY_S_BOOL ,
190
+ BLE_QIOT_STRUCT_T_ARRAY_STRUCT_PROPERTY_ID_BUTT ,
130
191
};
131
192
132
193
typedef struct {
133
- bool m_mem_bool ;
134
- int32_t m_mem_int ;
135
- char m_mem_string [BLE_QIOT_STRUCT_PROPERTY_STRUCT_PROPERTY_MEM_STRING_LEN_MAX ];
136
- float m_mem_float ;
137
- uint16_t m_mem_enum ;
138
- uint32_t m_mem_time ;
139
- }struct_property_property_struct ;
194
+ bool m_array_s_bool ;
195
+ }struct_property_t_array_struct ;
196
+
197
+ //define the actual size of array
198
+ #define BLE_QIOT_PROPERTY_T_ARRAY_STRUCT_SIZE_MAX (0)
199
+ #if BLE_QIOT_PROPERTY_T_ARRAY_STRUCT_SIZE_MAX == 0
200
+ #error "please define t_array_struct array size first"
201
+ #endif
202
+ typedef struct {
203
+ struct_property_t_array_struct m_struct_arr [BLE_QIOT_PROPERTY_T_ARRAY_STRUCT_SIZE_MAX ];
204
+ uint16_t m_arr_size ;
205
+ }array_struct_t_array_struct ;
140
206
141
207
// define property set handle return 0 if success, other is error
142
208
// sdk call the function that inform the server data to the device
143
209
typedef int (* property_set_cb )(const char * data , uint16_t len );
144
-
145
210
// define property get handle. return the data length obtained, -1 is error, 0 is no data
146
211
// sdk call the function fetch user data and send to the server, the data should wrapped by user adn skd just transmit
147
212
typedef int (* property_get_cb )(char * buf , uint16_t buf_len );
148
-
149
213
// each property have a struct ble_property_t, make up a array named sg_ble_property_array
150
214
typedef struct {
151
215
property_set_cb set_cb ; //set callback
152
216
property_get_cb get_cb ; //get callback
153
217
uint8_t authority ; //property authority
154
218
uint8_t type ; //data type
219
+ uint16_t elem_num ;
155
220
}ble_property_t ;
156
- #define BLE_QIOT_INCLUDE_EVENT
221
+ typedef int (* property_array_set_cb )(const char * data , uint16_t len , uint16_t index );
222
+ typedef int (* property_array_get_cb )(char * buf , uint16_t buf_len , uint16_t index );
223
+
224
+
225
+ #define BLE_QIOT_INCLUDE_EVENT
157
226
158
227
// define event id
159
228
enum {
160
- BLE_QIOT_EVENT_ID_EVENT_WARNNING = 0 ,
229
+ BLE_QIOT_EVENT_ID_EVENT_WARNNING ,
161
230
BLE_QIOT_EVENT_ID_EVENT_ERROR ,
162
231
BLE_QIOT_EVENT_ID_BUTT ,
163
232
};
164
233
165
- // define param id for event event_warnning
234
+ // define event event_warnning param id
166
235
enum {
167
- BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ID_PARAM_BOOL = 0 ,
236
+ BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ID_PARAM_BOOL ,
168
237
BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ID_PARAM_INT ,
169
238
BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ID_PARAM_STRING ,
170
239
BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ID_PARAM_FLOAT ,
@@ -173,67 +242,63 @@ enum {
173
242
BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ID_BUTT ,
174
243
};
175
244
176
- // define param param_int attributes
177
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_INT_MIN (-100000)
178
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_INT_MAX (1000000)
179
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_INT_START (0)
180
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_INT_STEP (1)
181
-
182
- // define range for param param_string
183
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_STRING_LEN_MIN (0)
184
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_STRING_LEN_MAX (128)
185
-
186
- // define param param_float attributes
187
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_FLOAT_MIN (0)
188
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_FLOAT_MAX (100)
189
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_FLOAT_START (0)
190
- #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_FLOAT_STEP (0.001)
191
-
192
- // define enum for param param_enum
245
+ // define event_warnning param_int attributes
246
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_INT_MIN (-100000)
247
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_INT_MAX (1000000)
248
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_INT_START (0)
249
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_INT_STEP (1)
250
+ // define event_warnningparam_string length limit
251
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_STRING_LEN_MIN (0)
252
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_STRING_LEN_MAX (128)
253
+ // define event_warnning param_float attributes
254
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_FLOAT_MIN (0)
255
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_FLOAT_MAX (100)
256
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_FLOAT_START (0)
257
+ #define BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_FLOAT_STEP (0.001)
258
+ // define event_warnning param_enum enum
193
259
enum {
194
260
BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ENUM_PARAM_ENUM0 = 0 ,
195
261
BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ENUM_PARAM_ENUM1 = 1 ,
196
262
BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ENUM_PARAM_ENUM2 = 2 ,
197
- BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ENUM_BUTT = 3 ,
263
+ BLE_QIOT_EVENT_EVENT_WARNNING_PARAM_ENUM_BUTT ,
198
264
};
199
265
200
- // define param id for event event_error
266
+ // define event event_error param id
201
267
enum {
202
- BLE_QIOT_EVENT_EVENT_ERROR_PARAM_ID_PARAM_BOOL = 0 ,
268
+ BLE_QIOT_EVENT_EVENT_ERROR_PARAM_ID_PARAM_BOOL ,
203
269
BLE_QIOT_EVENT_EVENT_ERROR_PARAM_ID_PARAM_STRING ,
204
270
BLE_QIOT_EVENT_EVENT_ERROR_PARAM_ID_BUTT ,
205
271
};
206
272
207
- // define range for param param_string
208
- #define BLE_QIOT_EVENT_EVENT_ERROR_PARAM_STRING_LEN_MIN (0)
209
- #define BLE_QIOT_EVENT_EVENT_ERROR_PARAM_STRING_LEN_MAX (128)
210
-
273
+ // define event_errorparam_string length limit
274
+ #define BLE_QIOT_EVENT_EVENT_ERROR_PARAM_STRING_LEN_MIN (0)
275
+ #define BLE_QIOT_EVENT_EVENT_ERROR_PARAM_STRING_LEN_MAX (128)
211
276
// define event get handle. return the data length obtained, -1 is error, 0 is no data
212
277
// sdk call the function fetch user data and send to the server, the data should wrapped by user adn skd just transmit
213
278
typedef int (* event_get_cb )(char * buf , uint16_t buf_len );
214
-
215
279
// each param have a struct ble_event_param, make up a array for the event
216
280
typedef struct {
217
281
event_get_cb get_cb ; //get param data callback
218
282
uint8_t type ; //param type
219
283
}ble_event_param ;
220
-
221
284
// a array named sg_ble_event_array is composed by all the event array
222
285
typedef struct {
223
286
ble_event_param * event_array ; //array of params data
224
287
uint8_t array_size ; //array size
225
288
}ble_event_t ;
226
- #define BLE_QIOT_INCLUDE_ACTION
289
+
290
+
291
+ #define BLE_QIOT_INCLUDE_ACTION
227
292
228
293
// define action id
229
294
enum {
230
- BLE_QIOT_ACTION_ID_ACTION_TEST = 0 ,
295
+ BLE_QIOT_ACTION_ID_ACTION_TEST ,
231
296
BLE_QIOT_ACTION_ID_BUTT ,
232
297
};
233
298
234
- // define input id for action action_test
299
+ // define action action_test input id
235
300
enum {
236
- BLE_QIOT_ACTION_ACTION_TEST_INPUT_ID_BOOL_INPUT = 0 ,
301
+ BLE_QIOT_ACTION_ACTION_TEST_INPUT_ID_BOOL_INPUT ,
237
302
BLE_QIOT_ACTION_ACTION_TEST_INPUT_ID_INT_INPUT ,
238
303
BLE_QIOT_ACTION_ACTION_TEST_INPUT_ID_STRING_INPUT ,
239
304
BLE_QIOT_ACTION_ACTION_TEST_INPUT_ID_FLOAT_INPUT ,
@@ -242,75 +307,69 @@ enum {
242
307
BLE_QIOT_ACTION_ACTION_TEST_INPUT_ID_BUTT ,
243
308
};
244
309
245
- // define output id for action action_test
310
+ // define action_test int_input attributes
311
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_INT_INPUT_MIN (-100000)
312
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_INT_INPUT_MAX (100000)
313
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_INT_INPUT_START (0)
314
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_INT_INPUT_STEP (1)
315
+ // define action_teststring_input length limit
316
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_STRING_INPUT_LEN_MIN (0)
317
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_STRING_INPUT_LEN_MAX (128)
318
+ // define action_test float_input attributes
319
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_FLOAT_INPUT_MIN (-100)
320
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_FLOAT_INPUT_MAX (100)
321
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_FLOAT_INPUT_START (0)
322
+ #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_FLOAT_INPUT_STEP (1)
323
+ // define action_test enum_input enum
324
+ enum {
325
+ BLE_QIOT_ACTION_INPUT_ACTION_TEST_ENUM_INPUT_INPUT_ENUM0 = 0 ,
326
+ BLE_QIOT_ACTION_INPUT_ACTION_TEST_ENUM_INPUT_INPUT_ENUM1 = 1 ,
327
+ BLE_QIOT_ACTION_INPUT_ACTION_TEST_ENUM_INPUT_INPUT_ENUM2 = 2 ,
328
+ BLE_QIOT_ACTION_INPUT_ACTION_TEST_ENUM_INPUT_BUTT ,
329
+ };
330
+
331
+ // define action action_test output id
246
332
enum {
247
- BLE_QIOT_ACTION_ACTION_TEST_OUTPUT_ID_BOOL_OUTPUT = 0 ,
333
+ BLE_QIOT_ACTION_ACTION_TEST_OUTPUT_ID_BOOL_OUTPUT ,
248
334
BLE_QIOT_ACTION_ACTION_TEST_OUTPUT_ID_INT_OUTPUT ,
249
335
BLE_QIOT_ACTION_ACTION_TEST_OUTPUT_ID_STRING_OUTPUT ,
250
336
BLE_QIOT_ACTION_ACTION_TEST_OUTPUT_ID_FLOAT_OUTPUT ,
251
337
BLE_QIOT_ACTION_ACTION_TEST_OUTPUT_ID_ENUM_OUTPUT ,
252
338
BLE_QIOT_ACTION_ACTION_TEST_OUTPUT_ID_TIME_OUTPUT ,
253
339
BLE_QIOT_ACTION_ACTION_TEST_OUTPUT_ID_BUTT ,
254
340
};
255
- #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_INT_INPUT_MIN (-100000)
256
- #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_INT_INPUT_MAX (100000)
257
- #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_INT_INPUT_START (0)
258
- #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_INT_INPUT_STEP (1)
259
-
260
- // define input id string_input attributes
261
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_STRING_INPUT_LEN_MIN (0)
262
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_STRING_INPUT_LEN_MAX (128)
263
- #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_FLOAT_INPUT_MIN (-100)
264
- #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_FLOAT_INPUT_MAX (100)
265
- #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_FLOAT_INPUT_START (0)
266
- #define BLE_QIOT_ACTION_INPUT_ACTION_TEST_FLOAT_INPUT_STEP (1)
267
-
268
- // define enum for input id enum_input
269
- enum {
270
- BLE_QIOT_ACTION_INPUT_ACTION_TEST_ENUM_INPUT_INPUT_ENUM0 = 0 ,
271
- BLE_QIOT_ACTION_INPUT_ACTION_TEST_ENUM_INPUT_INPUT_ENUM1 = 1 ,
272
- BLE_QIOT_ACTION_INPUT_ACTION_TEST_ENUM_INPUT_INPUT_ENUM2 = 2 ,
273
- BLE_QIOT_ACTION_INPUT_ACTION_TEST_ENUM_INPUT_BUTT = 3 ,
274
- };
275
-
276
- // define output id int_output attributes
277
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_INT_OUTPUT_MIN (-100000)
278
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_INT_OUTPUT_MAX (1000000)
279
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_INT_OUTPUT_START (0)
280
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_INT_OUTPUT_STEP (1)
281
341
282
- // define output id string_output attributes
283
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_STRING_OUTPUT_LEN_MIN (0)
284
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_STRING_OUTPUT_LEN_MAX (128)
285
-
286
- // define output id float_output attributes
287
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_FLOAT_OUTPUT_MIN (-100)
288
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_FLOAT_OUTPUT_MAX (100)
289
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_FLOAT_OUTPUT_START (0)
290
- #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_FLOAT_OUTPUT_STEP (1)
291
-
292
- // define enum for output id enum_output
342
+ // define action_test int_output attributes
343
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_INT_OUTPUT_MIN (-100000)
344
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_INT_OUTPUT_MAX (1000000)
345
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_INT_OUTPUT_START (0)
346
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_INT_OUTPUT_STEP (1)
347
+ // define action_teststring_output length limit
348
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_STRING_OUTPUT_LEN_MIN (0)
349
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_STRING_OUTPUT_LEN_MAX (128)
350
+ // define action_test float_output attributes
351
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_FLOAT_OUTPUT_MIN (-100)
352
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_FLOAT_OUTPUT_MAX (100)
353
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_FLOAT_OUTPUT_START (0)
354
+ #define BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_FLOAT_OUTPUT_STEP (1)
355
+ // define action_test enum_output enum
293
356
enum {
294
357
BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_ENUM_OUTPUT_OUTPUT_ENUM0 = 0 ,
295
358
BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_ENUM_OUTPUT_OUTPUT_ENUM1 = 1 ,
296
359
BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_ENUM_OUTPUT_OUTPUT_ENUM2 = 2 ,
297
- BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_ENUM_OUTPUT_BUTT = 3 ,
360
+ BLE_QIOT_ACTION_OUTPUT_ACTION_TEST_ENUM_OUTPUT_BUTT ,
298
361
};
299
362
300
- // define max input id and output id in all of input id and output id above
301
- #define BLE_QIOT_ACTION_INPUT_ID_BUTT 6
302
- #define BLE_QIOT_ACTION_OUTPUT_ID_BUTT 6
303
-
363
+ #define BLE_QIOT_ACTION_INPUT_ID_BUTT 6
364
+ #define BLE_QIOT_ACTION_OUTPUT_ID_BUTT 6
304
365
// define action input handle, return 0 is success, other is error.
305
366
// input_param_array carry the data from server, include input id, data length ,data val
306
367
// input_array_size means how many input id
307
368
// output_id_array filling with output id numbers that need obtained, sdk will traverse it and call the action_output_handle to obtained data
308
369
typedef int (* action_input_handle )(e_ble_tlv * input_param_array , uint8_t input_array_size , uint8_t * output_id_array );
309
-
310
370
// define action output handle, return length of the data, 0 is no data, -1 is error
311
371
// output_id means which id data should be obtained
312
372
typedef int (* action_output_handle )(uint8_t output_id , char * buf , uint16_t buf_len );
313
-
314
373
// each action have a struct ble_action_t, make up a array named sg_ble_action_array
315
374
typedef struct {
316
375
action_input_handle input_cb ; //handle input data
@@ -320,39 +379,37 @@ typedef struct{
320
379
uint8_t input_id_size ; //numbers of input id
321
380
uint8_t output_id_size ; //numbers of output id
322
381
}ble_action_t ;
382
+
323
383
// property module
324
384
#ifdef BLE_QIOT_INCLUDE_PROPERTY
325
385
uint8_t ble_get_property_type_by_id (uint8_t id );
326
-
327
386
int ble_user_property_set_data (const e_ble_tlv * tlv );
328
387
int ble_user_property_get_data_by_id (uint8_t id , char * buf , uint16_t buf_len );
329
388
int ble_user_property_report_reply_handle (uint8_t result );
330
389
int ble_lldata_parse_tlv (const char * buf , int buf_len , e_ble_tlv * tlv );
331
390
int ble_user_property_struct_handle (const char * in_buf , uint16_t buf_len , ble_property_t * struct_arr , uint8_t arr_size );
332
391
int ble_user_property_struct_get_data (char * in_buf , uint16_t buf_len , ble_property_t * struct_arr , uint8_t arr_size );
392
+ int ble_user_property_struct_array_set (uint8_t id , const char * in_buf , uint16_t buf_len , ble_property_t struct_arr [], uint8_t arr_size );
393
+ int ble_user_property_struct_array_get (uint8_t id , char * in_buf , uint16_t buf_len , ble_property_t struct_arr [], uint8_t arr_size );
333
394
#endif
334
-
335
395
// event module
336
396
#ifdef BLE_QIOT_INCLUDE_EVENT
337
397
int ble_event_get_id_array_size (uint8_t event_id );
338
398
uint8_t ble_event_get_param_id_type (uint8_t event_id , uint8_t param_id );
339
399
int ble_event_get_data_by_id (uint8_t event_id , uint8_t param_id , char * out_buf , uint16_t buf_len );
340
400
int ble_user_event_reply_handle (uint8_t event_id , uint8_t result );
341
401
#endif
342
-
343
402
// action module
344
403
#ifdef BLE_QIOT_INCLUDE_ACTION
345
404
uint8_t ble_action_get_intput_type_by_id (uint8_t action_id , uint8_t input_id );
346
405
uint8_t ble_action_get_output_type_by_id (uint8_t action_id , uint8_t output_id );
347
406
int ble_action_get_input_id_size (uint8_t action_id );
348
407
int ble_action_get_output_id_size (uint8_t action_id );
349
- int ble_action_user_handle_input_param (uint8_t action_id , e_ble_tlv * input_param_array , uint8_t input_array_size ,
350
- uint8_t * output_id_array );
408
+ int ble_action_user_handle_input_param (uint8_t action_id , e_ble_tlv * input_param_array , uint8_t input_array_size , uint8_t * output_id_array );
351
409
int ble_action_user_handle_output_param (uint8_t action_id , uint8_t output_id , char * buf , uint16_t buf_len );
352
410
#endif
353
411
354
-
355
412
#ifdef __cplusplus
356
413
}
357
414
#endif
358
- #endif //BLE_QIOT_TEMPLATE_H_
415
+ #endif //BLE_QIOT_TEMPLATE_H_
0 commit comments