APUE course source code
guowenxue
2 days ago dde12e90020d6a426ab12c8c1e9dba22f14bcc7e
Update mqttd project for new JSON string
2 files modified
24 ■■■■■ changed files
project/4.mqttd/etc/iotd.conf 14 ●●●● patch | view | raw | blame | history
project/4.mqttd/iotd.c 10 ●●●● patch | view | raw | blame | history
project/4.mqttd/etc/iotd.conf
@@ -8,13 +8,13 @@
rgbled=1
# 是否使能继电器模块,0:禁用 1:使能
relay=0
relay=1
# 是否使能 DS18b20 温度传感器模块,0:禁用  1:使能
ds18b20=0
ds18b20=1
# 是否使能 SHT2X 温湿度传感器模块,0:禁用  1:使能
sht2x=1
sht2x=0
[logger]
@@ -56,10 +56,10 @@
[subsciber]
# mosquitto_pub -h weike-iot.com -p 8013 -u lingyun -P lingyun -t \$Sys/Studio/Downlink/rpi001 -m '{ "RedLed":"on" }'
# mosquitto_pub -h weike-iot.com -p 8013 -u lingyun -P lingyun -t \$Sys/Studio/Downlink/rpi001 -m '{ "GreenLed":"on" }'
# mosquitto_pub -h weike-iot.com -p 8013 -u lingyun -P lingyun -t \$Sys/Studio/Downlink/rpi001 -m '{ "BlueLed":"on" }'
# mosquitto_pub -h weike-iot.com -p 8013 -u lingyun -P lingyun -t \$Sys/Studio/Downlink/rpi001 -m '{ "Relay":"on" }'
# mosquitto_pub -h weike-iot.com -p 8013 -u lingyun -P lingyun -t \$Sys/Studio/Downlink/rpi001 -m '{ "RedLed":1 }'
# mosquitto_pub -h weike-iot.com -p 8013 -u lingyun -P lingyun -t \$Sys/Studio/Downlink/rpi001 -m '{ "GreenLed":1 }'
# mosquitto_pub -h weike-iot.com -p 8013 -u lingyun -P lingyun -t \$Sys/Studio/Downlink/rpi001 -m '{ "BlueLed":1 }'
# mosquitto_pub -h weike-iot.com -p 8013 -u lingyun -P lingyun -t \$Sys/Studio/Downlink/rpi001 -m '{ "Relay":1 }'
subTopic="$Sys/Studio/Downlink"
subQos=0
project/4.mqttd/iotd.c
@@ -230,10 +230,7 @@
            if( !item )
                continue;
            if( !strcasecmp(item->valuestring, "on") )
                turn_relay(which, ON);
            else if( !strcasecmp(item->valuestring, "off") )
                turn_relay(which, OFF);
            turn_relay(which, item->valueint);
        }
    }
@@ -246,10 +243,7 @@
            if( !item )
                continue;
            if( !strcasecmp(item->valuestring, "on") )
                turn_led(which, ON);
            else if( !strcasecmp(item->valuestring, "off") )
                turn_led(which, OFF);
            turn_led(which, item->valueint);
        }
    }