Hi @Joan Duran,
You can use ZbMsgFilterRegister API at the startup (inside the func APP_ZIGBEE_StackLayersInit) to register the callback you want to use to retrieve any network status change.
Please find below an example to detect a new device join :
ZbMsgFilterRegister( stZigbeeAppInfo.pstZigbee, ZB_MSG_FILTER_JOIN_IND, ZB_MSG_DEFAULT_PRIO, APP_ZIGBEE_DeviceJointCallback, NULL );
static enum zb_msg_filter_rc APP_ZIGBEE_DeviceJointCallback( struct ZigBeeT * zb, uint32_t lId, void * pMessage, void * arg )
{
struct ZbNlmeJoinIndT * pstJoinMessage;
if ( lId == ZB_MSG_FILTER_JOIN_IND )
{
pstJoinMessage = ( struct ZbNlmeJoinIndT * )pMessage;
switch ( pstJoinMessage->rejoinNetwork )
{
case ZB_NWK_REJOIN_TYPE_ASSOC :
case ZB_NWK_REJOIN_TYPE_ORPHAN :
case ZB_NWK_REJOIN_TYPE_NWKREJOIN :
case ZB_NWK_REJOIN_TYPE_NWKCOMMISS_JOIN :
case ZB_NWK_REJOIN_TYPE_NWKCOMMISS_REJOIN :
/* A new Device has Join Network at MAC/NWK level */
APP_ZIGBEE_SetNewDevice( pstJoinMessage->nwkAddr, pstJoinMessage->extAddr, pstJoinMessage->capabilityInfo );
break;
default :
break;
}
}
return( ZB_MSG_CONTINUE );
}
Best regards,
Ouadi