commit | author | age
|
d6b4a7
|
1 |
/********************************************************************************* |
G |
2 |
* Copyright: (C) 2019 LingYun IoT System Studio |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Filename: conf.h |
|
6 |
* Description: This file is mqttd configure file parser function |
|
7 |
* |
|
8 |
* Version: 1.0.0(2019年06月25日) |
|
9 |
* Author: Guo Wenxue <guowenxue@gmail.com> |
|
10 |
* ChangeLog: 1, Release initial version on "2019年06月25日 22时23分55秒" |
|
11 |
* |
|
12 |
********************************************************************************/ |
|
13 |
#ifndef __CONF_H_ |
|
14 |
#define __CONF_H_ |
|
15 |
|
|
16 |
enum |
|
17 |
{ |
|
18 |
Qos0, /* 发送者只发送一次消息,不进行重试,Broker不会返回确认消息。在Qos0情况下,Broker可能没有接受到消息 */ |
|
19 |
Qos1, /* 发送者最少发送一次消息,确保消息到达Broker,Broker需要返回确认消息PUBACK。在Qos1情况下,Broker可能接受到重复消息 */ |
|
20 |
Qos2, /* Qos2使用两阶段确认来保证消息的不丢失和不重复。在Qos2情况下,Broker肯定会收到消息,且只收到一次 */ |
|
21 |
}; |
|
22 |
|
|
23 |
#define DEF_KEEPALIVE 30 |
|
24 |
#define DEF_PUBINTERVAL 120 |
|
25 |
#define DEF_QOS Qos2 |
|
26 |
|
|
27 |
typedef struct hwconf_s |
|
28 |
{ |
|
29 |
int relay; /* relay aviable or not. 0:Disable 1: Enable */ |
|
30 |
int led; /* RGB led aviable or not. 0:Disable 1: Enable */ |
|
31 |
int beeper; /* beeper aviable or not. 0:Disable 1: Enable */ |
|
32 |
int ds18b20; /* DS1B820 aviable or not. 0:Disable 1: Enable */ |
|
33 |
int sht2x; /* SHT20 aviable or not. 0:Disable 1: Enable */ |
|
34 |
int tsl2561; /* TSL2561 aviable or not. 0:Disable 1: Enable */ |
|
35 |
} hwconf_t; |
|
36 |
|
|
37 |
|
|
38 |
typedef struct mqtt_ctx_s |
|
39 |
{ |
|
40 |
char devid[32]; /* device ID */ |
|
41 |
|
|
42 |
/* hardware configuration */ |
|
43 |
hwconf_t hwconf; |
|
44 |
|
|
45 |
/* logger settings */ |
|
46 |
char logfile[128]; /* logger record file */ |
|
47 |
int loglevel; /* logger level */ |
|
48 |
int logsize; /* logger file maxsize, oversize will rollback */ |
|
49 |
|
|
50 |
/* Broker settings */ |
|
51 |
char host[128]; /* MQTT broker server name */ |
|
52 |
int port; /* MQTT broker listen port */ |
|
53 |
char uid[64]; /* username */ |
|
54 |
char pwd[64]; /* password */ |
|
55 |
int keepalive; /* MQTT broker send PING message to subsciber/publisher keepalive timeout<seconds> */ |
|
56 |
|
|
57 |
/* Publisher settings */ |
|
58 |
char pubTopic[256]; /* Publisher topic */ |
|
59 |
int pubQos; /* Publisher Qos */ |
|
60 |
int interval ; /* Publish sensor data interval time, unit seconds */ |
|
61 |
|
|
62 |
/* Subscriber settings */ |
|
63 |
char subTopic[256]; /* Subscriber topic */ |
|
64 |
int subQos; /* Subscriber Qos */ |
|
65 |
} mqtt_ctx_t; |
|
66 |
|
|
67 |
|
|
68 |
extern int mqttd_parser_conf(const char *conf_file, mqtt_ctx_t *ctx, int debug); |
|
69 |
|
|
70 |
#endif /* ----- #ifndef _CONF_H_ ----- */ |
|
71 |
|