协调器网络的建立

一、协调器网络的建立
     1、  网络的格式化
          A:初始化的能量阀值为16。通过设置ZDApp_event_loop任务中的事件ID为ZDO_NETWORK_INIT以便执行B。
          B:调用NLME_NetworkFormationRequest函数进行申请,对申请的回应在程序中没对应的回调处理,猜想回调处理在lib库中处理。在程序找到了两个对申请结果作处理的函数,void ZDO_NetworkFormationConfirmCB( ZStatus_t Status )和void nwk_Status( uint16 statusCode,uint16 statusValue );在两个函数中都有申请的结果。如果不成功则nwk_Status先执行如果成功则ZDO_NetworkFormationConfirmCB先执行。
          C:系统(lib)调用ZDO_NetworkFormationConfirmCB函数,在函数中通过设置ZDApp_event_loop任务中的事件ID为ZDO_NETWORK_START以便执行D。
          D:调用ZDApp_NetworkStartEvt函数,在函数中检测返回的申请结果,如果不成功则能量阀值增加16并将ZDApp_event_loop任务中的事件ID置为ZDO_NETWORK_INIT以便执行B;如果成功则ZDApp_event_loop任务中的事件ID置为ZDO_STATE_CHANGE_EVT以便执行E。
          E:调用ZDO_UpdateNwkStatus函数,函数通过端点表向SampleApp_ProcessEvent任务发送一个ZDO_STATE_CHANGE命令,以便执行F。
          F:设置ZDApp_event_loop任务中的事件ID为SAMPLEAPP_SEND_PERIODIC_MSG_EVT以便执行G。
          G:发送一个定期信息,并设置ZDApp_event_loop任务中的事件ID为SAMPLEAPP_SEND_PERIODIC_MSG_EVT以便执行G。
     注:1、B-C—D会循环多次。
     2、ZDO_StartDevice函数中的
           if ( ret != ZSuccess )
          osal_start_timerEx(ZDAppTaskID, ZDO_NETWORK_INIT, NWK_RETRY_DELAY );
          不知有何作用,不管申请是否成功ret== ZSuccess。
     2、  网络的允许设备加入
          A:网络允许设备连接的操作在程序中没有找到,只查看到了有节点加入时会有ZDApp_event_loop任务的ID为ZDO_NWK_UPDATE_NV的事件。执行的ZDApp_SaveNetworkStateEvt函数中间的实体好象都没有通过编译。
二、有节点加入网络的处理
     1、有节点加入会有ZDApp_event_loop任务的ID为ZDO_NWK_UPDATE_NV的事件。节点的信息可以通过AssociatedDevList表。
三、在节点退出网络的处理
     1、在例程中没有找到关于节点退出网络的处理接口,在查看各任务中都没有对应任务处理。即在void osal_start_system( void )函数中的每个任务的事件ID都没有变化。
     2、网上,给于的答付是:现在提供的列程中没有节点退出的体现,如果想有体现需要从底层找到接口,一层一层的传上来,但要注意配置中需要将此接口打开,否则也无法触发,还有可能将直接从寄存器中去读取数据。
简单的办法是定期的发送举手(poll Rate)、扫描、轮询等。如何进行目前未知。
     3、终端的父级退出网络时,终端可以知道,会引发ZDO_SyncIndicationCB( byte type, uint16 shortAddr )。但终端离开网络时没能找到对应的事件。
     4、从例程中的NLMDE.h文件中查看函数的注释可能以下函数有关:
          /*
           * This function allows the next higher layer to request that itself
           * or another device leave the network.-- 请求它自身或别的设备离开网络
            *
            * @MT SPI_CMD_NLME_LEAVE_REQ
            *
            */
           extern ZStatus_t NLME_LeaveReq( NLME_LeaveReq_t* req );

           /*
            * This function allows the next higher layer to be notified of the
            * results of its request for itself or another device to leave the
            * network.--接收它身或别的设备请求离开网络的结果
            *
            * @MT SPI_CB_NLME_LEAVE_CNF
            *
            */
           extern void NLME_LeaveCnf( NLME_LeaveCnf_t* cnf );

           /*
            * This function allows the next higher layer of a device to be
            * notified of a remote leave request.--接收一个远程离开请求
            *
            * @MT SPI_CB_NLME_LEAVE_IND
            *
            */
           extern void NLME_LeaveInd( NLME_LeaveInd_t* ind );

           /*
            * This function allows the next higher layer to respond to a leave
            * indication.--回应一个设备的离开
            */
           extern ZStatus_t NLME_LeaveRsp( NLME_LeaveRsp_t* rsp );

           /***********************************************************
            * @fn          ZDO_LeaveInd
            *
            * @brief       This function allows the next higher layer of a
            *              device to be notified of a remote leave request or
            *              indication.--远程设备设备离开请求的通知
            *
            * @param       ind - NLME_LeaveInd_t
            *
            * @return      none
            */
           void ZDO_LeaveInd( NLME_LeaveInd_t* ind )

           /***********************************************************
            * @fn          ZDO_LeaveCnf
            *
            * @brief       This function allows the next higher layer to be
            *              notified of the results of its request for this or
            *              a child device to leave the network.
            *
            * @param       cnf - NLME_LeaveCnf_t
            *
            * @return      none
            */
           void ZDO_LeaveCnf( NLME_LeaveCnf_t* cnf )

           /***********************************************************
            * @fn          ZDO_UpdateDeviceIndication
            *
            * @brief       This function notifies the "Trust Center" of a
            *              network when a device joins or leaves the network.--通知信任中心有设备加入或离开网络
            *
            * @param       extAddr - pointer to 64 bit address of new device
            * @param       status  - 0 if a new device joined securely
            *                      - 1 if a new device joined un-securely
            *                      - 2 if a device left the network
            *
            * @return      true if newly joined device should be allowed to
            *                                              remain on network
            */
           ZStatus_t ZDO_UpdateDeviceIndication( byte *extAddr, byte status )

           
           /**********************************************************
            * @fn          MAC_MlmeDisassociateReq
            *
            * @brief       This function is used by an associated device to notify the
            *              coordinator of its intent to leave the PAN.  It is also used
            *              by the coordinator to instruct an associated device to leave
            *              the PAN.  When the disassociate is complete the MAC sends a
            *              MAC_MLME_DISASSOCIATE_CNF to the application.
            *
            * input parameters
            *
            * @param       pData - Pointer to parameters structure.
            *
            * output parameters
            *
            * None.
            *
            * @return      None.
            ***********************************************************
            */
           extern void MAC_MlmeDisassociateReq(macMlmeDisassociateReq_t *pData);

           case SPI_CMD_NLME_LEAVE_REQ:

           /***********************************************************
            * @fn          nwk_MTCallbackSubLeaveIndication
            *
            * @brief       Process the callback subscription for NLME-LEAVE.indication
            *
            * @param       DeviceAddress - IEEE (64-bit) address
            *
            * @return      NULL
            */
           void nwk_MTCallbackSubLeaveIndication( byte *DeviceAddress )

           /***********************************************************
            * @fn          nwk_MTCallbackSubLeaveIndication
            *
            * @brief       Process the callback subscription for NLME-LEAVE.indication
            *
            * @param       DeviceAddress - IEEE (64-bit) address
            *
            * @return      NULL
            */
           void nwk_MTCallbackSubLeaveIndication( byte *DeviceAddress )

           ZDP_MgmtLeaveReq

           ZDP_MgmtLeaveRsp

四、网络中的各种信息
     1、  邻居表
          A:在程序中表的实体为neighborTable,表中的部分信息是指在建立网络时扫描到的所有在此信道的设备信息(具有不同的网络ID)。这次所建的网络ID不能与neighborTable表的ID相同。
     2、  关联设备表
          A:在程序中的实体为AssociatedDevList
  
五、接收数据的处理
     1、  当有节点的数据信息时会有SampleApp_ProcessEvent任务中的SYS_EVENT_MSG事件,在此事件中通过MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID );得到一个afIncomingMSGPacket_t。MSGpkt->hdr.event为AF_INCOMING_MSG_CMD的事件。传送的信息在MSGpkt中。可以通过MSGpkt->clusterId来检测是那一个端点的信息(猜想)。

posted @ 2011-05-31 23:23  雪帕  阅读(3408)  评论(0编辑  收藏  举报