Commit a6ba9a6e authored by 957dd's avatar 957dd

update mqtt

parent b8278eba
ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"head":{"message_type":1}}
{"body":{"ip":"192.168.1.74","ID":"dev2app/controlcar0002","N":"","E":""},"he
\ No newline at end of file
No preview for this file type
...@@ -16,6 +16,18 @@ unsigned char gpinTemp=0; ...@@ -16,6 +16,18 @@ unsigned char gpinTemp=0;
unsigned char gvalTemp=0; unsigned char gvalTemp=0;
unsigned char gvalt[4]; unsigned char gvalt[4];
int mqtt_init()
{
// 初始化 mosquitto 库
mosquitto_lib_init();
mosq = mosquitto_new(NULL, true, NULL);
if (!mosq) {
fprintf(stderr, "Failed to create Mosquitto client\n");
return -1;
}
mosquitto_int_option(mosq, MOSQ_OPT_PROTOCOL_VERSION, MQTT_PROTOCOL_V5);
}
void on_connect(struct mosquitto *mosq, void *obj, int rc) //回调函数 void on_connect(struct mosquitto *mosq, void *obj, int rc) //回调函数
{ {
...@@ -32,19 +44,6 @@ void on_connect(struct mosquitto *mosq, void *obj, int rc) //回调函数 ...@@ -32,19 +44,6 @@ void on_connect(struct mosquitto *mosq, void *obj, int rc) //回调函数
} }
int mqtt_init()
{
// 初始化 mosquitto 库
mosquitto_lib_init();
mosq = mosquitto_new(NULL, true, NULL);
if (!mosq) {
fprintf(stderr, "Failed to create Mosquitto client\n");
return -1;
}
mosquitto_int_option(mosq, MOSQ_OPT_PROTOCOL_VERSION, MQTT_PROTOCOL_V5);
}
//int init_mqtt(struct mosquitto *mosq) //int init_mqtt(struct mosquitto *mosq)
/* /*
void mqtt_MAC_wirte() void mqtt_MAC_wirte()
...@@ -84,7 +83,7 @@ void mqtt_wirte() ...@@ -84,7 +83,7 @@ void mqtt_wirte()
printf("%s\n",payload); printf("%s\n",payload);
mosquitto_publish(mosq, NULL, TOPIC2, strlen(payload), payload, 0, false); mosquitto_publish(mosq, NULL, TOPIC2, strlen(payload), payload, 0, false);
mosquitto_publish(mosq, NULL, TOPIC3, strlen(payload), payload, 0, false);
} }
......
...@@ -13,8 +13,9 @@ ...@@ -13,8 +13,9 @@
#define BROKER_ADDRESS "119.45.167.177" #define BROKER_ADDRESS "119.45.167.177"
#define BROKER_PORT 1883 #define BROKER_PORT 1883
#define TOPIC "IEP/controlcar0001" #define TOPIC "dev2app/controlcar0002"
#define TOPIC2 "IEQ/controlcar0001" #define TOPIC2 "app2dev/controlcar0002"
#define TOPIC3 "ser2dev"
#define USERNAME "admin" // 替换为你的用户名 #define USERNAME "admin" // 替换为你的用户名
#define PASSWORD "admin" // 替换为你的密码 #define PASSWORD "admin" // 替换为你的密码
......
...@@ -10,7 +10,7 @@ int opencamsh() ...@@ -10,7 +10,7 @@ int opencamsh()
setenv("DISPLAY", ":0", 1);//设置环境变量https://jywy.yd-ss.com?dev=controcar0004 --new-window sudo setenv("DISPLAY", ":0", 1);//设置环境变量https://jywy.yd-ss.com?dev=controcar0004 --new-window sudo
//sprintf(gwebcam,"sudo firefox --new-window https://jywy.yd-ss.com?dev=%s &",gsite); //sprintf(gwebcam,"sudo firefox --new-window https://jywy.yd-ss.com?dev=%s &",gsite);
system("sudo firefox https://jywy.yd-ss.com?dev=controlcar0001"); system("sudo firefox https://jywy.yd-ss.com?dev=controlcar0002");
printf("%s\n",gwebcam); printf("%s\n",gwebcam);
printf("close cam\n"); printf("close cam\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment