【已解决】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

Wi-Fi 设备、Wi-Fi 低功耗设备、Wi-Fi BLE 双模设备、Ethernet设备、Ethernet+Wi-Fi设备等
Jaoki
Posts: 51

目前SDK 使用的是TuyaOS-3.8.1。 调用的重置网络的接口为:tuya_iot_wf_gw_fast_unactive(GWCM_SPCL_MODE, WF_START_SMART_FIRST); 和 tuya_iot_wf_gw_unactive(); 都尝试过,设备在重启后进入不了配网。看log显示在重启的时候有二次重启。在Log文件中的第500 到 560行之间。麻烦帮忙看看这是什么问题呢

Attachments
bk7231n_重置进入不了配网问题.TXT
(46.21 KiB) Downloaded 103 times
Last edited by Jaoki on 2023年 Nov 15日 19:18, edited 1 time in total.
愚者千虑必有一得
Posts: 426

Re: 【求助】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

需要提供更完整的log,特别是附带调用tuya_iot_wf_gw_fast_unactive之后的完整的log。

Jaoki
Posts: 51

Re: 【求助】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

附件中的Log文件:第506行开始就是调用函数接口:tuya_iot_wf_gw_fast_unactive(GWCM_SPCL_MODE, WF_START_SMART_FIRST); 之后的Log呀。

一线长天
Posts: 52

Re: 【求助】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

日志里没有看到:gw reset called
至少在tuya_iot_wf_gw_fast_unactive(GWCM_SPCL_MODE, WF_START_SMART_FIRST);调用时肯定会同步输出上述日志的。
能否把这个接口的返回值打印出来?

Jaoki
Posts: 51

Re: 【求助】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

源码如下:

Code: Select all

{
    OPERATE_RET opRet = -1;
    UCHAR_T ucConnectMode = 0;

ucConnectMode = ucLightCtrlGetConnectMode();
PR_NOTICE("---> ucConnectMode = %d\n\n\n", ucConnectMode);
PR_NOTICE("---> before Reset opRet = %d\n", opRet);
opRet = tuya_iot_wf_gw_fast_unactive(ucConnectMode, WF_START_SMART_FIRST);
// opRet = tuya_iot_wf_gw_unactive();

PR_NOTICE("---> Reset status = %d\n", opRet);

return opRet;
}

看模块的Log,PR_NOTICE("---> Reset status = %d\n", opRet); 这个没有输出出来
[01-01 00:00:01 ty D][lr:0xcb175] protected read ret:0 length:140
[01-01 00:00:01 ty D][lr:0x73891] CCT delay 200ms reset factory!
[01-01 00:00:01 ty N][lr:0x70bb5] ---> ucConnectMode = 2

[01-01 00:00:01 ty N][lr:0x70bbf] ---> before Reset opRet = -1

get rssi error
[01-01 00:00:01 ty D][lr:0x8b7d9] gw_wsm read ret:0
[01-01 00:00:01 ty N][lr:0xc86c3] start wifi link params validate, nc_tp:0 md:0
get rssi error
[01-01 00:00:01 ty N][lr:0xc871f] gw_wsm.nc_tp:0
[01-01 00:00:01 ty N][lr:0xc8727] gw_wsm.md:0
[01-01 00:00:01 ty D][lr:0xbf28d] bt init...
get rssi error
[01-01 00:00:01 ty D][lr:0x906db] get_wifi_list eanbled
[01-01 00:00:01 ty D][lr:0x906eb] get_netcfg_stat eanbled
get rssi error
[01-01 00:00:01 ty D][lr:0x906fb] get_dev_log eanbled
[01-01 00:00:01 ty D][lr:0x9070b] get_ap_name eanbled
get rssi error
[01-01 00:00:01 ty D][lr:0xcb0ef] protected read [gw_wsm]
[01-01 00:00:01 ty E][lr:0xc8041] get rssi err:-1
[01-01 00:00:01 ty D][lr:0x896df] [4][34]:{"ts":1,"dt":4,"tp":3,"s":0,"r":0}
[01-01 00:00:01 ty D][lr:0xcb175] protected read ret:0 length:140
[01-01 00:00:01 ty D][lr:0x8956f] read tuya dev data's offset len:16 ok
[01-01 00:00:01 ty D][lr:0x89745] read file ok at offset:1024
[01-01 00:00:01 ty D][lr:0x894c9] read tuya dev data's index len:16 ok
[01-01 00:00:01 ty D][lr:0x8975f] available slot index:9, part index: 1, part offset:1024
[01-01 00:00:01 ty D][lr:0x893c5] before file_size:3072, after file_size:3072
[01-01 00:00:?
V:BK7231N_1.0.1
REG:cpsr spsr r13 r14
SVC:4000001F 0042DB10 000AFCA9
IRQ:400000d2 6000003f 003fc240 0001972e
FIR:400000d1 00000010 003fb250 3fd93d76
SYS:400000df 0042db10 000afca9
ST:00000000
J 0x10000
bk_misc_init_start_type a 0
xat0_reboot

一线长天
Posts: 52

Re: 【求助】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

从日志里看,在SDK初始化的过程中调用了reset接口,可能会导致异常。请在sdk初始化完成后再调用。
tuya_iot_wf_gw_fast_unactive这个接口可以在device_init前调用(SDK初始化前)

Jaoki
Posts: 51

Re: 【求助】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

重置的函数接口(tuya_iot_wf_gw_fast_unactive)是在:app_init 这里调用的函数:reset_judge_proc(),判断上电次数,然后开启定时器处理的。

Code: Select all

VOID app_init(VOID)
{    
OPERATE_RET opRet = -1; UINT_T len = 0; UCHAR_T *pConfig = NULL; UCHAR_T ucConnectMode = 0; light_prod_test_data_flash_t tProdResult = {0}; if(TRUE == bFastBootInit) { reset_judge_proc(); /* set pre app init to judge ifnot reset */ } ...... }

,而app_init 是在__soc_device_init 里面调用的

Code: Select all

OPERATE_RET __soc_device_init(VOID_T)
{
    OPERATE_RET rt = OPRT_OK;

#if (defined(UUID) && defined(AUTHKEY))
    ws_db_init_mf();

/* Set authorization information
 * Note that if you use the default authorization information of the code, there may be problems of multiple users and conflicts, 
 * so try to use all the authorizations purchased from the tuya iot platform.
 * Buying guide: https://developer.tuya.com/cn/docs/iot/lisence-management?id=Kb4qlem97idl0.
 * You can also apply for two authorization codes for free in the five-step hardware development stage of the Tuya IoT platform.
 * Authorization information can also be written through the production testing tool.
 * When the production testing function is started and the authorization is burned with the Tuya Cloud module tool, 
 * please comment out this piece of code.
 */
WF_GW_PROD_INFO_S prod_info = {UUID, AUTHKEY};
TUYA_CALL_ERR_RETURN(tuya_iot_set_wf_gw_prod_info(&prod_info));
#else
    // 产测初始化, 注册函数需要应用实现,其中串口驱动不需要应用提供
    MF_IMPORT_INTF_S intf = {0};

intf.uart_init = mf_uart_init_callback;
intf.uart_free = mf_uart_free_callback;
intf.uart_send = mf_uart_send_callback;
intf.uart_recv = mf_uart_recv_callback;

intf.mf_user_product_test = mf_user_product_test_callback;
intf.user_callback = mf_user_callback;
intf.user_enter_mf_callback = mf_user_enter_mf_callback;

TAL_PR_ERR("mf_init APP_BIN_NAME[%s] USER_SW_VER[%s]", APP_BIN_NAME, USER_SW_VER);

TUYA_CALL_ERR_RETURN(mf_init(&intf, APP_BIN_NAME, USER_SW_VER, TRUE));
#endif


// 应用初始化
app_init();

// 功能启动,其中 GWCM_OLD 模式特殊,在任意时刻都可以扫描SSID,进入产测模式。
TAL_PR_DEBUG("gwcm_mode %d", gwcm_mode);//默认没有低功耗模式

if(gwcm_mode != GWCM_OLD) {
    TAL_PR_DEBUG("low_power select");
    // 扫描到产测路由,进入产测模式,不需要进行设备初始化
    if(TRUE == __ty_product_test_init(gwcm_mode)) {
        return;
    }
    // 没有扫描到产测路由,初始化设备
    TAL_PR_DEBUG("no tuya_mdev_test1!");
}

TAL_PR_DEBUG("device_init in");
device_init();

return 0;
}

,在调用接口TUYA_CALL_ERR_RETURN(mf_init(&intf, APP_BIN_NAME, USER_SW_VER, TRUE)); 后,SDK 是不是已经初始化完成了呢? 而且同一套代码, 在有的CBU模块上面就重置不了,有的模块就正常。

Jaoki
Posts: 51

Re: 【求助】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

附件是同一个程序,能够重置成功进入配网的Log。

bk7213n_能够正常重置的Log.TXT
(68.68 KiB) Downloaded 64 times
一线长天
Posts: 52

Re: 【求助】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

从日志看,不会是同一个固件。
有问题的日志,显示SDK已经在初始化了:
[01-01 00:00:01 ty N][lr:0xb43ab] wifi soc init. pid:keytdaq7r9krgen5 firmwarekey:keytdaq7r9krgen5 ver:0.0.6
[01-01 00:00:01 ty D][lr:0xc8683] tuya wifi link init mthd:2,wifi start mode:4, enable_station_ap:0
[01-01 00:00:01 ty D][lr:0xcb0df] protected read [gw_wsm]
[01-01 00:00:01 ty D][lr:0xcb165] protected read ret:0 length:140
[01-01 00:00:01 ty D][lr:0x8b7c9] gw_wsm read ret:0
[01-01 00:00:01 ty N][lr:0xc86b3] start wifi link params validate, nc_tp:0 md:0
[01-01 00:00:01 ty N][lr:0xc870f] gw_wsm.nc_tp:0
[01-01 00:00:01 ty N][lr:0xc8717] gw_wsm.md:0
[01-01 00:00:01 ty D][lr:0xbf27d] bt init...
[01-01 00:00:01 ty D][lr:0x906cb] get_wifi_list eanbled
[01-01 00:00:01 ty D][lr:0x73881] CCT delay 200ms reset factory!
[01-01 00:00:01 ty N][lr:0x70bb5] ---> ucConnectMode = 2
而正常的重置固件,日志是。sdk并没有初始化:
[01-01 00:00:01 ty D][lr:0x7388d] CCT delay 200ms reset factory!
[01-01 00:00:01 ty N][lr:0x70bb5] ---> ucConnectMode = 2

[01-01 00:00:01 ty N][lr:0x70bbf] ---> before Reset opRet = -1

[01-01 00:00:01 ty D][lr:0xcb0eb] protected read [gw_wsm]
[01-01 00:00:01 ty D][lr:0xcb171] protected read ret:0 length:140
[01-01 00:00:01 ty D][lr:0x8b7d5] gw_wsm read ret:0
[01-01 00:00:01 ty D][lr:0xcb0eb] protected read [gw_wsm]
RSSI: dc:fe:18:bf:6b:9c -66 -> -65
[01-01 00:00:01 ty D][lr:0xcb171] protected read ret:0 length:140
[01-01 00:00:01 ty D][lr:0x8b7d5] gw_wsm read ret:0
[01-01 00:00:01 ty D][lr:0xaf82b] <__wf_reset> nc_tp:1, rst_tp:2, wifi_start_mode:3,mthd:0,md:0

Jaoki
Posts: 51

Re: 【求助】关于TuyaOS-3.8.1SDK开发的设备重置进入配网失败的问题

你好, 我现在两个模块烧录的是同一个固件,那为什么会出现这种情况呢

Post Reply