diff --git a/TC1/main.c b/TC1/main.c index 228c527..4d0b6f1 100644 --- a/TC1/main.c +++ b/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 ) ) diff --git a/TC1/main.h b/TC1/main.h index 4bd85e2..5ac63b8 100644 --- a/TC1/main.h +++ b/TC1/main.h @@ -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 //±ØÐë 4 ×Ö½Ú¶ÔÆë¡£ #define PLUG_NAME_LENGTH 32 diff --git a/TC1/user_function.c b/TC1/user_function.c index ace3f3a..f80de92 100644 --- a/TC1/user_function.c +++ b/TC1/user_function.c @@ -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 );