mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-13 21:48:25 +08:00
fix:json数据返回错误
add:掉电储存数据 add:优化初始化逻辑
This commit is contained in:
10
TC1/main.c
10
TC1/main.c
@@ -70,6 +70,11 @@ int application_start( void )
|
||||
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
for ( i = 0; i < Relay_NUM; i++ )
|
||||
{
|
||||
MicoGpioInitialize( Relay[i], OUTPUT_PUSH_PULL );
|
||||
//MicoGpioOutputHigh(Relay[i]);
|
||||
}
|
||||
/* Create mico system context and read application's config data from flash */
|
||||
sys_config = mico_system_context_init( sizeof(user_config_t) );
|
||||
user_config = ((system_context_t *) sys_config)->user_config_data;
|
||||
@@ -79,11 +84,6 @@ int application_start( void )
|
||||
require_noerr( err, exit );
|
||||
|
||||
|
||||
for ( i = 0; i < Relay_NUM; i++ )
|
||||
{
|
||||
MicoGpioInitialize( Relay[i], OUTPUT_PUSH_PULL );
|
||||
//MicoGpioOutputHigh(Relay[i]);
|
||||
}
|
||||
|
||||
MicoGpioInitialize( (mico_gpio_t) Button, INPUT_PULL_UP );
|
||||
if ( !MicoGpioInputGet( Button ) )
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#define ZTC1_NAME "zTC1_%02X%02X"
|
||||
|
||||
#define USER_CONFIG_VERSION 2
|
||||
#define USER_CONFIG_VERSION 1
|
||||
#define SETTING_MQTT_STRING_LENGTH_MAX 32 //<2F><><EFBFBD><EFBFBD> 4 <20>ֽڶ<D6BD><DAB6>롣
|
||||
|
||||
#define PLUG_NAME_LENGTH 32
|
||||
|
||||
@@ -212,11 +212,11 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
||||
cJSON_Delete( json_send );
|
||||
}
|
||||
|
||||
// if ( update_user_config_flag )
|
||||
// {
|
||||
// mico_system_context_update( sys_config );
|
||||
// update_user_config_flag = false;
|
||||
// }
|
||||
if ( update_user_config_flag )
|
||||
{
|
||||
mico_system_context_update( sys_config );
|
||||
update_user_config_flag = false;
|
||||
}
|
||||
|
||||
cJSON_Delete( pJsonRoot );
|
||||
return;
|
||||
@@ -303,6 +303,8 @@ bool json_plug_analysis( int udp_flag, char x, cJSON * pJsonRoot, cJSON * pJsonS
|
||||
if ( json_plug_task_analysis( x, i, p_plug_setting, json_plug_setting_send ) )
|
||||
return_flag = true;
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject( json_plug_send, "setting", json_plug_setting_send );
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject( pJsonSend, plug_str, json_plug_send );
|
||||
|
||||
Reference in New Issue
Block a user