zdobject.lst
来自「用IAR开发的ZIGBEE网络路由例子」· LST 代码 · 共 1,291 行 · 第 1/5 页
LST
1,291 行
\ 000000 12.... LCALL ?Subroutine19 & 0xFFFF
\ ??CrossCallReturnLabel_54:
\ 000003 22 RET
\ In segment BANKED_CODE, align 1, keep-with-next
\ ?Subroutine19:
\ 000000 E0 MOVX A,@DPTR
\ 000001 F8 MOV R0,A
\ 000002 A3 INC DPTR
\ 000003 E0 MOVX A,@DPTR
\ 000004 F583 MOV DPH,A
\ 000006 8882 MOV DPL,R0
\ 000008 E0 MOVX A,@DPTR
\ 000009 22 RET
\ In segment BANKED_CODE, align 1, keep-with-next
\ ?Subroutine6:
\ 000000 12.... LCALL ?Subroutine22 & 0xFFFF
\ ??CrossCallReturnLabel_61:
\ 000003 A3 INC DPTR
\ 000004 12.... LCALL ?Subroutine19 & 0xFFFF
\ ??CrossCallReturnLabel_52:
\ 000007 F9 MOV R1,A
\ 000008 90.... MOV DPTR,#(osal_msg_send & 0xffff)
\ 00000B 74.. MOV A,#((osal_msg_send >> 16) & 0xff)
\ 00000D 22 RET
\ In segment BANKED_CODE, align 1, keep-with-next
\ ?Subroutine3:
\ 000000 EA MOV A,R2
\ 000001 F0 MOVX @DPTR,A
\ 000002 A3 INC DPTR
\ 000003 EB MOV A,R3
\ 000004 F0 MOVX @DPTR,A
\ 000005 22 RET
420
421 #if defined ( REFLECTOR )
422 /*********************************************************************
423 * @fn ZDO_RemoveEndDeviceBind
424 *
425 * @brief Remove the end device bind
426 *
427 * @param none
428 *
429 * @return none
430 */
431 static void ZDO_RemoveEndDeviceBind( void )
432 {
433 if ( ZDO_EDBind )
434 {
435 // Free the RAM
436 if ( ZDO_EDBind->inClusters )
437 osal_mem_free( ZDO_EDBind->inClusters );
438 if ( ZDO_EDBind->outClusters )
439 osal_mem_free( ZDO_EDBind->outClusters );
440 osal_mem_free( ZDO_EDBind );
441 ZDO_EDBind = NULL;
442 }
443 }
444 #endif // REFLECTOR
445
446 #if defined ( REFLECTOR )
447 /*********************************************************************
448 * @fn ZDO_RemoveEndDeviceBind
449 *
450 * @brief Remove the end device bind
451 *
452 * @param none
453 *
454 * @return none
455 */
456 static void ZDO_SendEDBindRsp( byte TransSeq, zAddrType_t *dstAddr, byte Status, byte secUse )
457 {
458 ZDP_EndDeviceBindRsp( TransSeq, dstAddr, Status, secUse );
459
460 #if defined( LCD_SUPPORTED )
461 HalLcdWriteString( "End Device Bind", HAL_LCD_LINE_1 );
462 if ( Status == ZDP_SUCCESS )
463 HalLcdWriteString( "Success Sent", HAL_LCD_LINE_2 );
464 else
465 HalLcdWriteString( "Timeout", HAL_LCD_LINE_2 );
466 #endif
467
468 }
469 #endif // REFLECTOR
470
471 #if defined ( REFLECTOR ) || defined ( ZDO_COORDINATOR )
472 /*********************************************************************
473 * @fn ZDO_CompareClusterLists
474 *
475 * @brief Compare one list to another list
476 *
477 * @param numList1 - number of items in list 1
478 * @param list1 - first list of cluster IDs
479 * @param numList2 - number of items in list 2
480 * @param list2 - second list of cluster IDs
481 * @param pMatches - buffer to put matches
482 *
483 * @return number of matches
484 */
485 static byte ZDO_CompareClusterLists( byte numList1, uint16 *list1,
486 byte numList2, uint16 *list2, uint16 *pMatches )
487 {
488 byte x, y;
489 uint16 z;
490 byte numMatches = 0;
491
492 // Check the first in against the seconds out
493 for ( x = 0; x < numList1; x++ )
494 {
495 for ( y = 0; y < numList2; y++ )
496 {
497 z = list2[y];
498 if ( list1[x] == z )
499 pMatches[numMatches++] = z;
500 }
501 }
502
503 return ( numMatches );
504 }
505 #endif // REFLECTOR || ZDO_COORDINATOR
506
507 #if defined ( REFLECTOR )
508 /*********************************************************************
509 * @fn ZDO_DoEndDeviceBind
510 *
511 * @brief Process the End Device Bind Req from ZDApp
512 *
513 * @param bindReq - Bind Request Information
514 * @param SecurityUse - Security enable/disable
515 *
516 * @return none
517 */
518 void ZDO_DoEndDeviceBind( ZDEndDeviceBind_t *bindReq )
519 {
520 uint8 numMatches;
521 uint8 Status;
522 BindingEntry_t *pBind;
523 AddrMgrEntry_t addrEntry;
524 zAddrType_t SrcAddr;
525
526 SrcAddr.addrMode = Addr16Bit;
527 SrcAddr.addr.shortAddr = bindReq->srcAddr;
528
529 // Ask for IEEE address
530 if ( (bindReq->srcAddr != ZDAppNwkAddr.addr.shortAddr) )
531 {
532 addrEntry.user = ADDRMGR_USER_BINDING;
533 addrEntry.nwkAddr = bindReq->srcAddr;
534 Status = AddrMgrEntryLookupNwk( &addrEntry );
535 if ( Status == TRUE)
536 {
537 // Add a reference to entry
538 AddrMgrEntryAddRef( &addrEntry );
539 }
540 else
541 {
542 // If we have the extended address
543 if ( NLME_GetProtocolVersion() != ZB_PROT_V1_0 )
544 {
545 osal_cpyExtAddr( addrEntry.extAddr, bindReq->ieeeAddr );
546 }
547
548 // Not in address manager?
549 AddrMgrEntryUpdate( &addrEntry ); // Add it
550 }
551
552 if ( AddrMgrExtAddrValid( addrEntry.extAddr ) == FALSE )
553 {
554 ZDP_IEEEAddrReq( bindReq->srcAddr, ZDP_ADDR_REQTYPE_SINGLE, 0, false );
555 }
556 }
557
558 if ( ZDO_EDBind ) // End Device Bind in progress
559 {
560 Status = ZDP_NO_MATCH;
561
562 if ( bindReq->profileID == ZDO_EDBind->ProfileID )
563 {
564 // Check the first in against the seconds out
565 numMatches = ZDO_CompareClusterLists(
566 ZDO_EDBind->numOutClusters, ZDO_EDBind->outClusters,
567 bindReq->numInClusters, bindReq->inClusters, ZDOBuildBuf );
568
569 if ( numMatches )
570 {
571 // if existing bind exists, remove it
572 pBind = bindFindExisting( &(ZDO_EDBind->SrcAddr), ZDO_EDBind->epIntf,
573 &SrcAddr, bindReq->endpoint );
574 if ( pBind )
575 {
576 bindRemoveEntry( pBind );
577 Status = ZDP_SUCCESS;
578 }
579 // else add new binding table entry
580 else if ( bindAddEntry( &(ZDO_EDBind->SrcAddr), ZDO_EDBind->epIntf,
581 &SrcAddr, bindReq->endpoint, numMatches, ZDOBuildBuf ) )
582 Status = ZDP_SUCCESS;
583 else
584 Status = ZDP_TABLE_FULL;
585 }
586
587 // Check the second in against the first out
588 numMatches = ZDO_CompareClusterLists( bindReq->numOutClusters, bindReq->outClusters,
589 ZDO_EDBind->numInClusters, ZDO_EDBind->inClusters,
590 ZDOBuildBuf );
591
592 if ( numMatches )
593 {
594 // if existing bind exists, remove it
595 pBind = bindFindExisting( &SrcAddr, bindReq->endpoint, &(ZDO_EDBind->SrcAddr),
596 ZDO_EDBind->epIntf );
597 if ( pBind )
598 {
599 bindRemoveEntry( pBind );
600 Status = ZDP_SUCCESS;
601 }
602 // else add new binding table entry
603 else if ( bindAddEntry( &SrcAddr, bindReq->endpoint, &(ZDO_EDBind->SrcAddr),
604 ZDO_EDBind->epIntf, numMatches, ZDOBuildBuf ) )
605 Status = ZDP_SUCCESS;
606 else
607 Status = ZDP_TABLE_FULL;
608 }
609 }
610
611 if ( Status == ZDP_SUCCESS )
612 {
613 // We've found a match, so we don't have to wait for the timeout
614 APS_SetEndDeviceBindTimeout( 10, ZDO_EndDeviceTimeoutCB ); // psuedo stop end device timeout
615
616 // Notify to save info into NV
617 osal_start_timerEx( ZDAppTaskID, ZDO_NWK_UPDATE_NV, 250 );
618 }
619
620 ZDO_EDBind->status = Status;
621
622 // Send the response message to the device sending this message
623 ZDO_SendEDBindRsp( bindReq->TransSeq, &SrcAddr, Status, bindReq->SecurityUse );
624 }
625 else // Start a new End Device Bind
626 {
627 // Copy the info
628 ZDO_EDBind = osal_mem_alloc( sizeof( ZDO_EDBind_t ) );
629 if ( ZDO_EDBind )
630 {
631 osal_memcpy( &(ZDO_EDBind->SrcAddr), &SrcAddr, sizeof( zAddrType_t ) );
632 ZDO_EDBind->LocalCoordinator = bindReq->localCoordinator;
633 ZDO_EDBind->epIntf = bindReq->endpoint;
634 ZDO_EDBind->ProfileID = bindReq->profileID;
635 ZDO_EDBind->SrcTransSeq = bindReq->TransSeq;
636
637 ZDO_EDBind->numInClusters = bindReq->numInClusters;
638 if ( bindReq->numInClusters )
639 {
640 ZDO_EDBind->inClusters = osal_mem_alloc( (short)(bindReq->numInClusters * sizeof(uint16)) );
641 if ( ZDO_EDBind->inClusters )
642 {
643 osal_memcpy( ZDO_EDBind->inClusters, bindReq->inClusters, (bindReq->numInClusters * sizeof( uint16 )) );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?