Last Updated on : 2024-06-26 05:39:54download
When you debug your application code, logs can help you determine the severity of a problem, identify contributing factors, and quickly resolve them. This topic describes local logs of different types and how to read them. This can help you understand error messages for quick troubleshooting. Error codes ship with this topic enable you to have a quick search on issues.
The SDK provides the following log levels:
The log level determines how much granularity to display in the log. For example, if you set the level to TY_LOG_LEVEL_INFO
, ERR
, WARN
, NOTICE
, and INFO
information will be displayed, while DEBUG
and TRACE
information will not be displayed.
VOID pre_device_init(VOID)
{
.... // Irrelevant to this feature
PR_DEBUG("%s",tuya_iot_get_sdk_info());
PR_DEBUG("%s:%s",APP_BIN_NAME,DEV_SW_VERSION);
PR_NOTICE("firmware compiled at %s %s",__DATE__,__TIME__);
PR_NOTICE("system reset reason:[%s]",tuya_hal_system_get_rst_info());
SetLogManageAttr(TY_LOG_LEVEL_DEBUG); // Set the log level.
}
/* Tuya SDK definition of log level */
typedef INT_T LOG_LEVEL;
#define TY_LOG_LEVEL_ERR 0 // Error condition, displayed when the program does not work correctly.
#define TY_LOG_LEVEL_WARN 1 // Warning message.
#define TY_LOG_LEVEL_NOTICE 2 // Normal but significant condition.
#define TY_LOG_LEVEL_INFO 3 // Informational message.
#define TY_LOG_LEVEL_DEBUG 4 // Message for debugging purposes, which will be deleted in release.
#define TY_LOG_LEVEL_TRACE 5 // Reports events showing step by step execution of your code, which will be deleted in release.
The performance of some functions in the SDK is monitored so you can get complete insights into the health of your SDK during debugging. We use the BK7231N chip as an example to illustrate the typical log types.
When the chip is powered on, the log printed on the initial run includes information about the start of the bootloader
and SDK. This helps you check whether the SDK is started correctly.
/*******. Boot information ************/
:BK7231N_1.0.1
REG:cpsr spsr r13 r14
SVC:000000D3 00401C1C 000033AC
IRQ:000000d2 00000010 00401e0c 9519b7d5
FIR:000000d1 00000010 00401ffc 03f42817
SYS:000000df 0040192c 00000158
ST:00000000
J 0x10000
bk_misc_init_start_type 0 0
prvHeapInit-start addr:0x411800, size:124928
[Flash]id:0x1c7015
sctrl_sta_ps_init
cset:0 0 0 0
[
/******** Start the SDK and functions ********/
[2021-06-21 17:04:09.461]# RECV ASCII>
01-01 18:12:15 TUYA Info][lr:0xa33d1] mqc app init ...
[01-01 18:12:15 TUYA Info][lr:0xac517] thread_create name:sys_timer,stackDepth:4096,totalstackDepth:4096,priority:5
[01-01 18:12:15 TUYA Info][lr:0xac517] thread_create name:cmmod,stackDepth:4096,totalstackDepth:8192,priority:4
[01-01 18:12:15 TUYA Debug][lr:0xa337f] mq_pro:5 cnt:1
[01-01 18:12:15 TUYA Debug][lr:0xa337f] mq_pro:31 cnt:2
[01-01 18:12:15 TUYA Debug][lr:0xac3a3] Thread:sys_timer Exec Start. Set to Running Stat
[01-01 18:12:15 TUYA De
.......
The log printed in the pre-initialization step allows you to check the information about device running status, log level setting, SDK version and initialization, production test, and hardware initialization.
/******** Successful log printing initialization ********/
[2021-06-21 17:04:09.470]# RECV ASCII>
bug][lr:0x9d0cd] read m:0 f:0 l:0
[01-01 18:12:15 TUYA Debug][lr:0xabe87] svc online log init success
[01-01 18:12:15 TUYA Info][lr:0xac517] thread_create name:wk_th-0,stackDepth:5120,totalstackDepth:13312,priority:3
[01-01 18:12:15 TUYA Err][lr:0xc2e7d] kvs_read fails gw_bi -1
[01-01 18:12:15 TUYA Debug][lr:0x95bef] gw base read finish:-18
[01-01 18:12:15 TUYA Debug][lr:0xa05c9] ty bt cmmod regist ok:1
[01-01 18:12:15 TUYA Debug][lr:0xa08c5] upd adv para, send conn_req beacon.
[PLATFORM DEBUG]!!!!!!
/******** Successful SDK initialization and SDK information printed ********/
[2021-06-21 17:04:09.486]# RECV ASCII>
!!!!tuya_os_adapt_bt_port_init
[01-01 18:12:15ble mac:50-8a-06-57-3b- -57-3b-60
[01-01 18:16ice][lr:0xa06b3] ty bt2:15 TUYA Notice][lr:0x sdk init finish
xvr_ra06b3] ty bt sdk init feg_init
h4tl_init-1 okinish
[01-01 18:12:15 T
TUYA Debug][lr:0x583aUYA Debug][lr:0x583a7] 7] < TUYA IOT SDK V:2.3< TUYA IOT SDK V:2.3.1 .1 BS:40.00_PT:2.2_LAN:BS:40.00_PT:2.2_LAN:3.33.3_CAD:1.0.3_CD:1.0.0 _CAD:1.0.3_CD:1.0.0 >
>
< BUILD AT:2021_04_2< BUILD AT:2021_04_22_212_21_52_24 BY embed FOR_52_24 BY embed FOR ty_ ty
/******** Successful production test initialization and SDK information printed ********/
[2021-06-21 17:04:09.957]# RECV ASCII>
01-01 18:12:15 TUYA Notice][lr:0x9ae93] have actived over 15 min, not enter mf_init // The device has been activated for more than 15 minutes and will not enter production test mode again.
[01-01 18:12:15 TUYA Notice][lr:0x57e79] mf_init succ
[01-01 18:12:15 TUYA Debug][lr:0x58605] led init is sucess!!!!!!!!!!!!!!!!
[01-01 18:12:15 TUYA Info][lr:0xac517] thread_create name:key_handle,stackDepth:2048,totalstackDepth:15360,priority:5
[01-01 18:12:15 TUYA Debug][lr:0x586eb] relay init sucess!!!!!!!!!!!!!!!!
[01-01 18:12:15 TUYA Debug][lr:0x58605] led init is sucess!!!!!!!!!!!!!!!!
/******** Successful hardware initialization ********/
[2021-06-21 17:04:09.990]# RECV ASCII>
at:0
[01-01 18:12:15 TUYA Debug][lr:0x58caf] power_on relay_power_stat:0,init relay_stat:0
[01-01 18:12:15 TUYA Notice][lr:0x58d71] tuya_hard_init is success
[01-01 18:12:15 TUYA Debug][lr:0x57e87] gwcm_mode 1
[01-01 18:12:15 TUYA Debug][lr:0x57e93] low_power select
[01-01 18:12:15 TUYA Debug][lr:0xac3a3] Thread:key_handle Exec Start. Set to Running Stat
[01-01 18:12:15 TUYA Notice][lr:0x57ea1] have actived over 15min, don't scan prod test ssid
[01-01 18:12:15 TUYA Debug][lr:0x57f57] no tuya_mdev_tes
The log printed on the initialization of device applications includes information about the initialization process and device information.
/******** Successful device initialization ********/
[2021-06-21 17:04:10.005]# RECV ASCII>
t1!
[01-01 18:12:15 TUYA Debug][lr:0x57f5d] device_init in
[01-01 18:12:15 TUYA Debug][lr:0xa85fb] tuya svc upgrade init success!
[PLATFORM NOTICE]bk_rst:0 tuya_rst:0
[01-01 18:12:15 TUYA Notice][lr:0x99d97] Last reset reason: 0
[01-01 18:12:15 TUYA Debug][lr:0xaf4a3] init watchdog, interval: 60
[01-01 18:12:15 TUYA Debug][lr:0xaf4e1] watch_dog_interval:60, monitor_detect_interval:600
[01-01 18:12:15 TUYA Info][lr:0xac517] thread_create name:health_monitor,stackDepth:1536,totalstackDepth:16896,priori
/******** Device information read successfully and the product ID (PID) printed ********/
[2021-06-21 17:04:10.052]# RECV ASCII>
UYA Notice][lr:0x9a1bb] gw_cntl.gw_if.abi:0 input:0
[01-01 18:12:15 TUYA Notice][lr:0x9a1c7] gw_cntl.gw_if.product_key:sohpsfzztabmjeqo, input:sohpsfzztabmjeqo
[01-01 18:12:15 TUYA Notice][lr:0x9a1d3] gw_cntl.gw_if.tp:0, input:0
[01-01 18:12:15 TUYA Debug][lr:0x969b5] gw_ai read success
[01-01 18:12:15 TUYA Debug][lr:0xade55] set_dns_region:6
[01-01 18:12:15 TUYA Debug][lr:0xada8b] cache dns [http://a.tuyacn.com/d.json]<->[122.51.123.217]
The log status information is added to the callback for peripheral operations. This helps you to check whether peripherals work properly.
/******** Peripheral operations ********/
[2021-06-21 17:04:16.634]# RECV ASCII>
[01-01 18:12:22 TUYA Notice][lr:0xaf7bb] get key interrupt
[01-01 18:12:22 TUYA Debug][lr:0xa2f39] can not enable, lowpower disabled
The log provides information about network status. You can check the current network connection as well as the reason for a network failure.
/******** Device runs in low power mode ********/
[2021-06-21 17:04:11.067]# RECV ASCII>
[01-01 18:12:16 TUYA Debug][lr:0xb0771] wifi netstat changed to:0 -->> // The device runs in low power mode.
[01-01 18:12:16 TUYA Notice][lr:0x5836d] cur_wifi_stat:0
[01-01 18:12:16 TUYA Debug][lr:0x58747] led_time:0,led_io:2!
[01-01 18:12:16 TUYA Debug][lr:0x5876f] led on off!
[01-01 18:12:16 TUYA Debug][lr:0xaf153] pinname:9
[01-01 18:12:16 TUYA Debug][lr:0x5879d] led off!
[01-01 18:12:16 TUYA Debug][lr:0xb0789] wifi netstat changed to:0 <<--
/******** Device enters Wi-Fi Easy Connect mode (EZ mode) ********/
[2021-06-21 17:04:24.332]# RECV ASCII>
to:1 -->>
[01-01 18:12:18 TUYA Notice][lr:0x5836d] cur_wifi_stat:1 // The device enters Wi-Fi Easy Connect mode (EZ mode).
[01-01 18:12:18 TUYA Debug][lr:0x58747] led_time:250,led_io:2!
[01-01 18:12:18 TUYA Debug][lr:0xaf153] pinname:9
[01-01 18:12:18 TUYA Debug][lr:0x5879d] led flash!!
[01-01 18:12:18 TUYA Debug][lr:0xb0789] wifi netstat changed to:1 <<--
[01-01 18:12:18 TUYA Debug][lr:0xb84e7] smart cfg start type:65537
[01-01 18:12:18 TUYA Debug][lr:0xb713b] ----netcfgType:0x10001
[01-01 18:12:18 TUYA Debug][lr:0xb7907] ----register netcfgType:0x100
/******** Device is connected to the router ********/
[2021-06-21 17:04:39.358]# RECV ASCII>
[01-01 18:12:34 TUYA Debug][lr:0xb0771] wifi netstat changed to:5 -->> // The device is connected to the router.
[01-01 18:12:34 TUYA Notice][lr:0x5836d] cur_wifi_stat:5
[01-01 18:12:34 TUYA Debug][lr:0x58747] led_time:0,led_io:2!
[01-01 18:12:34 TUYA Debug][lr:0x5876f] led on off!
[01-01 18:12:34 TUYA Debug][lr:0xaf153] pinname:9
[01-01 18:12:34 TUYA Debug][lr:0x5879d] led off!
[01-01 18:12:34 TUYA Debug][lr:0xb0789] wifi netstat changed to:5 <<--
found scan rst rssi -65 < -50
dis ht_support
/******** Device is connected to the cloud ********/
[2021-06-21 17:04:40.363]# RECV ASCII>
01-01 18:12:34 TUYA Debug][lr:0xb45f3] Connect: h3.iot-dns.com Port: 443 --<< ,r:0
[01-01 18:12:34 TUYA Debug][lr:0xa4715] ----enable_cert:0,DEFAULT_LOAD_CERT:0
[01-01 18:12:34 TUYA Debug][lr:0xa47b1] TUYA_TLS Begin Connect h3.iot-dns.com:443 CustomNet:TRUE Enable_Cert:FALSE Default:FALSE
[01-01 18:12:35 TUYA Debug][lr:0xa4859] socket fd is set. set to inner send/recv to handshake
[01-01 18:12:35 TUYA Debug][lr:0xb0771] wifi netstat changed to:6 -->> // The device is connected to the cloud.
[01-01 18:12:35 TUYA Notice][lr:0x5836d] cur_wif
/******** Successful MQTT connection ********/
[2021-06-21 17:04:44.421]# RECV ASCII>
[06-21 17:04:42 TUYA Debug][lr:0xaaf03] mqtt subscribe success
[06-21 17:04:42 TUYA Debug][lr:0xa3171] mqtt connect success
/******** Device is registered with the cloud ********/
[2021-06-21 17:04:44.580]# RECV ASCII>
[06-21 17:04:42 TUYA Debug][lr:0xb0771] wifi netstat changed to:7 -->> // The device is registered with the cloud.
[06-21 17:04:42 TUYA Notice][lr:0x5836d] cur_wifi_stat:7
[06-21 17:04:42 TUYA Debug][lr:0x58747] led_time:1,led_io:2!
[06-21 17:04:42 TUYA Debug][lr:0x5876f] led on off!
[06-21 17:04:42 TUYA Debug][lr:0xaf153] pinname:9
[06-21 17:04:42 TUYA Debug][lr:0x5879d] led on!
[06-21 17:04:42 TUYA Notice][lr:0xa0f15] ble get conn stat:3
[06-21 17:04:42 TUYA Notice][lr:0xa0f93] ble_sdk_send. cmd:0x8001 encrpyt:5
[06-21 17:04:42 TUYA Notice
If the data reported by the device does not match the one on the app or the cloud, check the log to see whether the device reports the correct data. If the device has no issues, troubleshoot the app or cloud.
/******** Successful data reporting ********/
[2021-06-21 17:05:02.840]# RECV ASCII>":{"1":false}}
[06-21 17:05:02 TUYA Debug][lr:0x588df] upload all dp data sucess
[06-21 17:05:02 TUYA Debug][lr:0xb0fa5] g_lan_ctrl_enable:1
[06-21 17:05:02 TUYA Debug][lr:0xb17e9] Prepare To Send Lan:{"dps":{"1":false}}, msg_len:19, out_len:63
[06-21 17:05:02 TUYA Debug][lr:0xbad3d] msg_data:{"dps":{"1":false}}, mqtt async dp cb:0
[06-21 17:05:02 TUYA Debug][lr:0xba4f3] set short dp rate rule, dpID:1, curr_t:1624266302, rept_cnt:4.
[06-21 17:05:02 TUYA Debug][lr:0xba509] set long dp rate rule, dpID:1
If the device fails to execute an action as expected, check the log to see whether the device receives the correct command. If the device has no issues, troubleshoot the app or cloud.
/******** Successful data receiving ********/
[2021-06-21 17:05:01.253]# RECV ASCII>
[06-21 17:05:00 TUYA Debug][lr:0xbad3d] msg_data:{"dps":{"1":false}}, mqtt async dp cb:0
[06-21 17:05:00 TUYA Debug][lr:0xba4f3] set short dp rate rule, dpID:1, curr_t:1624266300, rept_cnt:2.
[06-21 17:05:00 TUYA Debug][lr:0xba509] set long dp rate rule, dpID:1, curr_t:1624266300, rept_cnt:0.
[06-21 17:05:00 TUYA Debug][lr:0xba521] set all dp rate rule, dpID:1, curr_t:1624266300, rept_cnt:0.
Error code | Reason | Troubleshoot | Reference |
---|---|---|---|
-4378 | Failed to activate and pair the device. | The PID is not associated with firmware. Go to the Tuya Developer Platform and the step of Hardware Development to add custom firmware. | Add custom firmware |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback