Commit 5eda44dc authored by 学习的菜鸟's avatar 学习的菜鸟

加入了wifi修改

parent 812f44eb
#include "device_wifi_change.h"
#include "audioplay.h"
#include "device_identity.h"
#include "mqtt_init.h"
#include "common.h"
#include "delay.h"
#include "device_wifi_change.h"
char current_ssid[SSID_MAX_LEN] = {0};//用于存现在已连接WiFi
char wifi_Last_ssid[SSID_MAX_LEN]= {0} ;
......@@ -443,7 +444,7 @@ int wifi_change_sendmqtt_init(){
}else {
if(change_wifi_connect(default_SSID,default_password)==0)delete_wifi_conf();
my_zlog_debug("WiFi无网切回");
delay_s(10); ;
delay_s(10);
}
}
......
......@@ -45,7 +45,6 @@ char *device_inspect() {
/*设备读取文件初始化*/
int device_id_file_init() {
g_device_id=device_inspect();
my_zlog_debug("读取到文件内容222: %s", g_device_id);
return 0;
}
char *device_id_function(){
......
......@@ -159,7 +159,7 @@ int device_mqtt_topic_init() {
free(sub_str);
delay_s(20);
delay_s(10);
if(g_device_name_exists == 0) {
sprintf(g_app2dev_topic,"app2dev/%s",readbuf);
sprintf(g_dev2app_topic,"dev2app/%s",readbuf);
......
......@@ -6,20 +6,38 @@ int main(){
return -1;
}
if (wiringPiSetup() == -1) {
if(wiringPiSetup() == -1) {
my_zlog_fatal("WiringPi setup failed!");
return -2;
}
if(wifi_change_sendmqtt_init()!=0){
my_zlog_error("WIFI是否更改检查相关,不会到这一步,有问题会直接重启,可能会导致重启,不会因此造成程序停止");
}
if(device_id_file_init()!=0){
my_zlog_error("设备id读取失败");
return -3;
}
if(device_mqtt_topic_init()!=0){
my_zlog_error("mqtt的topic读取失败");
my_zlog_error("设备id判断失败");
return -4;
}
if(request_date() !=0){
my_zlog_error("请求数据失败");
return -5;
}
if(softiic_init()!=0){
my_zlog_error("软件iic初始化失败");
return -6;
}
if(ina225_init()!=0){
my_zlog_warn("此版本电压没有使用INA226");
}
int thread_rc=thread_start_init( thread_exit_time,thread_mqtt_beat,thread_open_browser,thread_mqtt_reconnect,thread_time_calculation,thread_play_mp3);
thread_end_close();
......
......@@ -5,6 +5,10 @@
#include "device_fileopen.h"
#include "device_identity.h"
#include "pthread_open.h"
#include "http_request.h"
#include "device_wifi_change.h"
#include "softiic.h"
#include "INA226.h"
/*设备id读取初始化*/
int device_id_file_init();
......@@ -15,18 +19,28 @@ int mylog_init();
/*wiringPi初始化函数*/
int wiringPiSetup();
int softiic_init();
/*mqtt的topic初始化*/
int device_mqtt_topic_init();
int ina225_init();
/*wifi改变初始化,放在main开头,必须要等mqtt直播就绪才行*/
int wifi_change_sendmqtt_init();
/*线程初始化函数*/
int thread_start_init(ThreadFunc thread_exit_time, ThreadFunc thread_mqtt_beat,
ThreadFunc thread_open_browser, ThreadFunc thread_mqtt_reconnect,
ThreadFunc thread_time_calculation, ThreadFunc thread_play_mp3);
/*像服务器请求*/
int request_date();
/*线程关闭函数*/
void thread_end_close() ;
/*关闭log日志记录*/
void my_log_close();
#endif
......@@ -5,8 +5,10 @@
#include "mqtt_infor_handle.h"
#include "browser_open.h"
#include "mqtt_verify.h"
#include "device_wifi_change.h"
//#include "device_wifi_change.h"
#include "browser_open.h"
#include "device_init.h"
#include "audioplay.h"
pthread_t g_thread[6]; // 全局线程句柄数组(或传参)
......@@ -55,10 +57,8 @@ void *thread_exit_time(void *arg) {
void *thread_mqtt_beat(void *arg) {
my_zlog_info("thread_mqtt_beat start");
wifi_change_sendmqtt_init();
delay_s(5);
g_webrtc_index=1;
int device_type=0;
while(1) {
if( device_type == 202) delay_ms(45);
if( device_type != 202)delay_ms(100);
......@@ -134,7 +134,7 @@ void *thread_time_calculation(void *arg) {
//专门处理MP3播放
void *thread_play_mp3(void* arg) {
//audioplay_cycle();
audioplay_cycle();
return NULL;
}
......
......@@ -822,29 +822,29 @@ drivers/sensors/temperature.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/sensors/temperature.c.s
.PHONY : drivers/sensors/temperature.c.s
drivers/sensors/warm.o: drivers/sensors/warm.c.o
.PHONY : drivers/sensors/warm.o
drivers/sensors/warn.o: drivers/sensors/warn.c.o
.PHONY : drivers/sensors/warn.o
# target to build an object file
drivers/sensors/warm.c.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/sensors/warm.c.o
.PHONY : drivers/sensors/warm.c.o
drivers/sensors/warn.c.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/sensors/warn.c.o
.PHONY : drivers/sensors/warn.c.o
drivers/sensors/warm.i: drivers/sensors/warm.c.i
.PHONY : drivers/sensors/warm.i
drivers/sensors/warn.i: drivers/sensors/warn.c.i
.PHONY : drivers/sensors/warn.i
# target to preprocess a source file
drivers/sensors/warm.c.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/sensors/warm.c.i
.PHONY : drivers/sensors/warm.c.i
drivers/sensors/warn.c.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/sensors/warn.c.i
.PHONY : drivers/sensors/warn.c.i
drivers/sensors/warm.s: drivers/sensors/warm.c.s
.PHONY : drivers/sensors/warm.s
drivers/sensors/warn.s: drivers/sensors/warn.c.s
.PHONY : drivers/sensors/warn.s
# target to generate assembly for a file
drivers/sensors/warm.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/sensors/warm.c.s
.PHONY : drivers/sensors/warm.c.s
drivers/sensors/warn.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/sensors/warn.c.s
.PHONY : drivers/sensors/warn.c.s
modules/browser/browser_open.o: modules/browser/browser_open.c.o
.PHONY : modules/browser/browser_open.o
......@@ -1651,9 +1651,9 @@ help:
@echo "... drivers/sensors/temperature.o"
@echo "... drivers/sensors/temperature.i"
@echo "... drivers/sensors/temperature.s"
@echo "... drivers/sensors/warm.o"
@echo "... drivers/sensors/warm.i"
@echo "... drivers/sensors/warm.s"
@echo "... drivers/sensors/warn.o"
@echo "... drivers/sensors/warn.i"
@echo "... drivers/sensors/warn.s"
@echo "... modules/browser/browser_open.o"
@echo "... modules/browser/browser_open.i"
@echo "... modules/browser/browser_open.s"
......
No preview for this file type
......@@ -5,13 +5,15 @@
int abnormal_pin_pwm_stop=0;
int device_type =0;
const deviceconfig_t device_configs[] = {
// car0101配置
{
.device_id = 101,
.device_name = "car0101",
.gpio_pins = {5, 6, 7, 10, 16, 20, 22, 23, 24, 25, 26, 27, -1},
.gpio_pwms = {-1},
.gpio_pins = {5, 6, 7, 10, 16, 20, 22, 23, 24, 25, 26, -1},
.gpio_pwms = {27,-1},
.device_pwm_init = physics_pwm_init,
.device_control_stop = car0101_middle_pwm,
.emergency_code = 101
......@@ -66,7 +68,7 @@ const deviceconfig_t device_configs[] = {
{ .device_id = -1 }
};
bool get_array_length(int* arr) {
bool get_array_length(const int* arr) {
if(arr[0] != -1) { // 遇到-1停止计数
return TRUE;
}
......@@ -94,9 +96,8 @@ void device_init(int device_id) {
if(get_array_length(config->gpio_pins)==TRUE)init_gpiopwm(config->gpio_pwms); // GPIOsoft_pwm初始化
config->device_pwm_init(); // PWM初始化
config->device_control_stop(); // 速度控制初始化
device_type =config->emergency_code;
// 设置异常停止代码
abnormal_pin_pwm_stop = config->emergency_code;
printf("%s initialized successfully!\n", config->device_name);
}
\ No newline at end of file
#ifndef DEVICE_INIT_H__
#define DEVICE_INIT_H__
extern int abnormal_pin_pwm_stop;
extern int device_type;
typedef struct {
int device_id; // 设备ID (101, 102等)
......
#include "common.h"
#include "gpio_init.h"
#include "http_request.h"
#include "device_init.h"
#include "devcontrol_common.h"
#define MIN_DUTY 0 // 最小占空比
#define MAX_DUTY 100 // 最大占空比
......@@ -13,7 +15,7 @@ int g_gpiowpi[40]; //能使用高低引脚和其他引脚
int g_gpiocount=0;
int g_gpio_softpwmcount=0;
void init_gpiowpi(int *values_pin) {
void init_gpiowpi(const int *values_pin) {
while (values_pin[g_gpiocount] != -1) {
g_gpiocount++;
}
......@@ -27,7 +29,7 @@ void init_gpiowpi(int *values_pin) {
}
}
void init_gpiopwm(int *values_pwm) {
void init_gpiopwm(const int *values_pwm) {
while (values_pwm[g_gpio_softpwmcount] != -1) {
g_gpio_softpwmcount++;
}
......@@ -68,8 +70,8 @@ void pwm_value(int pin,int value) { //软件陪我们控制调速
softPwmWrite(pin, shot_speed);
my_zlog_debug("pin:%d,%d",pin,shot_speed);
} else {
//if(AppExit_pin_pwm == 202)softPwmWrite(pin, 30);
//if(AppExit_pin_pwm != 202 )softPwmWrite(pin, shot_speed);
if(device_type == DEVICE_TANK0202)softPwmWrite(pin, 30);
if(device_type != DEVICE_TANK0202 )softPwmWrite(pin, shot_speed);
}
......
......@@ -11,8 +11,8 @@
#define PWM_PIN_SPEED 21
#define PWM_PIN_CHANGE 2
void init_gpiowpi(int *values_pin);//gpio引脚初始化
void init_gpiopwm(int *values_pwm);
void init_gpiowpi(const int *values_pin);//gpio引脚初始化
void init_gpiopwm(const int *values_pwm);
void pin_value(int pin,int value);//控制引脚高低
......
......@@ -11,12 +11,12 @@ void i2c_delay() {
}
// 初始化 I2C 引脚
bool SOFTiic_init() {
int softiic_init() {
pinMode(sda_pin, OUTPUT);
pinMode(scl_pin, OUTPUT);
digitalWrite(sda_pin, HIGH);
digitalWrite(scl_pin, HIGH);
return true;
return 0;
}
// I2C 起始信号
......
......@@ -4,7 +4,7 @@
extern int sda_pin; // GPIO0
extern int scl_pin; // GPIO1
bool SOFTiic_init();
int softiic_init();
// I2C 起始信号
void i2c_start();
......
......@@ -4,8 +4,9 @@
float currentLSB;
// 配置 INA226
bool INA226_configure() {
bool ina226_configure() {
uint16_t config = 0x4127; // 默认配置:16次平均,1.1ms 转换时间,连续模式
i2c_start();
i2c_write_byte(INA226_ADDRESS << 1);
......@@ -17,7 +18,7 @@ bool INA226_configure() {
}
// 校准 INA226
bool INA226_calibrate(float rShuntValue, float iMaxExpected) {
bool ina226_calibrate(float rShuntValue, float iMaxExpected) {
currentLSB = iMaxExpected / 32767.0; // 电流 LSB
uint16_t calibrationValue = (uint16_t)(0.00512 / (currentLSB * rShuntValue));
......@@ -31,7 +32,7 @@ bool INA226_calibrate(float rShuntValue, float iMaxExpected) {
}
// 读取总线电压
float INA226_readBusVoltage() {
float ina226_readbusvoltage(){
i2c_start();
i2c_write_byte(INA226_ADDRESS << 1);
i2c_write_byte(INA226_REG_BUSVOLTAGE);
......@@ -45,7 +46,7 @@ float INA226_readBusVoltage() {
}
// 读取电流
float INA226_readCurrent() {
float ina226_readcurrent() {
i2c_start();
i2c_write_byte(INA226_ADDRESS << 1);
i2c_write_byte(INA226_REG_CURRENT);
......@@ -57,3 +58,20 @@ float INA226_readCurrent() {
int16_t value = (high << 8) | low;
return -value * currentLSB;
}
int ina225_init(){
// 配置 INA226
if(!ina226_configure()) {
my_zlog_warn("INA226初始化失败");
return -1;
}
// 校准 INA226
float rshuntvalue = 0.01; // 分流电阻值(单位:欧姆)
float imaxexpected= 5; // 最大预期电流(单位:安培)
if(!ina226_calibrate(rshuntvalue, imaxexpected)){
my_zlog_warn("INA226校准失败");
return -2;
}
return 0;
}
......@@ -10,16 +10,13 @@
#define INA226_REG_CURRENT (0x04)
#define INA226_REG_CALIBRATION (0x05)
// 配置 INA226
bool INA226_configure();
// 校准 INA226
bool INA226_calibrate( float rShuntValue, float iMaxExpected);
/*初始化ina226,包括配置 INA226和校准 INA226*/
int ina225_init();
// 读取总线电压
float INA226_readBusVoltage();
float ina226_readbusvoltage();
// 读取电流
float INA226_readCurrent();
float ina226_readcurrent();
#endif // INA226_H
\ No newline at end of file
#include "common.h"
#include "audioplay.h"
#include "device_identity.h"
#include "mqtt_init.h"
int audio_status=7;
char urlbuf[512];
char keybuf[256];
double audio_volume=0.8;
//接收音频播放
void audioplay_mqtt_receive(cJSON *json) {
// 解析"audioLink"字段(修正了原始JSON中的拼写错误)
cJSON *audio_link = cJSON_GetObjectItemCaseSensitive(json, "audioLink");
if (cJSON_IsString(audio_link) && (audio_link->valuestring != NULL)) {
my_zlog_debug("音频链接: %s", audio_link->valuestring);
char *url=audio_link->valuestring;
snprintf(urlbuf, sizeof(urlbuf), "%s", url);
} else {
my_zlog_warn("错误:无法解析音频链接字段");
}
// 解析"key"字段
cJSON *key_char = cJSON_GetObjectItemCaseSensitive(json, "key");
if (cJSON_IsString(key_char) && (key_char->valuestring != NULL)) {
my_zlog_debug("音频链接: %s", key_char->valuestring);
char *key=key_char->valuestring;
snprintf(keybuf, sizeof(keybuf), "%s", key);
} else {
my_zlog_warn("错误:无法解析音频链接");
audio_status=5;
}
// 解析"status"字段
cJSON *audio_status_val = cJSON_GetObjectItemCaseSensitive(json, "status");
if (cJSON_IsNumber(audio_status_val)) {
my_zlog_debug("标志: %d", audio_status_val->valueint);
audio_status=audio_status_val->valueint;
} else {
my_zlog_warn("错误:无法解析标志字段");
}
// 解析"volume"字段
cJSON *volume = cJSON_GetObjectItemCaseSensitive(json, "volume");
if (cJSON_IsNumber(volume)) {
my_zlog_debug("声量大小: %1f", volume->valuedouble);
audio_volume=volume->valuedouble + 0.0;
} else {
my_zlog_warn("错误:无法解析声量字段");
}
}
//发送音频播放是否完毕
void audioplay_send_mqtt() {
cJSON *root = cJSON_CreateObject();
cJSON *body = cJSON_CreateObject();
cJSON *head = cJSON_CreateObject();
// 添加各个字段到 JSON 对象
cJSON_AddStringToObject(body, "type", "audio");
cJSON_AddStringToObject(body, "audioLink", urlbuf);
cJSON_AddStringToObject(body, "key", keybuf);
cJSON_AddNumberToObject(body, "status", audio_status);
cJSON_AddNumberToObject(body, "volume", audio_volume);
cJSON_AddNumberToObject(head, "message_type",3001);
cJSON_AddItemToObject(root, "body", body);
cJSON_AddItemToObject(root, "head",head);
// 将 JSON 对象转换为字符串
char* json_string = cJSON_PrintUnformatted(root);
my_zlog_debug("%s",json_string);
mosquitto_publish(mosq, NULL, mqtt_topic_pure_number(), strlen(json_string), json_string, 0, false);
// 释放 JSON 对象内存
cJSON_Delete(root);
}
//音频播放
void audioplay_cycle(){
char command[512];
int ret;
while(1){
if(audio_status==0){
char *urlmoddle=urlbuf;
snprintf(command, sizeof(command),
"sudo ffplay -nodisp -autoexit -loglevel quiet -af \"volume=%1f\" \"%s\"",
audio_volume,urlmoddle);
my_zlog_debug("播放地址: %s\n", urlbuf);
ret = system(command);
if (ret == -1) {
my_zlog_error("播放失败");
audio_status=2;
}
if (WIFEXITED(ret) && WEXITSTATUS(ret) == 0) {
my_zlog_debug("播放已成功完成 : %s ", urlbuf);
audio_status=1;
} else {
my_zlog_warn("播放失败或中断: %s ", urlbuf);
audio_status=2;
}
audioplay_send_mqtt();
}
}
}
\ No newline at end of file
#ifndef AUDIOPLAY_H
#define AUDIOPLAY_H
#include <cjson/cJSON.h>
// extern int audio_status;
void audioplay_mqtt_receive(cJSON *body); //接收音频mqtt播放函数
void audioplay_cycle();//音频播放线程中函数
#endif
\ No newline at end of file
#include "common.h"
#include "warm.h"
#include "warn.h"
#include "http_request.h"
#include "mylog.h"
#include "gpio_init.h"
......@@ -57,14 +57,14 @@ int alarm_control_close(float voltage) {//关闭警报
}
int alarm_control(float voltage) {
#if WARM_MODE == 1
#if WARN_MODE == 1
my_zlog_info("Mode 1: 执行代码A");
return alarm_control_open(voltage);
#elif WARM_MODE == 2
#elif WARN_MODE == 2
my_zlog_info("Mode 2: 执行代码B");
return alarm_control_close(voltage);
#else
my_zlog_error("未知的 WARM_MODE: %d", WARM_MODE);
my_zlog_error("未知的 WARN_MODE: %d", WARN_MODE);
return -1;
#endif
}
\ No newline at end of file
#ifndef WARM_H__
#define WARM_H__
#ifndef WARN_H__
#define WARN_H__
/*当mode为1时候打开警报,为2时候关闭警告*/
#define WARM_MODE 1
#define WARN_MODE 1
int alarm_control(float voltage);
......
......@@ -3,7 +3,6 @@
#include "car0101_control.h"
#define DEVICE_CAR0101 101
#define DEVICE_CAR0102 102
#define DEVICE_CAR0103 103
......
......@@ -12,7 +12,7 @@ int g_errCodeValue;
bool g_enable_buzzer_value=0;
double g_warn_voltage_value=10.7;
double g_err_voltage_value=9.7;
double g_shot_speed_value=0.7;
double g_shot_speed_value=0.5;
// 回调函数,用于处理接收到的数据
static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) {
......@@ -109,11 +109,12 @@ char *wirte_json() {
char *payload = cJSON_PrintUnformatted(body);
my_zlog_debug("%s", payload);
cJSON_Delete(body); // 释放 cJSON 对象
cJSON_Delete(body);
return payload;
}
int request_date() {//请求数据
int request_date_open() {//请求数据
CURL *curl;
CURLcode res;
......@@ -165,6 +166,22 @@ int request_date() {//请求数据
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return 0;
}
int request_date() {
#if HTTP_REQUEST_INDEX == 1
// 当MODE为1时的代码
my_zlog_info("HTTP Mode 1: 执行代码A");
return request_date_open();
#elif HTTP_REQUEST_INDEX == 2
// 当MODE为2时的代码
my_zlog_info("HTTP Mode 2: 执行代码B");
return 0;
#else
my_zlog_error("未知的 WARM_MODE: %d", HTTP_REQUEST_INDEX);
return -1;
#endif
}
\ No newline at end of file
......@@ -3,7 +3,8 @@
#include"common.h"// 用于存储HTTP响应数据的结构体
#define HTTP_REQUEST_INDEX 1
/*2为关闭请求,1为打开*/
#define HTTP_REQUEST_INDEX 2
struct MemoryStruct {
char *memory;
......
......@@ -9,10 +9,14 @@
#include "common.h"
#include "INA226.h"
#include "ads1115.h"
#include "warm.h"
#include "warn.h"
#include "device_fileopen.h"
#include "devcontrol_common.h"
#include "device_wifi_change.h"
#include "audioplay.h"
#include "gpio_init.h"
#include "device_init.h"
bool g_verified_mode = TRUE;//控制是否需要验证
......@@ -26,13 +30,13 @@ unsigned char g_valt[4];//存放mqtt接收的tpye,mode等
//心跳发送格式*5/2
void heartbeat_send() {
float voltage = 0;//INA226_readBusVoltage();
float current = 0;//INA226_readCurrent();
my_zlog_debug("%.2f\n", voltage);
float voltage = ina226_readbusvoltage();
float current = ina226_readcurrent();
my_zlog_debug("%.2f", voltage);
if(voltage<=0.5){
voltage=ads1115_read_channel(0)*5/2;
current=ads1115_read_channel(1)*5/2;
my_zlog_debug("%.2f\n", voltage);
my_zlog_debug("%.2f", voltage);
current=(current-voltage)*100;
}
char voltage_str[20]; // 足够存储转换后的字符串的缓冲区
......@@ -78,8 +82,7 @@ void heartbeat_send() {
//mqtt设备行走驱动函数
void device_driver(){
int device_type=0;
if( device_type == 101) car0101_control_change(g_valt) ;
if( device_type == DEVICE_CAR0101) car0101_control_change(g_valt) ;
// if(AppExit_pin_pwm == 102) car0102_speed_change(valt) ;
// if(AppExit_pin_pwm == 103 ) car0103_change(valt) ;
// if(AppExit_pin_pwm == 104 ) car0104_change(valt) ;
......@@ -90,22 +93,20 @@ void device_driver(){
//角度发送
void angle_mqtt_send() {
// float angle_shot=ads1115_read_channel(2);
// if(angle_shot>0){
// angle_shot=angle_shot*360/5;
// //my_zlog_debug("%.2f",angle_shot);
// topic_middle_value();
// cJSON *root = cJSON_CreateObject();
// char TOPIC_send_angle[26];
// double rounded_angle = round(angle_shot * 100) / 100;
// sprintf(TOPIC_send_angle,"dev_rtinfo/%s",TOPIC3);
// cJSON_AddStringToObject(root, "type","tank_angle");
// cJSON_AddNumberToObject(root, "angle",rounded_angle);
// char *payload = cJSON_PrintUnformatted(root);
// my_zlog_debug("%s",payload);
// mosquitto_publish(mosq, NULL, TOPIC_send_angle, strlen(payload), payload, 0, false);
// cJSON_Delete(root); // 释放 cJSON 对象
// }
float angle_shot=ads1115_read_channel(2);
if(angle_shot>0){
angle_shot=angle_shot*360/5;
cJSON *root = cJSON_CreateObject();
char TOPIC_send_angle[26];
double rounded_angle = round(angle_shot * 100) / 100;
sprintf(TOPIC_send_angle,"dev_rtinfo/%s",mqtt_topic_pure_number());
cJSON_AddStringToObject(root, "type","tank_angle");
cJSON_AddNumberToObject(root, "angle",rounded_angle);
char *payload = cJSON_PrintUnformatted(root);
my_zlog_debug("%s",payload);
mosquitto_publish(mosq, NULL, TOPIC_send_angle, strlen(payload), payload, 0, false);
cJSON_Delete(root); // 释放 cJSON 对象
}
}
......@@ -116,7 +117,7 @@ void mqtt_wirte(){
heartbeat_send();
g_heartbeat_count=0;
}
// if( AppExit_pin_pwm == 202) angle_mqtt_send();
if( device_type == 202) angle_mqtt_send();
}
......@@ -269,7 +270,7 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息
my_zlog_debug("进入引脚控制");
break;
case 2001:
//audioplay_mqtt_receive(body);
audioplay_mqtt_receive(body);
my_zlog_debug("进入音频播放");
break;
case 2002:
......@@ -277,11 +278,11 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息
my_zlog_debug("进入修改设备号");
break;
case 2003:
//scan_wifi_json();
scan_wifi_json();
my_zlog_debug("进入查询WiFi");
break;
case 2004:
//wifi_change_recmqtt(body);
wifi_change_recmqtt(body);
my_zlog_debug("进入修改WiFi");
break;
case 2006:
......
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