/*********************************************************************************
|
* 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_
|
|
#define DEF_BORKER_HOSTNAME "master.iot-yun.club"
|
#define DEF_BROKER_PORT 10883
|
#define DEF_BROKER_KEEPALIVE 30
|
#define DEF_BROKER_USERNAME "lingyun"
|
#define DEF_BROKER_PASSWD "lingyun-emb"
|
|
#define DEF_PUBQOS 0
|
#define DEF_PUBINTERVAL 3 /* 3 seconds */
|
|
#define DEF_SUBQOS 0
|
|
#define MQTT_SYS_TOPIC "$Sys/Studio/"
|
#define DEF_SUBTOPIC MQTT_SYS_TOPIC"Downlink"
|
#define DEF_PUBTOPIC MQTT_SYS_TOPIC"Uplink"
|
|
enum
|
{
|
Qos0, /* 发送者只发送一次消息,不进行重试,Broker不会返回确认消息。在Qos0情况下,Broker可能没有接受到消息 */
|
Qos1, /* 发送者最少发送一次消息,确保消息到达Broker,Broker需要返回确认消息PUBACK。在Qos1情况下,Broker可能接受到重复消息 */
|
Qos2, /* Qos2使用两阶段确认来保证消息的不丢失和不重复。在Qos2情况下,Broker肯定会收到消息,且只收到一次 */
|
};
|
|
#define LUX_TRIGGLE_VAL 0.01
|
enum
|
{
|
FILLIN_LIGHT_OFF=0, /* disable */
|
FILLIN_LIGHT_ON, /* enable */
|
FILLIN_LIGHT_AUTO, /* auto fill-in light based on LUX sensor detected value */
|
};
|
|
|
typedef struct hwconf_s
|
{
|
unsigned char enable; /* Hardware enable or not, help to running on X86 */
|
|
int relay_pin; /* relay connected wPI #pin number, if set to 0 means disable */
|
int beep_pin; /* beep connected wPI #pin number, if set to 0 means disable */
|
int beep_times; /* default beep count when beep on */
|
|
unsigned char leds;
|
int red_pin; /* redled connect wPI #pin number, if set to 0 means disable */
|
int green_pin; /*greenled connect wPI #pin number, if set to 0 means disable */
|
int blue_pin; /* blueled connect wPI #pin number, if set to 0 means disable */
|
|
unsigned char ds18b20; /* enable or disable temperature sensor ds18b20 */
|
unsigned char sht2x; /* enable or disable temperature and hummidity sensor sht2x */
|
unsigned char lux; /* enable or disable light intensity sensor TSL2561 */
|
|
/* Infrared detect inbreank */
|
unsigned char infrared_pin; /* enable or disable inbreak detected */
|
unsigned char inbreak_beep; /* enable or diable beep when detect inbreak */
|
unsigned char fillin_light; /* fill-in light when detect inbrank or not */
|
unsigned char light_intval; /* fill-in light interval time, unit second */
|
double lux_threshold; /* Lux sensor detect value smaller than treshold will fill-in light */
|
} hwconf_t;
|
|
|
|
typedef struct mqtt_ctx_s
|
{
|
char id[32]; /* production ID */
|
|
/* hardware configuration */
|
hwconf_t hwconf;
|
|
/* logger settings */
|
char logfile[128]; /* logger record file */
|
int loglevel; /* logger level */
|
int logsize; /* logger file maxsize, oversize will rollback */
|
|
/* 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> */
|
|
/* Publisher settings */
|
char pubTopic[256]; /* Publisher topic */
|
int pubQos; /* Publisher Qos */
|
int interval ; /* Publish sensor data interval time, unit seconds */
|
|
/* Subscriber settings */
|
char subTopic[256]; /* Subscriber topic */
|
int subQos; /* Subscriber Qos */
|
} mqtt_ctx_t;
|
|
|
extern int mqttd_parser_conf(const char *conf_file, mqtt_ctx_t *ctx, int debug);
|
|
#endif /* ----- #ifndef _CONF_H_ ----- */
|