From 769064c24e418d2b3a9e19084607018369db9321 Mon Sep 17 00:00:00 2001 From: flykhan Date: Thu, 26 Oct 2023 20:00:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9mqtt=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E4=BD=8D=E7=BD=AE=E4=B8=BAlocalhost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cgi-bin/mqtt_pub_stoc.c | 6 +++--- cgi-bin/mqtt_sub_ctos.c | 4 ++-- sql_base/green_house.db | Bin 5120 -> 5120 bytes 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cgi-bin/mqtt_pub_stoc.c b/cgi-bin/mqtt_pub_stoc.c index 55bf4f4..4f907d0 100644 --- a/cgi-bin/mqtt_pub_stoc.c +++ b/cgi-bin/mqtt_pub_stoc.c @@ -25,8 +25,8 @@ int main(int argc, char const *argv[]) mosquitto_lib_init(); // 初始化(固定格式) struct mosquitto *client = mosquitto_new(NULL, true, NULL); // 创建客户端 mosquitto_connect_callback_set(client, connect_callback); // 设置连接回调函数 - // mosquitto_connect(client, "localhost", 1883, 60); // 连接服务器(地址,端口,超时时间) - mosquitto_connect(client, "flykhan.com", 1883, 60); // 连接服务器(地址,端口,超时时间) + mosquitto_connect(client, "localhost", 1883, 60); // 连接服务器(地址,端口,超时时间) +// mosquitto_connect(client, "flykhan.com", 1883, 60); // 连接服务器(地址,端口,超时时间) mosquitto_loop_start(client); // 开启客户端线程 while (isConnected == 0) ; // 等待连接成功(当连接成功后,isConnected会被置为1,然后跳出循环) @@ -45,4 +45,4 @@ int main(int argc, char const *argv[]) } return 0; -} \ No newline at end of file +} diff --git a/cgi-bin/mqtt_sub_ctos.c b/cgi-bin/mqtt_sub_ctos.c index 786cc52..49f37d8 100644 --- a/cgi-bin/mqtt_sub_ctos.c +++ b/cgi-bin/mqtt_sub_ctos.c @@ -150,8 +150,8 @@ int main(int argc, char const *argv[]) mosquitto_message_callback_set(client, on_message); // 设置接收消息回调函数,用于接收到消息后的处理 // 3. 连接mqtt broker - // int flag = mosquitto_connect(client, "localhost", 1883, 60); - int flag = mosquitto_connect(client, "flykhan.com", 1883, 60*60*24*30); // 连接服务器(地址,端口,超时时间) : 超时时间为一个月 + int flag = mosquitto_connect(client, "localhost", 1883, 60); + //int flag = mosquitto_connect(client, "flykhan.com", 1883, 60*60*24*30); // 连接服务器(地址,端口,超时时间) : 超时时间为一个月 if (flag == MOSQ_ERR_SUCCESS) { printf("-----连接MQTT 服务器成功!-----\n"); diff --git a/sql_base/green_house.db b/sql_base/green_house.db index e8bf7741ba1d2dfb1defd920d5d7bc5143d88c92..b3ad242111200eae735c2a3800f187d9540f6231 100644 GIT binary patch delta 131 zcmZqBXwaA-&B!}Z#+i|KW5N<{9v0>$49qW?FEQ_CUb0z{V+wPOC<`kCJ3E7e(`I83 fa0pHY)1u6%!VyqmCRAacV`(5D%7|5X5f2Lh|9&4Y delta 25 hcmZqBXwaA-&B!@X#+i|GW5N>d%`5_cm=_7K003SH2Rr}(