-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubusd.h
64 lines (49 loc) · 1.56 KB
/
ubusd.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
/**
* @file ubusd.h
* @brief iot-ubusd程序的主要数据结构和接口定义
*/
#ifndef __IOT_UBUSD_H__
#define __IOT_UBUSD_H__
#include <iot/mongoose.h>
/**
* @brief 程序配置选项结构
*/
struct ubusd_option {
const char *ubus_obj_cfg_file; /**< ubus对象配置文件路径 */
const char *mqtt_serve_address; //mqtt 服务端口
int mqtt_keepalive; //mqtt 保活间隔
const char *module;
const char *func;
int debug_level; /**< 调试日志级别(0-4) */
};
/**
* @brief 程序配置结构
*/
struct ubusd_config {
struct ubusd_option *opts; /**< 配置选项指针 */
void *ubus_object_json; /**< 解析后的JSON配置对象,退出时需要释放 */
};
/**
* @brief 程序私有数据结构
*/
struct ubusd_private {
struct ubusd_config cfg; /**< 配置信息 */
void *ubus_ctx; /**< ubus上下文 */
struct mg_mgr mgr;
struct mg_connection *mqtt_conn;
uint64_t ping_active;
uint64_t pong_active;
struct mg_fs *fs; /**< mongoose文件系统操作接口 */
int signo; /**< 退出信号 */
volatile int request_full; /**< 请求缓冲区是否已满 */
volatile int response_full; /**< 响应缓冲区是否已满 */
char *request; /**< 请求 */
char *response; /**< 响应 */
};
/**
* @brief 程序主入口函数
* @param user_options 用户配置选项
* @return 0表示成功,其他值表示失败
*/
int ubusd_main(void *user_options);
#endif //__IOT_UBUSD_H__