update lightd and thingsboard
| | |
| | | * All rights reserved. |
| | | * |
| | | * Filename: config.c |
| | | * Description: This file is mqttd configure file parser function |
| | | * Description: This file is lightd configure file parser function |
| | | * |
| | | * Version: 1.0.0(2019年06月25日) |
| | | * Author: Guo Wenxue <guowenxue@gmail.com> |
| | |
| | | goto cleanup; |
| | | } |
| | | /* cJSON parser ID will get "" */ |
| | | snprintf(mqtt->devid, sizeof(mqtt->devid), "\"%s\"", str); |
| | | strncpy(mqtt->devid, str, sizeof(mqtt->devid)); |
| | | log_info("Parser device ID [%s]\n", mqtt->devid); |
| | | |
| | | |
| | |
| | | mqtt->port = val; |
| | | log_info("Parser MQTT broker server [%s:%d]\n", mqtt->host, mqtt->port); |
| | | |
| | | str=iniparser_getstring(ini, "broker:token", NULL); |
| | | strncpy(mqtt->token, str, sizeof(mqtt->uid) ); |
| | | log_info("Parser broker token [%s]\n", mqtt->token); |
| | | if( (str=iniparser_getstring(ini, "broker:token", NULL)) ) |
| | | { |
| | | strncpy(mqtt->token, str, sizeof(mqtt->uid) ); |
| | | log_info("Parser broker token [%s]\n", mqtt->token); |
| | | } |
| | | |
| | | str=iniparser_getstring(ini, "broker:username", NULL); |
| | | strncpy(mqtt->uid, str, sizeof(mqtt->uid) ); |
| | | if( (str=iniparser_getstring(ini, "broker:username", NULL)) ) |
| | | strncpy(mqtt->uid, str, sizeof(mqtt->uid) ); |
| | | |
| | | str=iniparser_getstring(ini, "broker:password", NULL); |
| | | strncpy(mqtt->pwd, str, sizeof(mqtt->pwd) ); |
| | | if( (str=iniparser_getstring(ini, "broker:password", NULL)) ) |
| | | strncpy(mqtt->pwd, str, sizeof(mqtt->pwd) ); |
| | | |
| | | if( mqtt->uid && mqtt->pwd ) |
| | | if( mqtt->uid ) |
| | | log_info("Parser broker account [%s:%s]\n", mqtt->uid, mqtt->pwd); |
| | | |
| | | mqtt->keepalive = iniparser_getint(ini, "broker:keepalive", DEF_KEEPALIVE); |
| | |
| | | * All rights reserved. |
| | | * |
| | | * Filename: config.h |
| | | * Description: This file is mqttd configure file parser function |
| | | * Description: This file is lightd configure file parser function |
| | | * |
| | | * Version: 1.0.0(2019年06月25日) |
| | | * Author: Guo Wenxue <guowenxue@gmail.com> |
| | |
| | | * Copyright: (C) 2019 LingYun IoT System Studio |
| | | * All rights reserved. |
| | | * |
| | | * Filename: main.c |
| | | * Description: This file |
| | | * Filename: lightd.c |
| | | * Description: This file is infrared detect auto light program on RaspberryPi |
| | | * |
| | | * Version: 1.0.0(29/01/19) |
| | | * Author: Guo Wenxue <guowenxue@gmail.com> |
| | |
| | | int init_pwm(int channel, int freq, int duty) |
| | | { |
| | | int rv; |
| | | char buf[32]; |
| | | char path[256]; |
| | | |
| | | if( (rv=export_pwm(channel, 1)) ) |
| | | { |
| | |
| | | } |
| | | |
| | | relay = &ctx.relay[which]; |
| | | log_info("turn Led %s %s\n", relay->name, cmd?"on":"off"); |
| | | |
| | | if( OFF == cmd ) |
| | | { |
| | |
| | | |
| | | memset(buf, 0, sizeof(buf)); |
| | | i2c_read(fd, SHT20_I2CADDR, buf, 3); |
| | | log_dump(LOG_LEVEL_TRACE, "Temperature sample data: ", buf, 3); |
| | | log_dump(LOG_LEVEL_TRACE, "Temperature sample data: ", (char *)buf, 3); |
| | | |
| | | if( !sht20_checksum(buf, 2, buf[2]) ) |
| | | { |
| | |
| | | |
| | | memset(buf, 0, sizeof(buf)); |
| | | i2c_read(fd, SHT20_I2CADDR, buf, 3); |
| | | log_dump(LOG_LEVEL_TRACE, "Relative humidity sample data: ", buf, 3); |
| | | log_dump(LOG_LEVEL_TRACE, "Relative humidity sample data: ", (char *)buf, 3); |
| | | |
| | | if( !sht20_checksum(buf, 2, buf[2]) ) |
| | | { |
| | |
| | | * All rights reserved. |
| | | * |
| | | * Filename: config.c |
| | | * Description: This file is mqttd configure file parser function |
| | | * Description: This file is thingsboard configure file parser function |
| | | * |
| | | * Version: 1.0.0(2019年06月25日) |
| | | * Author: Guo Wenxue <guowenxue@gmail.com> |
| | |
| | | goto cleanup; |
| | | } |
| | | /* cJSON parser ID will get "" */ |
| | | snprintf(mqtt->devid, sizeof(mqtt->devid), "\"%s\"", str); |
| | | strncpy(mqtt->devid, str, sizeof(mqtt->devid)); |
| | | log_info("Parser device ID [%s]\n", mqtt->devid); |
| | | |
| | | |
| | |
| | | mqtt->port = val; |
| | | log_info("Parser MQTT broker server [%s:%d]\n", mqtt->host, mqtt->port); |
| | | |
| | | str=iniparser_getstring(ini, "broker:token", NULL); |
| | | strncpy(mqtt->token, str, sizeof(mqtt->uid) ); |
| | | log_info("Parser broker token [%s]\n", mqtt->token); |
| | | if( (str=iniparser_getstring(ini, "broker:token", NULL)) ) |
| | | { |
| | | strncpy(mqtt->token, str, sizeof(mqtt->uid) ); |
| | | log_info("Parser broker token [%s]\n", mqtt->token); |
| | | } |
| | | |
| | | str=iniparser_getstring(ini, "broker:username", NULL); |
| | | strncpy(mqtt->uid, str, sizeof(mqtt->uid) ); |
| | | if( (str=iniparser_getstring(ini, "broker:username", NULL)) ) |
| | | strncpy(mqtt->uid, str, sizeof(mqtt->uid) ); |
| | | |
| | | str=iniparser_getstring(ini, "broker:password", NULL); |
| | | strncpy(mqtt->pwd, str, sizeof(mqtt->pwd) ); |
| | | if( (str=iniparser_getstring(ini, "broker:password", NULL)) ) |
| | | strncpy(mqtt->pwd, str, sizeof(mqtt->pwd) ); |
| | | |
| | | if( mqtt->uid && mqtt->pwd ) |
| | | if( mqtt->uid ) |
| | | log_info("Parser broker account [%s:%s]\n", mqtt->uid, mqtt->pwd); |
| | | |
| | | mqtt->keepalive = iniparser_getint(ini, "broker:keepalive", DEF_KEEPALIVE); |
| | |
| | | * All rights reserved. |
| | | * |
| | | * Filename: config.h |
| | | * Description: This file is mqttd configure file parser function |
| | | * Description: This file is thingsboard configure file parser function |
| | | * |
| | | * Version: 1.0.0(2019年06月25日) |
| | | * Author: Guo Wenxue <guowenxue@gmail.com> |
| | |
| | | [common] |
| | | devid="RaspberryPi#4B" |
| | | |
| | | # 树莓派连接的外设信息,0:禁用或未连接 其他: 使能或相关硬件连接的Pin管脚(wPI模式) |
| | | # 树莓派连接的外设信息,0:禁用或未连接 |
| | | [hardware] |
| | | |
| | | # 是否使能 RGB 三色灯模块,0:禁用 1:使能 |
| | |
| | | |
| | | # libraries |
| | | libs=openlibs ${SRCS} |
| | | LDFLAGS+=-lmosquitto -lcjson -lssl -lcrypto -lgpiod |
| | | LDFLAGS+=-lmosquitto -lcjson -lssl -lcrypto -lgpiod -lm |
| | | |
| | | LDFLAGS+=-lpthread |
| | | |
| | |
| | | |
| | | subdir: |
| | | @for dir in ${libs} ; do if [ ! -e $${dir} ] ; then ln -s ../$${dir}; fi; done |
| | | @for dir in ${libs} ; do make -C $${dir} ; done |
| | | @for dir in ${libs} ; do CFLAGS="${CFLAGS}" make -C $${dir} ; done |
| | | |
| | | install: |
| | | cp ${APP_NAME} /tftp |
| | |
| | | * Copyright: (C) 2019 LingYun IoT System Studio |
| | | * All rights reserved. |
| | | * |
| | | * Filename: main.c |
| | | * Description: This file |
| | | * Filename: thingsboard.c |
| | | * Description: This file is thingsboard platform device daemon program. |
| | | * |
| | | * Version: 1.0.0(29/01/19) |
| | | * Author: Guo Wenxue <guowenxue@gmail.com> |