📄 mt_zdo.s51
字号:
// 499 devAddr.addr.shortAddr = BUILD_UINT16( pData[1], pData[0] );
// 500 pData += 2;
// 501
// 502 // Network address of interest
// 503 shortAddr = BUILD_UINT16( pData[1], pData[0] );
// 504 pData += 2;
// 505
// 506 // User descriptor
// 507 userDesc.len = *pData++;
// 508 osal_memcpy( userDesc.desc, pData, userDesc.len );
// 509 pData += 16; // len of user desc
// 510
// 511 ret =(byte)ZDP_UserDescSet( &devAddr, shortAddr, &userDesc, pData[0] );
// 512 break;
// 513 #endif
// 514
// 515 #if defined ( ZDO_ENDDEVICE_ANNCE_REQUEST )
// 516 case SPI_CMD_ZDO_END_DEV_ANNCE:
// 517 // network address
// 518 shortAddr = BUILD_UINT16( pData[1], pData[0] );
// 519 pData += 2;
// 520
// 521 // extended address
// 522 ptr = pData;
// 523 MT_ReverseBytes( ptr, Z_EXTADDR_LEN );
// 524 pData += Z_EXTADDR_LEN;
// 525
// 526 // security
// 527 attr = *pData++;
// 528
// 529 ret = (byte)ZDP_EndDeviceAnnce( shortAddr, ptr, *pData, attr );
// 530 break;
// 531 #endif
// 532
// 533 #if defined (ZDO_SERVERDISC_REQUEST )
// 534 case SPI_CMD_ZDO_SERVERDISC_REQ:
// 535
// 536 // Service Mask
// 537 uAttr = BUILD_UINT16( pData[1], pData[0] );
// 538 pData += 2;
// 539 attr = *pData++; // Security suite
// 540
// 541 ret = (byte) ZDP_ServerDiscReq( uAttr, attr );
// 542 break;
// 543 #endif
// 544
// 545 #if defined (ZDO_NETWORKSTART_REQUEST )
// 546 case SPI_CMD_ZDO_NETWORK_START_REQ:
// 547 ret = ZDApp_StartUpFromApp( ZDAPP_STARTUP_AUTO );
// 548 break;
// 549
// 550 #endif
// 551
// 552 default:
// 553 break;
// 554 }
// 555
// 556 MT_SendSPIRespMsg( ret, cmd_id, len, respLen );
// 557 }
// 558
// 559 /*********************************************************************
// 560 * Utility FUNCTIONS
// 561 */
// 562
// 563 /*********************************************************************
// 564 * @fn zdo_MT_CopyRevExtAddr
// 565 *
// 566 */
// 567 byte *zdo_MT_CopyRevExtAddr( byte *dstMsg, byte *addr )
// 568 {
// 569 // Copy the 64-bit address
// 570 osal_cpyExtAddr( dstMsg, addr );
// 571 // Reverse byte order
// 572 MT_ReverseBytes( dstMsg, Z_EXTADDR_LEN );
// 573 // Return ptr to next destination location
// 574 return ( dstMsg + Z_EXTADDR_LEN );
// 575 }
// 576
// 577 /*********************************************************************
// 578 * @fn zdo_MT_MakeExtAddr
// 579 *
// 580 */
// 581 byte *zdo_MT_MakeExtAddr( zAddrType_t *devAddr, byte *pData )
// 582 {
// 583 // Define a 64-bit address
// 584 devAddr->addrMode = Addr64Bit;
// 585 // Copy and reverse the 64-bit address
// 586 zdo_MT_CopyRevExtAddr( devAddr->addr.extAddr, pData );
// 587 // Return ptr to next destination location
// 588 return ( pData + Z_EXTADDR_LEN );
// 589 }
// 590
// 591 /*********************************************************************
// 592 * CALLBACK FUNCTIONS
// 593 */
// 594
// 595 #if defined ( ZDO_NWKADDR_REQUEST ) || defined ( ZDO_IEEEADDR_REQUEST )
// 596 /*********************************************************************
// 597 * @fn zdo_MTCB_NwkIEEEAddrRspCB
// 598 *
// 599 * @brief
// 600 *
// 601 * Called by ZDO when a NWK_addr_rsp message is received.
// 602 *
// 603 * @param SrcAddr - Source address
// 604 * @param Status - response status
// 605 * @param IEEEAddr - 64 bit IEEE address of device
// 606 * @param nwkAddr - 16 bit network address of device
// 607 * @param NumAssocDev - number of associated devices to reporting device
// 608 * @param AssocDevList - array short addresses of associated devices
// 609 *
// 610 * @return none
// 611 */
// 612 void zdo_MTCB_NwkIEEEAddrRspCB( uint16 type, zAddrType_t *SrcAddr, byte Status,
// 613 byte *IEEEAddr, uint16 nwkAddr, byte NumAssocDev,
// 614 byte StartIndex, uint16 *AssocDevList )
// 615 {
// 616 byte *pBuf;
// 617 byte *msg;
// 618 byte len;
// 619 byte x;
// 620
// 621 /*Allocate a message of size equivalent to the corresponding SPI message
// 622 (plus a couple of bytes for MT use)so that the same buffer can be sent by
// 623 MT to the test tool by simply setting the header bytes.*/
// 624
// 625 /*In order to allocate the message , we need to know the length and this
// 626 has to be calculated before we allocate the message*/
// 627
// 628 if ( type == SPI_CB_ZDO_NWK_ADDR_RSP )
// 629 {
// 630 len = 1 + Z_EXTADDR_LEN + 1 + Z_EXTADDR_LEN + 2 + 1 + 1 + (2*8);
// 631 // Addrmode + SrcAddr + Status + IEEEAddr + nwkAddr + NumAssocDev + StartIndex
// 632 }
// 633 else
// 634 {
// 635 len = 1 + Z_EXTADDR_LEN + 1 + Z_EXTADDR_LEN + 1 + 1 + (2*8);
// 636 // Addrmode + SrcAddr + Status + IEEEAddr + NumAssocDev + StartIndex
// 637 }
// 638
// 639 pBuf = osal_mem_alloc( len );
// 640
// 641 if ( pBuf )
// 642 {
// 643 msg = pBuf;
// 644
// 645 //First fill in details
// 646 if ( SrcAddr->addrMode == Addr16Bit )
// 647 {
// 648 *msg++ = Addr16Bit;
// 649 for ( x = 0; x < (Z_EXTADDR_LEN - 2); x++ )
// 650 *msg++ = 0;
// 651 *msg++ = HI_UINT16( SrcAddr->addr.shortAddr );
// 652 *msg++ = LO_UINT16( SrcAddr->addr.shortAddr );
// 653 }
// 654 else
// 655 {
// 656 *msg++ = Addr64Bit;
// 657 msg = zdo_MT_CopyRevExtAddr( msg, SrcAddr->addr.extAddr );
// 658 }
// 659
// 660 *msg++ = Status;
// 661 msg = zdo_MT_CopyRevExtAddr( msg, IEEEAddr );
// 662
// 663 if ( type == SPI_CB_ZDO_NWK_ADDR_RSP )
// 664 {
// 665 *msg++ = HI_UINT16( nwkAddr );
// 666 *msg++ = LO_UINT16( nwkAddr );
// 667 }
// 668
// 669 *msg++ = NumAssocDev;
// 670 *msg++ = StartIndex;
// 671 byte cnt = NumAssocDev - StartIndex;
// 672
// 673 for ( x = 0; x < 8; x++ )
// 674 {
// 675 if ( x < cnt )
// 676 {
// 677 *msg++ = HI_UINT16( *AssocDevList );
// 678 *msg++ = LO_UINT16( *AssocDevList );
// 679 AssocDevList++;
// 680 }
// 681 else
// 682 {
// 683 *msg++ = 0;
// 684 *msg++ = 0;
// 685 }
// 686 }
// 687
// 688 MT_BuildAndSendZToolCB( type, len, pBuf );
// 689
// 690 osal_mem_free( pBuf );
// 691 }
// 692 }
// 693 #endif // ZDO_NWKADDR_REQUEST || ZDO_IEEEADDR_REQUEST
// 694
// 695 #if defined ( ZDO_NODEDESC_REQUEST )
// 696 /*********************************************************************
// 697 * @fn zdo_MTCB_NodeDescRspCB()
// 698 *
// 699 * @brief
// 700 *
// 701 * Called by ZDO when a Node_Desc_rsp message is received.
// 702 *
// 703 * @param SrcAddr - Source address
// 704 * @param Status - response status
// 705 * @param nwkAddr - 16 bit network address of device
// 706 * @param pNodeDesc - pointer to the devices Node Descriptor
// 707 * NULL if Status != ZDP_SUCCESS
// 708 *
// 709 * @return none
// 710 */
// 711 void zdo_MTCB_NodeDescRspCB( zAddrType_t *SrcAddr, byte Status, uint16 nwkAddr,
// 712 NodeDescriptorFormat_t *pNodeDesc )
// 713 {
// 714 byte buf[18];
// 715 byte *msg;
// 716
// 717 msg = buf;
// 718
// 719 //Fill up the data bytes
// 720 *msg++ = Status;
// 721 *msg++ = HI_UINT16( SrcAddr->addr.shortAddr );
// 722 *msg++ = LO_UINT16( SrcAddr->addr.shortAddr );
// 723
// 724 *msg++ = HI_UINT16( nwkAddr );
// 725 *msg++ = LO_UINT16( nwkAddr );
// 726
// 727 *msg++ = (byte)(pNodeDesc->LogicalType);
// 728
// 729 // Since Z-Tool can't treat V1.0 and V1.1 differently,
// 730 // we just output these two byte in both cases, although
// 731 // in V1.0, they are always zeros.
// 732 *msg++ = (byte) pNodeDesc->ComplexDescAvail;
// 733 *msg++ = (byte) pNodeDesc->UserDescAvail;
// 734
// 735 *msg++ = pNodeDesc->APSFlags;
// 736 *msg++ = pNodeDesc->FrequencyBand;
// 737 *msg++ = pNodeDesc->CapabilityFlags;
// 738 *msg++ = pNodeDesc->ManufacturerCode[1];
// 739 *msg++ = pNodeDesc->ManufacturerCode[0];
// 740 *msg++ = pNodeDesc->MaxBufferSize;
// 741 *msg++ = pNodeDesc->MaxTransferSize[1];
// 742 *msg++ = pNodeDesc->MaxTransferSize[0];
// 743 *msg++ = HI_UINT16( pNodeDesc->ServerMask);
// 744 *msg++ = LO_UINT16( pNodeDesc->ServerMask);
// 745
// 746 MT_BuildAndSendZToolCB( SPI_CB_ZDO_NODE_DESC_RSP, 18, buf );
// 747 }
// 748 #endif // ZDO_NODEDESC_REQUEST
// 749
// 750 #if defined ( ZDO_POWERDESC_REQUEST )
// 751 /*********************************************************************
// 752 * @fn zdo_MTCB_PowerDescRspCB()
// 753 *
// 754 * @brief
// 755 *
// 756 * Called by ZDO when a Power_Desc_rsp message is received.
// 757 *
// 758 * @param SrcAddr - Source address
// 759 * @param Status - response status
// 760 * @param nwkAddr - 16 bit network address of device
// 761 * @param pPwrDesc - pointer to the devices Power Descriptor
// 762 * NULL if Status != ZDP_SUCCESS
// 763 *
// 764 * @return none
// 765 */
// 766 void zdo_MTCB_PowerDescRspCB( zAddrType_t *SrcAddr, byte Status,
// 767 uint16 nwkAddr, NodePowerDescriptorFormat_t *pPwrDesc )
// 768 {
// 769 byte buf[9];
// 770 byte *msg;
// 771
// 772 msg = buf;
// 773
// 774 //Fill up the data bytes
// 775 *msg++ = Status;
// 776 *msg++ = HI_UINT16( SrcAddr->addr.shortAddr );
// 777 *msg++ = LO_UINT16( SrcAddr->addr.shortAddr );
// 778 *msg++ = HI_UINT16( nwkAddr );
// 779 *msg++ = LO_UINT16( nwkAddr );
// 780
// 781 *msg++ = pPwrDesc->PowerMode;
// 782 *msg++ = pPwrDesc->AvailablePowerSources;
// 783 *msg++ = pPwrDesc->CurrentPowerSource;
// 784 *msg = pPwrDesc->CurrentPowerSourceLevel;
// 785
// 786 MT_BuildAndSendZToolCB( SPI_CB_ZDO_POWER_DESC_RSP, 9, buf );
// 787 }
// 788 #endif // ZDO_POWERDESC_REQUEST
// 789
// 790 #if defined ( ZDO_SIMPLEDESC_REQUEST )
// 791 #define ZDO_SIMPLE_DESC_CB_LEN 78
// 792 /*********************************************************************
// 793 * @fn zdo_MTCB_SimpleDescRspCB()
// 794 *
// 795 * @brief
// 796 *
// 797 * Called by ZDO when a Simple_Desc_rsp message is received.
// 798 *
// 799 * @param SrcAddr - Source address
// 800 * @param Status - response status
// 801 * @param nwkAddr - 16 bit network address of device
// 802 * @param EPIntf - Endpoint/Interface for description
// 803 * @param pSimpleDesc - pointer to the devices Simple Descriptor
// 804 * NULL if Status != ZDP_SUCCESS
// 805 *
// 806 * @return none
// 807 */
// 808 void zdo_MTCB_SimpleDescRspCB( zAddrType_t *SrcAddr, byte Status,
// 809 uint16 nwkAddr, byte EPIntf, SimpleDescriptionFormat_t *pSimpleDesc )
// 810 {
// 811 byte *msgPtr;
// 812 byte *msg;
// 813 byte x;
// 814
// 815 msgPtr = osal_mem_alloc( ZDO_SIMPLE_DESC_CB_LEN );
// 816 if ( msgPtr )
// 817 {
// 818 msg = msgPtr;
// 819
// 820 //Fill up the data bytes
// 821 *msg++ = Status;
// 822 *msg++ = HI_UINT16( SrcAddr->addr.shortAddr );
// 823 *msg++ = LO_UINT16( SrcAddr->addr.shortAddr );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -