Commit 64ef9a92 authored by 957dd's avatar 957dd

加入了后台配置验证

parent 149174c2
#include "device_identity.h"g_current_ssid #include "device_identity.h"
#include "mqtt_init.h" #include "mqtt_init.h"
#include "common.h" #include "common.h"
#include "delay.h" #include "delay.h"
......
...@@ -72,6 +72,10 @@ void *thread_mqtt_beat(void *arg) { ...@@ -72,6 +72,10 @@ void *thread_mqtt_beat(void *arg) {
// if(wifi_change_sendmqtt_init()!=0){ // if(wifi_change_sendmqtt_init()!=0){
// my_zlog_error("WIFI是否更改检查相关,不会到这一步,有问题会直接重启,可能会导致重启,不会因此造成程序停止"); // my_zlog_error("WIFI是否更改检查相关,不会到这一步,有问题会直接重启,可能会导致重启,不会因此造成程序停止");
// } // }
if(verify_open_index_init() !=0){
my_zlog_info("mqtt send verify is NULL");
}
while(1) { while(1) {
if( g_device_type == 202) delay_ms(45); if( g_device_type == 202) delay_ms(45);
if( g_device_type != 202)delay_ms(100); if( g_device_type != 202)delay_ms(100);
......
No preview for this file type
...@@ -137,7 +137,7 @@ void device_stop(int device_id) { ...@@ -137,7 +137,7 @@ void device_stop(int device_id) {
} }
if(!config) { if(!config) {
my_zlog_error("Error: Device stop ID %d not found!", device_id); my_zlog_error("Error: Device gpio stop ID %d not found!", device_id);
return; return;
} }
......
...@@ -147,7 +147,7 @@ void tank_shot_stop_control(int device_id,unsigned char pin,unsigned char val) { ...@@ -147,7 +147,7 @@ void tank_shot_stop_control(int device_id,unsigned char pin,unsigned char val) {
} }
if(!g_tank_common_config_t) { if(!g_tank_common_config_t) {
my_zlog_error("Error: Device stop ID %d not found!", device_id); my_zlog_error("Error: Device tank stop ID %d not found!", device_id);
return; return;
} }
g_tank_common_config_t->shot_back(pin,val); g_tank_common_config_t->shot_back(pin,val);
......
...@@ -133,9 +133,8 @@ void device_gpio_control(int device_id,int pin,int val) { ...@@ -133,9 +133,8 @@ void device_gpio_control(int device_id,int pin,int val) {
break; break;
} }
} }
for(int i=0;i<GPIO_ID_THREAD_COUNT;i++ ){ for(int i=0;i<GPIO_ID_THREAD_COUNT;i++ ){
if(gpio_control_config_t&&device_id == gpio_device_id[i]){ if(gpio_control_config_t && device_id == gpio_device_id[i]){
my_zlog_info("线程函数:%d\n", device_id); my_zlog_info("线程函数:%d\n", device_id);
gpio_control_config_t->device_gpio_pthread_create(); //创建线程,线程关闭在tank.common.h中何tank需要的其他线程关闭 gpio_control_config_t->device_gpio_pthread_create(); //创建线程,线程关闭在tank.common.h中何tank需要的其他线程关闭
} }
......
...@@ -305,6 +305,10 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息 ...@@ -305,6 +305,10 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息
refresh_cam(); refresh_cam();
my_zlog_debug("刷新成功"); my_zlog_debug("刷新成功");
break; break;
case 2013:
message2013_recverigy_open(body);
my_zlog_debug("进入是否需要验证");
break;
default: default:
break; break;
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#elif MQTT_IPMODE == 2 #elif MQTT_IPMODE == 2
#define BROKER_ADDRESS "mqtt.luckycar.top" #define BROKER_ADDRESS "mqtt.luckycar.top"
#elif MQTT_IPMODE == 3 #elif MQTT_IPMODE == 3
#define BROKER_ADDRESS "47.91.125.224" #define BROKER_ADDRESS "47.107.64.23"
#else #else
#define BROKER_ADDRESS "127.0.0.1" // 默认地址 #define BROKER_ADDRESS "127.0.0.1" // 默认地址
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include "mqtt_init.h" #include "mqtt_init.h"
#include "mylog.h" #include "mylog.h"
/*TRUE为打开验证,FALSE为关闭验证*/
bool VERIFIED_MODE=FALSE;
bool g_service_verify=TRUE;//验证判断 bool g_service_verify=TRUE;//验证判断
int g_verify_count =12000;//判断是否有一分钟 int g_verify_count =12000;//判断是否有一分钟
...@@ -175,3 +178,61 @@ int message2006_verify(cJSON *body){ ...@@ -175,3 +178,61 @@ int message2006_verify(cJSON *body){
return 0; return 0;
} }
/*接收到是否打开验证的函数*/
int message2013_recverigy_open(cJSON *body){
cJSON *verifty_open_index = cJSON_GetObjectItem(body, "verify_status");
if(verifty_open_index == NULL){
my_zlog_debug("接收验证是否打开为空");
return -1;
}
int verifty_open = verifty_open_index->valueint;
my_zlog_debug("verifty:%d",verifty_open);
if(verifty_open == 0){
VERIFIED_MODE=FALSE;
my_zlog_debug("verify close");
}else {
VERIFIED_MODE=TRUE;
my_zlog_debug("verify open");
}
return 0;
}
/*发送是否打开验证的mqtt给后端验证*/
int message_sendopen_verify(){
cJSON *root = cJSON_CreateObject();
cJSON *body = cJSON_CreateObject();
cJSON *head = cJSON_CreateObject();
cJSON_AddStringToObject(body, "verify_status", 0);
cJSON_AddNumberToObject(head, "message_type",3013);
cJSON_AddItemToObject(root, "body", body);
cJSON_AddItemToObject(root, "head",head);
char *payload = cJSON_PrintUnformatted(root);
if(payload==NULL){
my_zlog_debug("send verify am null");
return -1;
}
my_zlog_debug("%s",payload);
mosquitto_publish(mosq, NULL, mqtt_topic_pure_number(), strlen(payload), payload, 0, false);
cJSON_Delete(root); // 释放 cJSON 对象
return 0;
}
/*发送是否打开验证的mqtt给后端验证初始化*/
int verify_open_index_init(){
if(message_sendopen_verify()!=0){
return -1;
}
return 0;
}
\ No newline at end of file
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
#include "cjson/cJSON.h" #include "cjson/cJSON.h"
#include <pthread.h> #include <pthread.h>
#include <stdbool.h>
/*TRUE为打开验证,FALSE为关闭验证*/ /*TRUE为打开验证,FALSE为关闭验证*/
#define VERIFIED_MODE FALSE extern bool VERIFIED_MODE;
#define AES_BLOCK_SIZE 16 #define AES_BLOCK_SIZE 16
...@@ -16,4 +18,9 @@ int receive_jwt(cJSON *body);//jwt验证 ...@@ -16,4 +18,9 @@ int receive_jwt(cJSON *body);//jwt验证
int message2006_verify(cJSON *body); int message2006_verify(cJSON *body);
/*接收到是否打开验证的函数*/
int message2013_recverigy_open(cJSON *body);
/*发送是否打开验证的mqtt给后端验证初始化*/
int verify_open_index_init();
#endif #endif
\ No newline at end of file
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