guowenxue
2022-04-19 edcdb8b7e2b21a4e4ec46f39f13a8601852d5957
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
/*********************************************************************************
 *      Copyright:  (C) 2019 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  conf.h
 *    Description:  This file is mqttd configure file parser function
 *                 
 *        Version:  1.0.0(2019年06月25日)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "2019年06月25日 22时23分55秒"
 *                 
 ********************************************************************************/
#ifndef  __CONF_H_
#define  __CONF_H_
 
#include "hal/hal.h"
 
enum
{
    Qos0, /* 发送者只发送一次消息,不进行重试,Broker不会返回确认消息。在Qos0情况下,Broker可能没有接受到消息 */
    Qos1, /* 发送者最少发送一次消息,确保消息到达Broker,Broker需要返回确认消息PUBACK。在Qos1情况下,Broker可能接受到重复消息 */
    Qos2, /* Qos2使用两阶段确认来保证消息的不丢失和不重复。在Qos2情况下,Broker肯定会收到消息,且只收到一次  */
};
 
 
typedef struct log_ctx_s
{
    /* logger settings */
    char          logfile[128]; /* logger record file */
    int           loglevel;     /* logger level  */
    int           logsize;      /* logger file maxsize, oversize will rollback */
} log_ctx_t;
 
typedef struct mqtt_ctx_s
{
    char          id[32];       /*  production ID */
 
    /* Broker settings  */
    char          host[128];  /* MQTT broker server name  */
    int           port;       /* MQTT broker listen port  */
    char          uid[64];    /* username */
    char          pwd[64];    /* password */
    int           keepalive;  /* MQTT broker send PING message to subsciber/publisher keepalive timeout<seconds> */
 
    /* Subscriber settings */
    char          subTopic[256]; /* Subscriber topic */
    int           subQos;        /* Subscriber Qos  */
} mqtt_ctx_t;
 
 
typedef struct lightd_ctx_s
{
    log_ctx_t     log_ctx;
    hal_ctx_t     hal_ctx;
    mqtt_ctx_t    mqtt_ctx;
} lightd_ctx_t;
 
 
extern int parser_conf(const char *conf_file, lightd_ctx_t *ctx, int debug);
 
#endif   /* ----- #ifndef _CONF_H_  ----- */