修复所有编译警告

This commit is contained in:
zzh 2025-06-12 11:04:36 +08:00
parent b94dd4dd74
commit 3b588cbfdc
4 changed files with 27 additions and 8 deletions

32
main.c
View File

@ -83,6 +83,11 @@ int mqtt_port=1883;
int getLedOtaVersion(char *filename);
int getApOtaVersion(char *filename,char *modename);
void hmacsha1(char *key,char* data,char *signbase64,int signbase64_len);
void light_off_tag_report(uint32_t name,uint16_t batteryv);
void search_tag_report();
void copyOnlyTag(void);
/*================================================================================*/
void doCommand_help(int argc, char *argv[])
{
@ -1041,10 +1046,16 @@ void getDevRawPassword(char *devsn){
json_object_object_add(root, "deviceId",json_object_new_string(devsn));
json_object_object_add(root, "oldPassword",json_object_new_string("12345"));
payload = json_object_to_json_string(root);
json_object_put(root);
if (payload == NULL) {
LOG_I("json_object_to_json_string error\n");
return;
}
strncpy(payload_copy, payload, sizeof(payload_copy)-1);
removeSpaces(payload_copy);
strcpy(signtmp,payload);
strcat(signtmp,appSecret);
strncpy(signtmp, payload, sizeof(signtmp) - 1);
signtmp[sizeof(signtmp) - 1] = '\0';
strncat(signtmp, appSecret, sizeof(signtmp) - strlen(signtmp) - 1);
//LOG_I("signtmp:%s\n",signtmp);
get_base64_md5_from_string(signbase64, sizeof(signbase64), signtmp, strlen(signtmp));
//LOG_I("signbase64:%s\n",signbase64);
@ -1052,7 +1063,10 @@ void getDevRawPassword(char *devsn){
appKey, signbase64, payload_copy, getDevRawPasswordUrl);
LOG_I("send_request:%s\n",send_request);
fp=popen(send_request,"r");
fgets(buffer,sizeof(buffer),fp);
if (fp != NULL) {
fgets(buffer, sizeof(buffer), fp);
pclose(fp);
}
//get_string_from_json_string_by_key_unescape(buffer, "message", tmpdata1, sizeof(tmpdata1));
//LOG_I("message: %s\n",tmpdata1);
get_string_from_json_string_by_key_unescape(buffer, "result", tmpdata, sizeof(tmpdata));
@ -1644,7 +1658,7 @@ void *thread_mqtt_recv(void *arg){
searchTimeOld=getCurrentTime();
LOG_I("searchTimeOld:%d\n",searchTimeOld);
isSearchLabelOn=true;
}else if(strcmp(mqtt_parm.msg_type,"3015")==0){
}else if(strcmp(mqtt_parm.msg_type,"3016")==0){
LOG_I("3015 light on\n");
get_string_from_json_string_by_key_unescape(msg_data, "scene", mqtt_parm.msg_scene, sizeof(mqtt_parm.msg_scene));
LOG_I("scene:%s\n",mqtt_parm.msg_scene);
@ -1767,11 +1781,12 @@ void *thread_mqtt_recv(void *arg){
}else{
mqtt_service_reply(stationsn,mqtt_parm.msg_messageId,"labelconfig is empty",0,productid);
}
}else if(strcmp(mqtt_parm.msg_type,"3027")==0){
}else if(strcmp(mqtt_parm.msg_type,"3015")==0){
LOG_I("3027 All light on/off 广播点亮\n");
get_string_from_json_string_by_key_unescape(msg_data, "color", mqtt_parm.msg_color, sizeof(mqtt_parm.msg_color));
LOG_I("color:%s\n",mqtt_parm.msg_color);
strcpy(mqtt_parm.msg_color, "1"); // 默认关闭颜色
LOG_I("color:%s\n",mqtt_parm.msg_color);
get_string_from_json_string_by_key_unescape(msg_data, "sound", mqtt_parm.msg_sound, sizeof(mqtt_parm.msg_sound));
strcpy(mqtt_parm.msg_sound, "0"); // 默认关闭声音
@ -1785,7 +1800,8 @@ void *thread_mqtt_recv(void *arg){
LOG_I("flashInterval:%s\n",mqtt_parm.msg_flashInterval);
get_string_from_json_string_by_key_unescape(msg_data, "lightDuration", mqtt_parm.msg_lightDuration, sizeof(mqtt_parm.msg_lightDuration));
LOG_I("lightDuration:%s\n",mqtt_parm.msg_lightDuration);
strcpy(mqtt_parm.msg_lightDuration, "300"); // 点亮300秒
LOG_I("lightDuration:%s\n",mqtt_parm.msg_lightDuration);
if(isLightEnable){
mqtt_service_reply(stationsn,mqtt_parm.msg_messageId,"ok",1,productid);
@ -1830,7 +1846,7 @@ void hmacsha1(char *key,char* data,char *signbase64,int signbase64_len){
//LOG_I("key_len:%d,data_len:%d\n",strlen(key),strlen(data));
hmac_sha1(key,strlen(key),data,strlen(data),result,&len);
//LOG_I("result_len:%d\n",len);
int t_i;
//int t_i;
//for(t_i=0;t_i<len;t_i++)
// printf("%x ",result[t_i]);
Base64_encode( signbase64, signbase64_len, result,strlen(result));

1
main.h
View File

@ -34,6 +34,7 @@ int wdt_val;
#include "main.h"
#include "ping.h"
#include "Hmacsha1.h"
#include "mqtt/Base64.h"
typedef struct
{

View File

@ -4,6 +4,7 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#define PRINT_TIME_TAG
#define DBG_TAG "uart_can"
#define DBG_LVL DBG_INFO

View File

@ -322,4 +322,5 @@ int uart_data_send_head_ledota(uart_utils_t *uart,uint32_t datalen,uint16_t data
int uart_data_send_ledota(uart_utils_t *uart,char *data,int size);
int uart_data_send_head_apota(uart_utils_t *uart,uint32_t datalen,uint16_t packagenum);
int uart_data_send_apota(uart_utils_t *uart,uint8_t dataori[],int datalen,uint16_t pnum,uint16_t datacrc);
int uart_data_receive_version(uart_utils_t *uart);
#endif