mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-13 05:28:14 +08:00
fix:ota失败时无数据返回的问题
版本0.4
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
#define os_log(format, ...) custom_log("FUNCTION", format, ##__VA_ARGS__)
|
||||
|
||||
#include "TimeUtils.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "user_gpio.h"
|
||||
#include "cJSON/cJSON.h"
|
||||
#include "user_ota.h"
|
||||
#include "user_mqtt_client.h"
|
||||
#include "user_udp.h"
|
||||
|
||||
uint32_t last_time = 0;
|
||||
|
||||
@@ -19,8 +23,8 @@ typedef struct _user_json_context_t
|
||||
int8_t val;
|
||||
} user_json_context_t;
|
||||
|
||||
bool json_plug_analysis( int udp_flag, char x, cJSON * pJsonRoot, cJSON * pJsonSend );
|
||||
bool json_plug_task_analysis( char x, char y, cJSON * pJsonRoot, cJSON * pJsonSend );
|
||||
bool json_plug_analysis( int udp_flag, unsigned char x, cJSON * pJsonRoot, cJSON * pJsonSend );
|
||||
bool json_plug_task_analysis(unsigned char x, unsigned char y, cJSON * pJsonRoot, cJSON * pJsonSend );
|
||||
|
||||
void user_send( int udp_flag, char *s )
|
||||
{
|
||||
@@ -32,8 +36,8 @@ void user_send( int udp_flag, char *s )
|
||||
|
||||
void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
char i;
|
||||
|
||||
unsigned char i;
|
||||
bool update_user_config_flag = false; //<2F><>־λ,<2C><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool return_flag = true; //Ϊtrueʱ<65><CAB1><EFBFBD><EFBFBD>json<6F><6E><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><F2B2BBB7><EFBFBD>
|
||||
|
||||
@@ -119,7 +123,7 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
||||
if ( cJSON_IsNumber( p_nvalue ) )
|
||||
{
|
||||
uint32_t now_time = UpTicks( );
|
||||
os_log( "system_get_time:%d,%d = %09d\r\n", last_time, now_time, (now_time - last_time) );
|
||||
// os_log( "system_get_time:%d,%d = %09d\r\n", last_time, now_time, (now_time - last_time) );
|
||||
if ( now_time - last_time < 1000 && p_idx )
|
||||
{
|
||||
return_flag = false;
|
||||
@@ -226,7 +230,6 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>plug-----------------------------------------------------------------
|
||||
char plug_str[] = "plug_X";
|
||||
for ( i = 0; i < PLUG_NUM; i++ )
|
||||
{
|
||||
if ( json_plug_analysis( udp_flag, i, pJsonRoot, json_send ) )
|
||||
@@ -256,11 +259,6 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
||||
}
|
||||
|
||||
cJSON_Delete( pJsonRoot );
|
||||
return;
|
||||
exit:
|
||||
os_log( "user_function_cmd_received ERROR:0x%x", err );
|
||||
|
||||
cJSON_Delete( pJsonRoot );
|
||||
|
||||
}
|
||||
|
||||
@@ -269,7 +267,7 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
||||
*udp_flag:<3A><><EFBFBD><EFBFBD>udp/mqtt<74><74>־λ,<2C>˴<EFBFBD><CBB4>IJ<DEB8><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ʱ,<2C><>Ҫʵʱ<CAB5><CAB1><EFBFBD>¸<EFBFBD>domoticz
|
||||
*x:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
bool json_plug_analysis( int udp_flag, char x, cJSON * pJsonRoot, cJSON * pJsonSend )
|
||||
bool json_plug_analysis( int udp_flag, unsigned char x, cJSON * pJsonRoot, cJSON * pJsonSend )
|
||||
{
|
||||
if ( !pJsonRoot ) return false;
|
||||
if ( !pJsonSend ) return false;
|
||||
@@ -346,7 +344,7 @@ bool json_plug_analysis( int udp_flag, char x, cJSON * pJsonRoot, cJSON * pJsonS
|
||||
cJSON_AddItemToObject( json_plug_send, "setting", json_plug_setting_send );
|
||||
}
|
||||
}
|
||||
cJSON *p_nvalue = cJSON_GetObjectItem( pJsonRoot, "nvalue" );
|
||||
// cJSON *p_nvalue = cJSON_GetObjectItem( pJsonRoot, "nvalue" );
|
||||
// if ( p_plug || p_nvalue )
|
||||
cJSON_AddNumberToObject( json_plug_send, "on", user_config->plug[x].on );
|
||||
|
||||
@@ -358,7 +356,7 @@ bool json_plug_analysis( int udp_flag, char x, cJSON * pJsonRoot, cJSON * pJsonS
|
||||
*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>json
|
||||
*x:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> y:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
bool json_plug_task_analysis( char x, char y, cJSON * pJsonRoot, cJSON * pJsonSend )
|
||||
bool json_plug_task_analysis( unsigned char x, unsigned char y, cJSON * pJsonRoot, cJSON * pJsonSend )
|
||||
{
|
||||
if ( !pJsonRoot ) return false;
|
||||
bool return_flag = false;
|
||||
|
||||
Reference in New Issue
Block a user