mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
fix:当存在idx作为确认时手机无法接收到数据的问题
This commit is contained in:
@@ -92,7 +92,6 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
||||
|
||||
cJSON_AddItemToObject( json_send, strTemp1, json_send_plug_on );
|
||||
|
||||
|
||||
char *json_str = cJSON_Print( json_send );
|
||||
user_send( udp_flag, json_str ); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
free( json_str );
|
||||
@@ -134,7 +133,7 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
||||
}
|
||||
user_function_set_last_time( );
|
||||
}
|
||||
cJSON_AddNumberToObject( json_send, "nvalue", relay_out( ) );
|
||||
cJSON_AddNumberToObject( json_send, "nvalue", p_nvalue->valueint );
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>setting-----------------------------------------------------------------
|
||||
@@ -263,11 +262,13 @@ bool json_plug_analysis( int udp_flag, char x, cJSON * pJsonRoot, cJSON * pJsonS
|
||||
plug_str[5] = x + '0';
|
||||
|
||||
cJSON *p_plug = cJSON_GetObjectItem( pJsonRoot, plug_str );
|
||||
if ( !p_plug ) return false;
|
||||
if ( !p_plug ) return_flag = false;
|
||||
|
||||
cJSON *json_plug_send = cJSON_CreateObject( );
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>plug on------------------------------------------------------
|
||||
if ( p_plug )
|
||||
{
|
||||
cJSON *p_plug_on = cJSON_GetObjectItem( p_plug, "on" );
|
||||
if ( p_plug_on )
|
||||
{
|
||||
@@ -286,7 +287,8 @@ bool json_plug_analysis( int udp_flag, char x, cJSON * pJsonRoot, cJSON * pJsonS
|
||||
cJSON_Delete( json_return_now );
|
||||
}
|
||||
}
|
||||
cJSON_AddNumberToObject( json_plug_send, "on", user_config->plug[x].on );
|
||||
|
||||
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>plug<75><67>setting<6E><67>Ŀ----------------------------------------------
|
||||
@@ -327,6 +329,9 @@ 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" );
|
||||
if ( p_plug || p_nvalue )cJSON_AddNumberToObject( json_plug_send, "on", user_config->plug[x].on );
|
||||
|
||||
cJSON_AddItemToObject( pJsonSend, plug_str, json_plug_send );
|
||||
return return_flag;
|
||||
|
||||
@@ -98,22 +98,31 @@ static void key_short_press( void )
|
||||
user_relay_set_all( 1 );
|
||||
}
|
||||
|
||||
uint8_t * buf = NULL; //[64] = { 0 };
|
||||
buf = malloc( 64 );
|
||||
if ( buf != NULL )
|
||||
{
|
||||
char relay_out_temp;
|
||||
cJSON *json_send = cJSON_CreateObject( );
|
||||
cJSON_AddStringToObject( json_send, "mac", strMac );
|
||||
if ( user_config->idx >= 0 )
|
||||
sprintf( buf, "{\"idx\" : %d,\"mac\" : \"%s\",\"nvalue\" : %d}", user_config->idx, strMac, relay_out( ) );
|
||||
else
|
||||
sprintf( buf, "{\"mac\" : \"%s\",\"nvalue\" : %d}", strMac, relay_out( ) );
|
||||
os_log("send %s", buf);
|
||||
if ( !user_mqtt_isconnect( ) ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
user_udp_send( buf );
|
||||
else
|
||||
user_mqtt_send( buf );
|
||||
free( buf );
|
||||
cJSON_AddNumberToObject( json_send, "idx", user_config->idx );
|
||||
|
||||
relay_out_temp = relay_out( ) ? 1 : 0;
|
||||
char plug_str[] = "plug_X";
|
||||
for ( i = 0; i < PLUG_NUM; i++ )
|
||||
{
|
||||
plug_str[5] = i + '0';
|
||||
cJSON *json_plug_send = cJSON_CreateObject( );
|
||||
cJSON_AddNumberToObject( json_plug_send, "on", relay_out_temp );
|
||||
cJSON_AddItemToObject( json_send, plug_str, json_plug_send );
|
||||
}
|
||||
|
||||
char *json_str = cJSON_Print( json_send );
|
||||
if ( !user_mqtt_isconnect( ) ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
user_udp_send( json_str );
|
||||
else
|
||||
user_mqtt_send( json_str );
|
||||
|
||||
free( (void *) json_str );
|
||||
cJSON_Delete( json_send );
|
||||
|
||||
}
|
||||
mico_timer_t user_key_timer;
|
||||
uint16_t key_time = 0;
|
||||
|
||||
Reference in New Issue
Block a user