@@ -68,8 +68,6 @@ tuya_iot_license_t license;
6868
6969#define DPID_VOLUME 6
7070
71- static uint8_t _need_reset = 0 ;
72-
7371/**
7472 * @brief user defined log output api, in this demo, it will use uart0 as log-tx
7573 *
@@ -177,15 +175,10 @@ void user_event_handler_on(tuya_iot_client_t *client, tuya_event_msg_t *event)
177175 switch (event -> id ) {
178176 case TUYA_EVENT_BIND_START :
179177 PR_INFO ("Device Bind Start!" );
180- if (_need_reset == 1 ) {
181- PR_INFO ("Device Reset!" );
182- tal_system_reset ();
183- }
184178
185179#if defined(ENABLE_COMP_AI_AUDIO ) && (ENABLE_COMP_AI_AUDIO == 1 )
186180 ai_audio_player_alert (AI_AUDIO_ALERT_NETWORK_CFG );
187181#endif
188-
189182 break ;
190183
191184 /* Print the QRCode for Tuya APP bind */
@@ -197,13 +190,9 @@ void user_event_handler_on(tuya_iot_client_t *client, tuya_event_msg_t *event)
197190#endif
198191 } break ;
199192
200- case TUYA_EVENT_BIND_TOKEN_ON :
201- break ;
202-
203193 /* MQTT with tuya cloud is connected, device online */
204194 case TUYA_EVENT_MQTT_CONNECTED :
205195 PR_INFO ("Device MQTT Connected!" );
206- tal_event_publish (EVENT_MQTT_CONNECTED , NULL );
207196
208197 static uint8_t first = 1 ;
209198 if (first ) {
@@ -217,29 +206,28 @@ void user_event_handler_on(tuya_iot_client_t *client, tuya_event_msg_t *event)
217206 }
218207 break ;
219208
220- /* MQTT with tuya cloud is disconnected, device offline */
221- case TUYA_EVENT_MQTT_DISCONNECT :
222- PR_INFO ("Device MQTT DisConnected!" );
223- tal_event_publish (EVENT_MQTT_DISCONNECTED , NULL );
224- break ;
225-
226209 /* RECV upgrade request */
227210 case TUYA_EVENT_UPGRADE_NOTIFY :
228211 user_upgrade_notify_on (client , event -> value .asJSON );
229212 break ;
230213
231214 /* Sync time with tuya Cloud */
232215 case TUYA_EVENT_TIMESTAMP_SYNC :
233- PR_INFO ("Sync timestamp:%d" , event -> value .asInteger );
234- tal_time_set_posix (event -> value .asInteger , 1 );
235216 tal_event_publish ("app.time.sync" , NULL );
236217 break ;
218+ case TUYA_EVENT_RESET : {
219+ tuya_reset_type_t reset_type = (tuya_reset_type_t )event -> value .asInteger ;
220+ PR_INFO ("Device Reset:%d" , reset_type );
237221
238- case TUYA_EVENT_RESET :
239- PR_INFO ("Device Reset:%d" , event -> value .asInteger );
222+ // TUYA_RESET_TYPE_FACTORY, TUYA_RESET_TYPE_REMOTE_FACTORY, TUYA_RESET_TYPE_DATA_FACTORY
223+ // Need remove the device application data from the kv store
224+ } break ;
225+ case TUYA_EVENT_RESET_COMPLETE : {
226+ PR_INFO ("Device Reset Complete!" );
240227
241- _need_reset = 1 ;
242- break ;
228+ // Restart the device
229+ tal_system_reset ();
230+ } break ;
243231
244232 /* RECV OBJ DP */
245233 case TUYA_EVENT_DP_RECEIVE_OBJ : {
0 commit comments