📄 zdcache.s51
字号:
// 530 byte epIdx;
// 531 NwkAddr[idx] = INVALID_NODE_ADDR;
// 532
// 533 for ( epIdx = 0; epIdx < CACHE_EP_MAX; epIdx++ )
// 534 {
// 535 SimpDesc[idx][epIdx].pAppInClusterList = InClusters[idx][epIdx];
// 536 SimpDesc[idx][epIdx].pAppOutClusterList= OutClusters[idx][epIdx];
// 537 }
// 538 }
// 539 #elif ( CACHE_DEV_MAX == 0 )
// 540 // Client cache work done by ZDCacheTimerEvent, driven by NWK_AUTO_POLL_EVT.
// 541 #endif
// 542 }
// 543
// 544 /*********************************************************************
// 545 * @fn ZDCacheTimerEvent
// 546 *
// 547 * @brief ZDP maintenance, aging discovery cache.
// 548 * Invoked at RTG_TIMER_INTERVAL.
// 549 */
// 550 void ZDCacheTimerEvent( void )
// 551 {
// 552 #if ( CACHE_DEV_MAX > 0 )
// 553 byte idx;
// 554
// 555 for ( idx = 0; idx < CACHE_DEV_MAX; idx++ )
// 556 {
// 557 if ( NwkAddr[idx] != INVALID_NODE_ADDR )
// 558 {
// 559 if ( --Expiry[idx] == 0 )
// 560 {
// 561 NwkAddr[idx] = INVALID_NODE_ADDR;
// 562 }
// 563 }
// 564 }
// 565 #elif ( CACHE_DEV_MAX == 0 )
// 566 static eCacheState state = eCacheWait;
// 567 static byte reqIdx = 0;
// 568 static byte wCnt = 0;
// 569
// 570 byte strtFind = FALSE;
// 571 byte cmd = 0;
// 572 byte len = 2 + Z_EXTADDR_LEN;
// 573 byte *msg, *ptr;
// 574
// 575 wCnt++;
// 576 if ( state == eCacheWait )
// 577 {
// 578 if ( wCnt < WAIT_TO_STORE_CACHE )
// 579 {
// 580 return;
// 581 }
// 582 }
// 583 else if ( wCnt < WAIT_ON_RESP_CACHE )
// 584 {
// 585 return;
// 586 }
// 587
// 588 msg = osal_mem_alloc( MAX_PKT_LEN );
// 589 if ( msg == NULL )
// 590 {
// 591 return;
// 592 }
// 593
// 594 msg[0] = LO_UINT16( ZDAppNwkAddr.addr.shortAddr );
// 595 msg[1] = HI_UINT16( ZDAppNwkAddr.addr.shortAddr );
// 596 osal_cpyExtAddr( msg+2, saveExtAddr );
// 597 ptr = msg+2+Z_EXTADDR_LEN;
// 598
// 599 switch ( state )
// 600 {
// 601 case eCacheWait:
// 602 state = eCacheClean;
// 603 msgAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
// 604 cmd = Find_node_cache_req;
// 605 cacheCnt = 0;
// 606 reqIdx = 0;
// 607 break;
// 608
// 609 case eCacheClean:
// 610 if ( reqIdx < cacheCnt )
// 611 {
// 612 msgAddr.addr.shortAddr = cacheFindAddr[reqIdx++];
// 613 cmd = Remove_node_cache_req;
// 614 }
// 615 else
// 616 {
// 617 strtFind = TRUE;
// 618 radius = 0;
// 619 }
// 620 break;
// 621
// 622 case eCacheFind:
// 623 if ( cacheCnt != 0 )
// 624 {
// 625 state = eCacheRequest;
// 626 reqIdx = 0;
// 627 }
// 628 else
// 629 {
// 630 strtFind = TRUE;
// 631 }
// 632 break;
// 633
// 634 case eCacheRequest:
// 635 if ( (cacheRsp == ZDP_SUCCESS) && (reqIdx != 0) )
// 636 {
// 637 cmd = Node_Desc_store_req;
// 638 len += sizeof( NodeDescriptorFormat_t );
// 639 ptr = osal_memcpy( ptr, &ZDO_Config_Node_Descriptor,
// 640 sizeof( NodeDescriptorFormat_t ) );
// 641 state = eNodeDescStore;
// 642 }
// 643 else if ( reqIdx < cacheCnt )
// 644 {
// 645 EPCnt = afNumEndPoints() - 1; // -1 for ZDO endpoint descriptor.
// 646
// 647 if ( EPCnt < CACHE_EP_MAX )
// 648 {
// 649 byte idx;
// 650 afEndPoints( EPArr, true );
// 651
// 652 msgAddr.addr.shortAddr = cacheFindAddr[reqIdx++];
// 653
// 654 cmd = Discovery_store_req;
// 655 len += (4 + EPCnt);
// 656 *ptr++ = sizeof( NodeDescriptorFormat_t );
// 657 *ptr++ = sizeof( NodePowerDescriptorFormat_t );
// 658 *ptr++ = EPCnt + 1; // NOT -1 for size in bytes of EP list.
// 659 *ptr++ = EPCnt;
// 660
// 661 for ( idx = 0; idx < EPCnt; idx++ )
// 662 {
// 663 SimpleDescriptionFormat_t *sDesc;
// 664 byte free = afFindSimpleDesc( &sDesc, EPArr[idx] );
// 665
// 666 if ( sDesc != NULL )
// 667 {
// 668 *ptr++ = 8 + sDesc->AppNumInClusters + sDesc->AppNumOutClusters;
// 669
// 670 if ( free )
// 671 {
// 672 osal_mem_free( sDesc );
// 673 }
// 674 }
// 675 else
// 676 {
// 677 *ptr++ = 8;
// 678 }
// 679 }
// 680 }
// 681 }
// 682 else
// 683 {
// 684 strtFind = TRUE;
// 685 }
// 686 break;
// 687
// 688 case eNodeDescStore:
// 689 if ( cacheRsp == ZDP_SUCCESS )
// 690 {
// 691 cmd = Power_Desc_store_req;
// 692 len += sizeof( NodePowerDescriptorFormat_t );
// 693 ptr = osal_memcpy( ptr, &ZDO_Config_Power_Descriptor,
// 694 sizeof( NodePowerDescriptorFormat_t ) );
// 695 state = ePwrDescStore;
// 696 }
// 697 else
// 698 {
// 699 strtFind = TRUE;
// 700 }
// 701 break;
// 702
// 703 case ePwrDescStore:
// 704 if ( cacheRsp == ZDP_SUCCESS )
// 705 {
// 706 cmd = Active_EP_store_req;
// 707 len += EPCnt + 1;
// 708 *ptr++ = EPCnt;
// 709 afEndPoints( ptr, true );
// 710 state = eActiveEPStore;
// 711 }
// 712 else
// 713 {
// 714 strtFind = TRUE;
// 715 }
// 716 break;
// 717
// 718 case eActiveEPStore:
// 719 if ( cacheRsp == ZDP_SUCCESS )
// 720 {
// 721 state = eSimpDescStore;
// 722 reqIdx = 0;
// 723 }
// 724 else
// 725 {
// 726 strtFind = TRUE;
// 727 }
// 728 break;
// 729
// 730 case eSimpDescStore:
// 731 if ( (cacheRsp == ZDP_SUCCESS) || (reqIdx == 0) )
// 732 {
// 733 if ( reqIdx >= EPCnt )
// 734 {
// 735 state = eCacheDone;
// 736 }
// 737 else
// 738 {
// 739 SimpleDescriptionFormat_t *sDesc;
// 740 byte free = afFindSimpleDesc( &sDesc, EPArr[reqIdx++] );
// 741
// 742 if ( sDesc != NULL )
// 743 {
// 744 cmd = Simple_Desc_store_req;
// 745 len += 1 + 8 + sDesc->AppNumInClusters + sDesc->AppNumOutClusters;
// 746 *ptr++ = 8 + sDesc->AppNumInClusters + sDesc->AppNumOutClusters;
// 747 *ptr++ = sDesc->EndPoint;
// 748 *ptr++ = LO_UINT16( sDesc->AppProfId );
// 749 *ptr++ = HI_UINT16( sDesc->AppProfId );
// 750 *ptr++ = LO_UINT16( sDesc->AppDeviceId );
// 751 *ptr++ = HI_UINT16( sDesc->AppDeviceId );
// 752 *ptr++ = (sDesc->Reserved << 4) | sDesc->AppDevVer;
// 753 *ptr++ = sDesc->AppNumInClusters;
// 754 ptr = osal_memcpy( ptr, sDesc->pAppInClusterList,
// 755 sDesc->AppNumInClusters );
// 756 *ptr++ = sDesc->AppNumOutClusters;
// 757 osal_memcpy(ptr, sDesc->pAppOutClusterList, sDesc->AppNumOutClusters);
// 758
// 759 if ( free )
// 760 {
// 761 osal_mem_free( sDesc );
// 762 }
// 763 }
// 764 }
// 765 }
// 766 else
// 767 {
// 768 strtFind = TRUE;
// 769 }
// 770 break;
// 771
// 772 case eCacheDone:
// 773 #if !defined( NWK_AUTO_POLL )
// 774 NLME_SetPollRate( 0 ); // Stop the timer to allow max power savings.
// 775 #endif
// 776 break;
// 777
// 778 default:
// 779 break;
// 780 } // switch ( state )
// 781
// 782 if ( strtFind )
// 783 {
// 784 if ( state >= eNodeDescStore )
// 785 {
// 786 SendMsg( Remove_node_cache_req, 2+Z_EXTADDR_LEN, msg );
// 787 }
// 788
// 789 state = eCacheFind;
// 790 if ( ++radius > (2 * _NIB.MaxDepth) )
// 791 {
// 792 radius = 1;
// 793 }
// 794 msgAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
// 795 cacheCnt = 0;
// 796 cmd = Discovery_Register_req;
// 797 }
// 798 cacheRsp = ZDP_TIMEOUT;
// 799 wCnt = 0;
// 800
// 801 if ( cmd != 0 )
// 802 {
// 803 SendMsg( cmd, len, msg );
// 804 }
// 805 osal_mem_free( msg );
// 806 #endif
// 807 }
// 808
// 809 #if ( CACHE_DEV_MAX > 0 )
// 810 /*********************************************************************
// 811 * @fn ZDCacheProcessReq
// 812 *
// 813 * @brief Build and send a response to a Discovery Cache request.
// 814 *
// 815 */
// 816 void ZDCacheProcessReq( zAddrType_t *src, byte *msg, byte len,
// 817 byte cmd, byte seq, byte sty )
// 818 {
// 819 byte status = ZDP_SUCCESS;
// 820 byte sent = FALSE;
// 821
// 822 msgAddr.addr.shortAddr = src->addr.shortAddr;
// 823 tranSeq = seq;
// 824 secUse = sty;
// 825
// 826 if ( !CACHE_SERVER )
// 827 {
// 828 // Broadcast reqs without a negative response specified.
// 829 if ( (cmd == Discovery_Register_req) || (cmd == Find_node_cache_req) )
// 830 {
// 831 sent = TRUE;
// 832 }
// 833 else
// 834 {
// 835 status = ZDP_NOT_SUPPORTED;
// 836 }
// 837 }
// 838 else if ( cmd == Discovery_Register_req )
// 839 {
// 840 if ( getIdx( INVALID_NODE_ADDR ) == CACHE_DEV_MAX )
// 841 {
// 842 status = ZDP_TABLE_FULL;
// 843 }
// 844 }
// 845 else if ( cmd == Discovery_store_req )
// 846 {
// 847 status = processDiscoveryStoreReq( msg );
// 848 }
// 849 else if ( cmd == Find_node_cache_req )
// 850 {
// 851 processFindNodeCacheReq( msg );
// 852 sent = TRUE;
// 853 }
// 854 else if ( cmd == Mgmt_Cache_req )
// 855 {
// 856 processMgmtCacheReq( *msg );
// 857 sent = TRUE;
// 858 }
// 859 else
// 860 {
// 861 uint16 aoi = BUILD_UINT16( msg[0], msg[1] );
// 862 byte idx = getIdx( aoi );
// 863
// 864 if ( cmd == Remove_node_cache_req )
// 865 {
// 866 if ( (purgeAddr( aoi ) + purgeIEEE( msg+2 )) == 0 )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -