This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HOLD_AUTO_START 每次上电必须触发一下吗?

HOLD_AUTO_START 是个编译选项,目前是每次上电必须设置个事件触发一下,模块才会工作,比较麻烦。我想问一下能不能设置为模块第一次上电是HOLD_AUTO_START  ,在第二三次是自启动呢?

  • HOLD_AUTO_START即阻止网络的自启动,所以您只要编译了该选项就会一直阻止自启动

  • 我有个想法是出厂的设备第一次是非自动,外部事件触发后设备启动方式就变为自动启动了,我该怎么实现?

  • 你可以在节点入网,写一参数到NV里面,自己定义一个NV的item。

    在重新启动以后,可以去这个NV里面都数据,如果是已经加过网的,那么就自动启动了。

    在下面的函数

    void ZDApp_Init( uint8 task_id )

    / Start the device?
    if ( devState != DEV_HOLD )
    {
    ZDOInitDevice( 0 );
    }
    else
    {
    ZDOInitDevice( ZDO_INIT_HOLD_NWK_START );
    // Blink LED to indicate HOLD_START
    HalLedBlink ( HAL_LED_4, 0, 50, 500 );
    }

    在上面的代码的前面加上

    uint8 *restoreInitState = osal_mem_alloc(1);
    osal_nv_read(NV_STORE_ZDO_INIT, 0, 1, restoreInitState);
    if(*restoreInitState == TRUE)
    {
    devState = DEV_INIT;
    }

    osal_mem_free(restoreInitState);


    NV_STORE_ZDO_INIT你可以自己去定义,在入网以后写进去就可以了。