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.

ZDP_DeviceAnnce job or no?

Other Parts Discussed in Thread: Z-STACK

Hello everyone.  I have a problem with using the next function:

afStatus_t ZDP_DeviceAnnce( uint16 nwkAddr, byte *IEEEAddr, byte capabilities, byte SecurityEnable );

 ZDP_DeviceAnnce(ADDR,(void *)IEA,ZDO_Config_Node_Descriptor.CapabilityFlags, 0 );

Somewhere in my code :

.................

case ZDO_STATE_CHANGE:
NWK_STATE = (devStates_t)(MSGpkt->hdr.status);


if ( (NWK_STATE == DEV_ZB_COORD) ||
(NWK_STATE == DEV_ROUTER) ||
(NWK_STATE == DEV_END_DEVICE) )
{

// at this point the device has successfully connected to the network. THIS TRUE

uint8 IEA [8];
uint16 ADDR;

ZMacGetReq( ZMacExtAddr, IEA ); // JOB Function (checked by UART)
ZMacGetReq (ZMacShortAddress,(void *)ADDR); // JOB Function (checked by UART)
/*
ZDP_DeviceAnnce(ADDR,(void *)IEA,ZDO_Config_Node_Descriptor.CapabilityFlags, 0 ); // NO JOB (a sniffer I do not see the command Device Annce)

ZDP_DeviceAnnce( NLME_GetShortAddr(), NLME_GetExtAddr(),ZDO_Config_Node_Descriptor.CapabilityFlags, 0 );   // NO JOB (a sniffer I do not see the command Device Annce)  same as above

*/

............

briefly about my project:

1) I write firmware for end device, using example - zcl_samplesw.c

2) I want to when successfully connected to my network device to send the command Device Annce

Take a look at my code, taking into account the fact that everything works, except this -> ZDP_DeviceAnnce

I can not understand why this function is not fulfilling its obligations?

  • End device announcement is sent by Z-Stack by default when an end device joins Zigbee network. You don't have to add these code for this purpose.
  • The thing is that it does not automatically sent. I can not understand what is the reason. Sniffer shows:
    Device - beacon request
    Coordinator - beacon
    Device - beacon request
    Coordinator - beacon
    Device - Association reuest
    Coordinator - Ack
    Device - Data Request
    Coordinator - Ack
    Coordinator - Association Response (SUCCESSFUL)
    Device - Data Request
    Coordinator - Ack
    Coordinator - Transport Key
    Device - Ack
    AND ALL
    Device Annce - NONE
    In what could be the possible reason for this ?
  • Which Z-Stack version do you use? By the way, can you attach sniffer log so I can help to check?

  • Z-Stack HA 1.2.0. At the moment I do not have access to a sniffer (from work I got home). There's nothing more to check, I compared the packages with other devices, all the same. Maybe it safe?
  • I always see end node announcement when I test examples in z-stack home 1.2.0. If you use original samplesw example, do you still can not see end node announcement?
  • I have a whole to lie with these examples. How many of them are not tried, even to the network device is not plugged in (HOLD_AUTO_START deleted). I looked in the sniffer and did not see any packets at all. I solved the problem by writing manually configured and running after registration last end point function ZDO_Init_Device (zcl_samplesw.c):

    // Register for a test endpoint
    afRegister( &sampleSw_TestEp );

    ZDO_RegisterForZDOMsg( SW_TaskID, End_Device_Bind_rsp );
    ZDO_RegisterForZDOMsg( SW_TaskID, Match_Desc_rsp );

    //zgWriteStartupOptions(ZG_STARTUP_SET, ZCD_STARTOPT_DEFAULT_NETWORK_STATE); - it is no used

    ZDOInitDevice(0); THIS !

    and configurations :

    void configuration_my (void) {

    uint8 end_dev [] = {0x02};
    uint8 pan_id [] = {0xFF,0xFF};
    uint8 chan_list [] = {0x00,0xF8,0xFF,0x07};
    /*uint8 key_pre [] = {0x39,0x30,0x65,0x63,0x6E,0x61,0x69,0x6C,0x6C,0x41,0x65,0x65,0x42,0x67,0x69,0x5A};
    uint8 key_enable[] = {0x00};
    uint8 security_mode[] = {0x01};
    uint8 tclk_mode[] = {0x01};*/

    zb_WriteConfiguration (0x87,1,end_dev);
    zb_WriteConfiguration (0x83,2,pan_id);
    zb_WriteConfiguration (0x84,4,chan_list);
    /* zb_WriteConfiguration (0x62,16,key_pre);
    zb_WriteConfiguration (0x63,1,key_enable);
    zb_WriteConfiguration (0x64,1,security_mode);
    zb_WriteConfiguration (0x6D,1,tclk_mode);*/

    }

    called here (OSAL_SampleSw.c) :
    void osalInitTasks( void )
    {
    uint8 taskID = 0;

    tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
    osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));
    configuration_my (); // THIS !
    macTaskInit( taskID++ );
    nwk_init( taskID++ );

    After these procedures, the device has successfully connected to the network but is not sent at the end of the Device Annce...

    Based on what you have said that you are all working, I'm starting to think that I do not have a working stack. Maybe it makes sense to download the other? Can send preprocessor options that you used to, I conducted an experiment, and finally convinced that my stack is not working?
  • Maybe you can try to use the following steps and try again.
    1. Open SampleLight (as ZC) and SampleSwitch (as ZED). Disable NV_RESTORE and HOLD_AUTO_START in compile opton.
    2. Build SampleLight, SampleSwitch and download it to EVBs.
    3. Power on SampleLight as ZC to form Zigbee network and press SW2 to start EZ-mode.
    4. Power on SampleSwitch as ZED and press SW2 to start EZ-mode.
    5. You should see SampleSwitch joins SampleLight's network and see end node announcement in Sniffer.
  • Binding device to the coordinator through a EZ-Mode or Binding is a prerequisite? As far as I know - no.   Bind - the upper level and the announcement does not affect.

    I think this function (NLME_PermitJoiningRequest (0xFF -always on) ) could be a key moment, although I'm not sure I will check

  • I don't get your point. What is your question or doubt?
  • Why do bind to the coordinator if it is possible only after a successful connection to the network device ?

    code responsible for buttons:


    static void zclSampleSw_HandleKeys( byte shift, byte keys )
    {
    // toggle remote light
    if ( keys & HAL_KEY_SW_1 )
    {
    giSwScreenMode = SW_MAINMODE; // remove help screen if there

    // Using this as the "Light Switch"
    #ifdef ZCL_ON_OFF
    zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, FALSE, 0 );
    #endif
    #ifdef LCD_SUPPORTED
    HalLcdWriteString( (char *)sCmdSent, HAL_LCD_LINE_2 );

    // clear message on screen after 3 seconds
    osal_start_timerEx( zclSampleSw_TaskID, SAMPLESW_MAIN_SCREEN_EVT, 3000 );
    #endif
    }

    // invoke EZ-Mode
    if ( keys & HAL_KEY_SW_2 ) // you recommend it
    {
    giSwScreenMode = SW_MAINMODE; // remove help screen if there

    #ifdef ZCL_EZMODE
    {
    zclEZMode_InvokeData_t ezModeData;
    static uint16 clusterIDs[] = { ZCL_CLUSTER_ID_GEN_ON_OFF }; // only bind on the on/off cluster

    // Invoke EZ-Mode
    ezModeData.endpoint = SAMPLESW_ENDPOINT; // endpoint on which to invoke EZ-Mode
    if ( (zclSampleSw_NwkState == DEV_ZB_COORD) ||
    (zclSampleSw_NwkState == DEV_ROUTER) ||
    (zclSampleSw_NwkState == DEV_END_DEVICE) )
    {
    ezModeData.onNetwork = TRUE; // node is already on the network
    }
    else
    {
    ezModeData.onNetwork = FALSE; // node is not yet on the network
    }
    ezModeData.initiator = TRUE; // OnOffSwitch is an initiator
    ezModeData.numActiveOutClusters = 1; // active output cluster
    ezModeData.pActiveOutClusterIDs = clusterIDs;
    ezModeData.numActiveInClusters = 0; // no active input clusters
    ezModeData.pActiveInClusterIDs = NULL;
    zcl_InvokeEZMode( &ezModeData ); // EZ-Mode  connection  - WHY ?

    #ifdef LCD_SUPPORTED
    HalLcdWriteString( "EZMode", HAL_LCD_LINE_2 );
    #endif
    }

    #else // NOT ZCL_EZMODE
    // bind to remote light
    zAddrType_t dstAddr;
    HalLedSet ( HAL_LED_4, HAL_LED_MODE_OFF );

    // Initiate an End Device Bind Request, this bind request will
    // only use a cluster list that is important to binding.
    dstAddr.addrMode = afAddr16Bit;
    dstAddr.addr.shortAddr = 0; // Coordinator makes the match
    ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(),
    SAMPLESW_ENDPOINT,
    ZCL_HA_PROFILE_ID,
    0, NULL, // No incoming clusters to bind
    ZCLSAMPLESW_BINDINGLIST, bindingOutClusters,
    TRUE ); // END DEVICE BIND - WHY ?
    #endif // ZCL_EZMODE
    }

    // toggle permit join
    if ( keys & HAL_KEY_SW_4 )
    {
    giSwScreenMode = SW_MAINMODE; // remove help screen if there

    if ( ( zclSampleSw_NwkState == DEV_ZB_COORD ) ||
    ( zclSampleSw_NwkState == DEV_ROUTER ) )
    {
    // toggle permit join
    gPermitDuration = gPermitDuration ? 0 : 0xff;
    NLME_PermitJoiningRequest( gPermitDuration ); // Maybe it makes sense to use it?
    }
    }

    if ( shift && ( keys & HAL_KEY_SW_5 ) )
    {
    zclSampleSw_BasicResetCB();
    }
    else if ( keys & HAL_KEY_SW_5 )
    {
    giSwScreenMode = giSwScreenMode ? SW_MAINMODE : SW_HELPMODE;
    #ifdef LCD_SUPPORTED
    HalLcdWriteString( (char *)sClearLine, HAL_LCD_LINE_2 );
    #endif
    }

    // update the display
    zclSampleSw_LcdDisplayUpdate();
    }

    I'm trying to say is that the bindings are possible only when the device is already connected to the network. And I can not get an automatic successful connection to the network. The device does not send any packets to the network. I tried everything you said  (delete options HOLD and NV)and nothing happens ....

  • I solved the problem.

    0) Delete the compile options:

    xNV_RESTORE
    HOLD_AUTO_START

    1) In file f8wConfig.cfg I do next:

    /* Default security key. */
    -DDEFAULT_KEY="{0x5a, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41, 0x6c, 0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x30, 0x39}"

    2) in projekt I include :

    sapi.h

    sapi.c

    3) In file sapi.c I delete next (because it causes a conflict):

    #if OSAL_SAPI
    // The order in this table must be identical to the task initialization calls below in osalInitTask.
    const pTaskEventHandlerFn tasksArr[] = {
    macEventLoop,
    nwk_event_loop,
    Hal_ProcessEvent,
    #if defined( MT_TASK )
    MT_ProcessEvent,
    #endif
    APS_event_loop,
    ZDApp_event_loop,

    SAPI_ProcessEvent
    };

    const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
    uint16 *tasksEvents;
    #endif

    #if OSAL_SAPI
    /*********************************************************************
    * @fn osalInitTasks
    *
    * @brief This function invokes the initialization function for each task.
    *
    * @param void
    *
    * @return none
    */
    void osalInitTasks( void )
    {
    uint8 taskID = 0;

    tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
    osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));

    macTaskInit( taskID++ );
    nwk_init( taskID++ );
    Hal_Init( taskID++ );
    #if defined( MT_TASK )
    MT_TaskInit( taskID++ );
    #endif
    APS_Init( taskID++ );
    ZDApp_Init( taskID++ );
    SAPI_Init( taskID );
    }
    #endif

    4) In file OSAL_SampleSw.c I do next:

    #include "sapi.h"

    void osalInitTasks( void )
    {
    uint8 taskID = 0;

    tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
    osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));

    uint8 end_dev [] = {0x02};
    uint8 pan_id [] = {0xFF,0xFF};
    uint8 chan_list [] = {0x00,0xF8,0xFF,0x07};
    uint8 key_pre [] = {0x39,0x30,0x65,0x63,0x6E,0x61,0x69,0x6C,0x6C,0x41,0x65,0x65,0x42,0x67,0x69,0x5A};
    uint8 key_enable[] = {0x00};
    uint8 security_mode[] = {0x01};
    uint8 tclk_mode[] = {0x01};

    zb_WriteConfiguration (0x87,1,end_dev);
    zb_WriteConfiguration (0x83,2,pan_id);
    zb_WriteConfiguration (0x84,4,chan_list);
    zb_WriteConfiguration (0x62,16,key_pre);
    zb_WriteConfiguration (0x63,1,key_enable);
    zb_WriteConfiguration (0x64,1,security_mode);
    zb_WriteConfiguration (0x6D,1,tclk_mode);

    macTaskInit( taskID++ );

    5) In file zcl_samplesw.c I do next:

    void zclSampleSw_Init( byte task_id )
    {
    zclSampleSw_TaskID = task_id;

    #ifdef ZCL_ON_OFF
    // Set destination address to indirect
    zclSampleSw_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
    zclSampleSw_DstAddr.endPoint = 0;
    zclSampleSw_DstAddr.addr.shortAddr = 0;
    #endif

    // This app is part of the Home Automation Profile
    zclHA_Init( &zclSampleSw_SimpleDesc );

    // Register the ZCL General Cluster Library callback functions
    zclGeneral_RegisterCmdCallbacks( SAMPLESW_ENDPOINT, &zclSampleSw_CmdCallbacks );

    // Register the application's attribute list
    zcl_registerAttrList( SAMPLESW_ENDPOINT, SAMPLESW_MAX_ATTRIBUTES, zclSampleSw_Attrs );

    // Register the Application to receive the unprocessed Foundation command/response messages
    zcl_registerForMsg( zclSampleSw_TaskID );

    #ifdef ZCL_EZMODE
    // Register EZ-Mode
    zcl_RegisterEZMode( &zclSampleSw_RegisterEZModeData );

    // Register with the ZDO to receive Match Descriptor Responses
    ZDO_RegisterForZDOMsg(task_id, Match_Desc_rsp);
    #endif

    // Register for all key events - This app will handle all key events
    RegisterForKeys( zclSampleSw_TaskID );

    // Register for a test endpoint
    afRegister( &sampleSw_TestEp );

    ZDO_RegisterForZDOMsg( zclSampleSw_TaskID, End_Device_Bind_rsp );
    ZDO_RegisterForZDOMsg( zclSampleSw_TaskID, Match_Desc_rsp );

    #ifdef LCD_SUPPORTED
    HalLcdWriteString ( (char *)sDeviceName, HAL_LCD_LINE_3 );
    #endif
    ZDOInitDevice(0); include this!

    }

    All JOB !!! The device successfully connects to the network and sends the "Device Annce"