From 6bbbd7aba33a95fe23a17843dbd9947235fd23fc Mon Sep 17 00:00:00 2001 From: Zip <76966589@qq.com> Date: Thu, 14 Mar 2019 13:31:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:json=E6=95=B0=E6=8D=AE=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=94=99=E8=AF=AF=20add:=E6=8E=89=E7=94=B5=E5=82=A8=E5=AD=98?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20add:=E4=BC=98=E5=8C=96=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TC1/main.c | 10 +++++----- TC1/main.h | 2 +- TC1/user_function.c | 12 +++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) 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 );