📄 zdobject.lst
字号:
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 )) );
644 }
645 else
646 {
647 // Force no clusters
648 ZDO_EDBind->numInClusters = 0;
649 }
650 }
651 else
652 ZDO_EDBind->inClusters = NULL;
653
654 ZDO_EDBind->numOutClusters = bindReq->numOutClusters;
655 if ( bindReq->numOutClusters )
656 {
657 ZDO_EDBind->outClusters = osal_mem_alloc( (short)(bindReq->numOutClusters*sizeof(uint16)) );
658 if ( ZDO_EDBind->outClusters )
659 {
660 osal_memcpy( ZDO_EDBind->outClusters, bindReq->outClusters, (bindReq->numOutClusters * sizeof( uint16 )) );
661 }
662 else
663 {
664 ZDO_EDBind->numOutClusters = 0;
665 }
666 }
667 else
668 ZDO_EDBind->outClusters = NULL;
669
670 ZDO_EDBind->SecurityUse = bindReq->SecurityUse;
671 ZDO_EDBind->status = ZDP_TIMEOUT;
672
673 // Setup the timer
674 APS_SetEndDeviceBindTimeout( AIB_MaxBindingTime, ZDO_EndDeviceTimeoutCB );
675 }
676 }
677 }
678 #endif // REFLECTOR
679
680 /*********************************************************************
681 * Utility functions
682 */
683
684 /*********************************************************************
685 * @fn ZDO_CreateAlignedUINT16List
686 *
687 * @brief Creates a list of cluster IDs that is guaranteed to be aligned.
688 * according to the needs of the target. If thre device is running
689 * Protocol version 1.0 the incoming buffer will have only a single
690 * byte for the cluster ID.
691 *
692 * Depends on the malloc taking care of alignment.
693 *
694 * When cluster ID went to 16 bits alignment for cluster IDs became
695 * an issue.
696 *
697 * @param num - number of entries in list
698 * @param buf - pointer to list
699 *
700 * @return pointer to aligned list. Null if can't allocate memory.
701 * Caller's responsibility to free memory.
702 */
\ In segment BANKED_CODE, align 1, keep-with-next
703 static uint16 *ZDO_CreateAlignedUINT16List(uint8 num, uint8 *buf)
\ ??ZDO_CreateAlignedUINT16List:
704 {
\ 000000 74F2 MOV A,#-0xe
\ 000002 12.... LCALL ?BANKED_ENTER_XDATA
\ 000005 ; Saved register size: 14
\ 000005 ; Auto size: 0
\ 000005 89.. MOV ?V0 + 2,R1
\ 000007 EA MOV A,R2
\ 000008 FE MOV R6,A
\ 000009 EB MOV A,R3
\ 00000A FF MOV R7,A
705 uint16 *ptr;
706
707 if ((ptr=osal_mem_alloc((short)(num*sizeof(uint16))))) {
\ 00000B ; Setup parameters for call to function osal_mem_alloc
\ 00000B E9 MOV A,R1
\ 00000C C3 CLR C
\ 00000D 33 RLC A
\ 00000E FA MOV R2,A
\ 00000F E4 CLR A
\ 000010 33 RLC A
\ 000011 FB MOV R3,A
\ 000012 90.... MOV DPTR,#(osal_mem_alloc & 0xffff)
\ 000015 74.. MOV A,#((osal_mem_alloc >> 16) & 0xff)
\ 000017 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 00001A 8A.. MOV ?V0 + 0,R2
\ 00001C 8B.. MOV ?V0 + 1,R3
\ 00001E EA MOV A,R2
\ 00001F 7001 JNZ ??ZDO_CreateAlignedUINT16List_1
\ 000021 EB MOV A,R3
\ ??ZDO_CreateAlignedUINT16List_1:
\ 000022 605D JZ ??ZDO_CreateAlignedUINT16List_2
708 uint8 i, ubyte, inc;
709
710 inc = (ZB_PROT_V1_1 == NLME_GetProtocolVersion()) ? 2 : 1;
\ 000024 ; Setup parameters for call to function NLME_GetProtocolVersion
\ 000024 90.... MOV DPTR,#(NLME_GetProtocolVersion & 0xffff)
\ 000027 74.. MOV A,#((NLME_GetProtocolVersion >> 16) & 0xff)
\ 000029 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 00002C E9 MOV A,R1
\ 00002D 6402 XRL A,#0x2
\ 00002F 7004 JNZ ??ZDO_CreateAlignedUINT16List_3
\ 000031 7B02 MOV R3,#0x2
\ 000033 8002 SJMP ??ZDO_CreateAlignedUINT16List_4
\ ??ZDO_CreateAlignedUINT16List_3:
\ 000035 7B01 MOV R3,#0x1
711
712 for (i=0; i<num; ++i) {
\ ??ZDO_CreateAlignedUINT16List_4:
\ 000037 7A00 MOV R2,#0x0
\ 000039 8031 SJMP ??ZDO_CreateAlignedUINT16List_5
713 // set upper byte to 0 if we're talking Version 1.0. otherwise
714 // the buffer contains 16 bit cluster IDs.
715 ubyte = (2 == inc) ? buf[1] : 0;
\ ??ZDO_CreateAlignedUINT16List_6:
\ 00003B 75..00 MOV ?V0 + 3,#0x0
716 ptr[i] = BUILD_UINT16(buf[0], ubyte);
\ ??ZDO_CreateAlignedUINT16List_7:
\ 00003E 8E82 MOV DPL,R6
\ 000040 8F83 MOV DPH,R7
\ 000042 E0 MOVX A,@DPTR
\ 000043 FC MOV R4,A
\ 000044 E4 CLR A
\ 000045 2C ADD A,R4
\ 000046 E5.. MOV A,?V0 + 3
\ 000048 3400 ADDC A,#0x0
\ 00004A FD MOV R5,A
\ 00004B EA MOV A,R2
\ 00004C C3 CLR C
\ 00004D 33 RLC A
\ 00004E F8 MOV R0,A
\ 00004F E4 CLR A
\ 000050 33 RLC A
\ 000051 F9 MOV R1,A
\ 000052 E5.. MOV A,?V0 + 0
\ 000054 28 ADD A,R0
\ 000055 F582 MOV DPL,A
\ 000057 E5.. MOV A,?V0 + 1
\ 000059 39 ADDC A,R1
\ 00005A F583 MOV DPH,A
\ 00005C EC MOV A,R4
\ 00005D F0 MOVX @DPTR,A
\ 00005E A3 INC DPTR
\ 00005F ED MOV A,R5
\ 000060 F0 MOVX @DPTR,A
717 buf += inc;
\ 000061 8B.. MOV ?V0 + 4,R3
\ 000063 EE MOV A,R6
\ 000064 25.. ADD A,?V0 + 4
\ 000066 FE MOV R6,A
\ 000067 EF MOV A,R7
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -