From dde12e90020d6a426ab12c8c1e9dba22f14bcc7e Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Wed, 26 Nov 2025 09:59:54 +0800
Subject: [PATCH] Update mqttd project for new JSON string
---
project/4.mqttd/etc/iotd.conf | 16 ++++++++--------
project/4.mqttd/iotd.c | 10 ++--------
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/project/4.mqttd/etc/iotd.conf b/project/4.mqttd/etc/iotd.conf
index 0b4d3ba..534d59a 100644
--- a/project/4.mqttd/etc/iotd.conf
+++ b/project/4.mqttd/etc/iotd.conf
@@ -8,20 +8,20 @@
rgbled=1
# 是否使能继电器模块,0:禁用 1:使能
-relay=0
+relay=1
# 是否使能 DS18b20 温度传感器模块,0:禁用 1:使能
-ds18b20=0
+ds18b20=1
# 是否使能 SHT2X 温湿度传感器模块,0:禁用 1:使能
-sht2x=1
+sht2x=0
[logger]
# 日志记录文件
file=/var/log/iotd.log
-# 日志级别: 0:ERROR 1:WARN 2:INFO 3:DEBUG 4:TRACE
+# 日志级别: 0:ERROR 1:WARN 2:INFO 3:DEBUG 4:TRACE
level=2
# 日志回滚大小
@@ -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
diff --git a/project/4.mqttd/iotd.c b/project/4.mqttd/iotd.c
index 1db2f2d..77b3964 100644
--- a/project/4.mqttd/iotd.c
+++ b/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);
}
}
--
Gitblit v1.9.1