Commit 67263504 authored by 957dd's avatar 957dd

update val

parent 91eeaa51
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,7 +7,8 @@
#include <arpa/inet.h>
#include "mqtt.h"
char TOPIC[18];
//char TOPIC[18];
//char gsite[18];//网址后缀,使用mac地址
void get_mac_address(const char *iface) {
int sock;
......@@ -30,8 +31,8 @@ void get_mac_address(const char *iface) {
printf("MAC address of %s: %02X:%02X:%02X:%02X:%02X:%02X\n",
iface, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
sprintf(TOPIC,"%02X:%02X:%02X:%02X:%02X:%02X",mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
//sprintf(TOPIC,"%02X:%02X:%02X:%02X:%02X:%02X",mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
//sprintf(gsite,"https://jywy.yd-ss.com?dev=%02X%02X%02X%02X%02X%02X",mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
close(sock); // 关闭套接字
......
......@@ -2,7 +2,8 @@
#define __MAC_H__
extern char TOPIC[18];
//extern char TOPIC[18];
//extern char gsite[18];
void get_mac_address(const char *iface) ;
......
No preview for this file type
......@@ -85,14 +85,15 @@ int main(int argc, char *argv[]) {
gStart=time(NULL);//开始时间戳
get_mac_address("eth0");
serial_Init();//串口初始化
mqtt_init();//mqtt初始化
mqtt_create(mosq);//创建mqtt客户端
get_mac_address("eth0");
ipaddr();//获取ip
mqtt_wirte();//mqtt心跳首次发送
//mosquitto_publish(mosq, NULL, "macmqtt", strlen(TOPIC), TOPIC, 0, false);
......
......@@ -52,6 +52,8 @@ void mqtt_MAC_wirte()
cJSON *root = cJSON_CreateObject();
cJSON *body = cJSON_CreateObject();
cJSON_AddStringToObject(body, "TOPIC", TOPIC);
cJSON_AddStringToObject(body, "device", "controlcar0001");
cJSON_AddStringToObject(body, "http", "https://jywy.yd-ss.com?dev=controlcar0001");//gsite
cJSON_AddItemToObject(root, "body", body);
char *payload = cJSON_PrintUnformatted(root);
mosquitto_publish(mosq, NULL, "macmqtt", strlen(payload), payload, 0, false);
......@@ -155,7 +157,7 @@ void message_3(cJSON *body,cJSON *pwm_ctrl)//message_type为3,控制pwm
cJSON *val = cJSON_GetObjectItem(pwm_ctrl, "val"); //val为pwm的值 0~100(unsigned char)(unsigned char)
gmodeTemp= mode->valueint;
gtypeTemp=type->valueint;
gvalTemp= val->valueint*3/4;
gvalTemp= val->valueint;
if(gtypeTemp==3)
{
gvalTemp= val->valueint;
......
......@@ -14,7 +14,7 @@
#define BROKER_ADDRESS "119.45.167.177"
#define BROKER_PORT 1883
//#define TOPIC "controcar0004"
#define TOPIC "controlcar0001"
#define USERNAME "admin" // 替换为你的用户名
#define PASSWORD "admin" // 替换为你的密码
......
......@@ -4,22 +4,22 @@
#include "mac.h"
#include <string.h>
char webcam[100];
char gwebcam[100];
int opencamsh()
{
setenv("DISPLAY", ":0", 1);//设置环境变量https://jywy.yd-ss.com?dev=controcar0004
sprintf(webcam,"sudo firefox --new-window https://jywy.yd-ss.com?dev=%s &",TOPIC);
system(webcam);
printf("%s\n",webcam);
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);
system("firefox https://jywy.yd-ss.com?dev=controlcar0001");
printf("%s\n",gwebcam);
printf("close cam\n");
}
void refresh_cam()
{
system(SHELLFILECLOSE);
//system(SHELLFILECLOSE);
const char *search_command = "xdotool search --name \"Mozilla Firefox\"";
FILE *fp = popen(search_command, "r");
if (!fp) {
......
......@@ -2,8 +2,10 @@
#define __opensh_H__
#define SHELLFILE "/home/kickpi/car/master/camopen.sh"
#define SHELLFILECLOSE "/home/kickpi/car/master/recam.sh"
//#define SHELLFILE "/home/kickpi/car/master/camopen.sh"
//#define SHELLFILECLOSE "/home/kickpi/car/master/recam.sh"
extern char gwebcam[100];
int opencamsh();
......
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