📄 mtel.s51
字号:
// 541 // Get a message buffer to build the debug message
// 542 msg_ptr = osal_mem_alloc( (byte)(SPI_0DATA_MSG_LEN + dstr->sln) );
// 543 if ( msg_ptr )
// 544 {
// 545 #ifdef SPI_MGR_DEFAULT_PORT
// 546 MT_BuildSPIMsg( SPI_RESPONSE_BIT | SPI_SYS_STRING_MSG, msg_ptr, dstr->sln, dstr->pString );
// 547 HalUARTWrite ( SPI_MGR_DEFAULT_PORT, msg_ptr, SPI_0DATA_MSG_LEN + dstr->sln );
// 548 #endif
// 549 osal_mem_free( msg_ptr );
// 550 }
// 551 }
// 552 #endif // ZTOOL
// 553
// 554 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
// 555 /*********************************************************************
// 556 * @fn MT_ProcessSetNV
// 557 *
// 558 * @brief
// 559 *
// 560 * The Set NV serial message.
// 561 *
// 562 * @param byte *msg - pointer to the data
// 563 *
// 564 * @return ZSuccess if successful
// 565 *
// 566 * @MT SPI_CMD_SYS_SET_NV
// 567 */
// 568 byte MT_ProcessSetNV( byte *pData )
// 569 {
// 570 uint16 attrib;
// 571 uint16 attlen;
// 572
// 573 attrib = (uint16) *pData++;
// 574 attlen = osal_nv_item_len( attrib );
// 575
// 576 return osal_nv_write( attrib, 0, attlen, pData );
// 577 }
// 578 #endif
// 579
// 580 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
// 581 /*********************************************************************
// 582 * @fn MT_ProcessGetNV
// 583 *
// 584 * @brief
// 585 *
// 586 * The Get NV serial message.
// 587 *
// 588 * @param byte *msg - pointer to the data
// 589 *
// 590 * @return void
// 591 *
// 592 * @MT SPI_CMD_SYS_GET_NV
// 593 *
// 594 */
// 595 void MT_ProcessGetNV( byte *pData )
// 596 {
// 597 uint16 attrib;
// 598 uint16 attlen;
// 599 uint16 buflen;
// 600 uint8 *buf;
// 601
// 602 attrib = (uint16)*pData;
// 603 attlen = osal_nv_item_len( attrib );
// 604
// 605 buflen = attlen + 2;
// 606 buf = osal_mem_alloc( buflen );
// 607 if ( buf != NULL )
// 608 {
// 609 osal_memset( buf, 0, buflen );
// 610
// 611 buf[0] = osal_nv_read( attrib, 0, attlen, &buf[2] );
// 612 buf[1] = (uint8)attrib;
// 613
// 614 MT_BuildAndSendZToolResponse( (SPI_0DATA_MSG_LEN + buflen),
// 615 (SPI_RESPONSE_BIT | SPI_CMD_SYS_GET_NV),
// 616 buflen, buf );
// 617 osal_mem_free( buf );
// 618 }
// 619 }
// 620 #endif
// 621
// 622 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
// 623 #if !defined ( NONWK )
// 624 /***************************************************************************************************
// 625 * @fn MT_ProcessGetNvInfo
// 626 *
// 627 * @brief
// 628 *
// 629 * The Get NV Info serial message.
// 630 *
// 631 * @param byte *msg - pointer to the data
// 632 *
// 633 * @return void
// 634 *
// 635 * @MT SPI_CMD_SYS_GET_NV_INFO
// 636 *
// 637 ***************************************************************************************************/
// 638 void MT_ProcessGetNvInfo( void )
// 639 {
// 640 uint8 len;
// 641 uint8 stat;
// 642 uint8 *buf;
// 643 uint8 *pBuf;
// 644 uint16 tmp16;
// 645 uint32 tmp32;
// 646
// 647 // Get required length of buffer
// 648 // Status + ExtAddr + ChanList + PanID + SecLevel + PreCfgKey
// 649 len = 1 + Z_EXTADDR_LEN + 4 + 2 + 1 + SEC_KEY_LEN;
// 650
// 651 buf = osal_mem_alloc( len );
// 652 if ( buf )
// 653 {
// 654 // Assume NV not available
// 655 osal_memset( buf, 0xFF, len );
// 656
// 657 // Skip over status
// 658 pBuf = buf + 1;
// 659
// 660 // Start with 64-bit extended address
// 661 stat = osal_nv_read( ZCD_NV_EXTADDR, 0, Z_EXTADDR_LEN, pBuf );
// 662 if ( stat ) stat = 0x01;
// 663 MT_ReverseBytes( pBuf, Z_EXTADDR_LEN );
// 664 pBuf += Z_EXTADDR_LEN;
// 665
// 666 // Scan channel list (bit mask)
// 667 if ( osal_nv_read( ZCD_NV_CHANLIST, 0, sizeof( tmp32 ), &tmp32 ) )
// 668 stat |= 0x02;
// 669 else
// 670 {
// 671 pBuf[0] = BREAK_UINT32( tmp32, 3 );
// 672 pBuf[1] = BREAK_UINT32( tmp32, 2 );
// 673 pBuf[2] = BREAK_UINT32( tmp32, 1 );
// 674 pBuf[3] = BREAK_UINT32( tmp32, 0 );
// 675 }
// 676 pBuf += sizeof( tmp32 );
// 677
// 678 // ZigBee PanID
// 679 if ( osal_nv_read( ZCD_NV_PANID, 0, sizeof( tmp16 ), &tmp16 ) )
// 680 stat |= 0x04;
// 681 else
// 682 {
// 683 pBuf[0] = HI_UINT16( tmp16 );
// 684 pBuf[1] = LO_UINT16( tmp16 );
// 685 }
// 686 pBuf += sizeof( tmp16 );
// 687
// 688 // Security level
// 689 if ( osal_nv_read( ZCD_NV_SECURITY_LEVEL, 0, sizeof( uint8 ), pBuf++ ) )
// 690 stat |= 0x08;
// 691
// 692 // Pre-configured security key
// 693 if ( osal_nv_read( ZCD_NV_PRECFGKEY, 0, SEC_KEY_LEN, pBuf ) )
// 694 stat |= 0x10;
// 695
// 696 // Status bit mask - bit=1 indicates failure
// 697 *buf = stat;
// 698
// 699 MT_BuildAndSendZToolResponse( (SPI_0DATA_MSG_LEN + len),
// 700 (SPI_RESPONSE_BIT | SPI_CMD_SYS_GET_NV_INFO),
// 701 len, buf );
// 702
// 703 osal_mem_free( buf );
// 704 }
// 705 }
// 706 #endif // NONWK
// 707 #endif // ZTOOL
// 708
// 709 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
// 710 #define DEVICE_INFO_RESPONSE_LEN 46
// 711 #define TYPE_COORDINATOR 1
// 712 #define TYPE_ROUTER 2
// 713 #define TYPE_ENDDEVICE 4
// 714 /***************************************************************************************************
// 715 * @fn MT_ProcessGetDeviceInfo
// 716 *
// 717 * @brief
// 718 *
// 719 * The Get Device Info serial message.
// 720 *
// 721 * @param byte *msg - pointer to the data
// 722 *
// 723 * @return void
// 724 ***************************************************************************************************/
// 725 void MT_ProcessGetDeviceInfo( void )
// 726 {
// 727 byte *buf;
// 728 byte *pBuf;
// 729 uint8 deviceType = 0;
// 730 uint16 shortAddr;
// 731 uint16 *assocList;
// 732 byte assocCnt;
// 733 uint16 *puint16;
// 734 byte x;
// 735
// 736 buf = osal_mem_alloc( DEVICE_INFO_RESPONSE_LEN );
// 737 if ( buf )
// 738 {
// 739 pBuf = buf;
// 740
// 741 *pBuf++ = ZSUCCESS;
// 742
// 743 osal_nv_read( ZCD_NV_EXTADDR, 0, Z_EXTADDR_LEN, pBuf );
// 744 // Outgoing extended address needs to be reversed
// 745 MT_ReverseBytes( pBuf, Z_EXTADDR_LEN );
// 746 pBuf += Z_EXTADDR_LEN;
// 747
// 748 #if !defined( NONWK )
// 749 shortAddr = NLME_GetShortAddr();
// 750 #else
// 751 shortAddr = 0;
// 752 #endif
// 753
// 754 *pBuf++ = HI_UINT16( shortAddr );
// 755 *pBuf++ = LO_UINT16( shortAddr );
// 756
// 757 // Return device type
// 758 #if !defined( NONWK )
// 759 #if defined (ZDO_COORDINATOR)
// 760 deviceType |= (uint8) TYPE_COORDINATOR;
// 761 #if defined (SOFT_START)
// 762 deviceType |= (uint8) TYPE_ROUTER;
// 763 #endif
// 764 #endif
// 765 #if defined (RTR_NWK) && !defined (ZDO_COORDINATOR)
// 766 deviceType |= (uint8) TYPE_ROUTER;
// 767 #elif !defined (RTR_NWK)
// 768 deviceType |= (uint8) TYPE_ENDDEVICE;
// 769 #endif
// 770 #endif
// 771 *pBuf++ = (byte) deviceType;
// 772
// 773 //Return device state
// 774 #if !defined( NONWK )
// 775 *pBuf++ = (byte)devState;
// 776 #else
// 777 *pBuf++ = (byte)0;
// 778 #endif
// 779
// 780 #if defined(RTR_NWK) && !defined( NONWK )
// 781 assocList = AssocMakeList( &assocCnt );
// 782 #else
// 783 assocCnt = 0;
// 784 assocList = NULL;
// 785 #endif
// 786
// 787 *pBuf++ = assocCnt;
// 788
// 789 // upto 16 devices
// 790 osal_memset( pBuf, 0, (16 * sizeof(uint16)) );
// 791 puint16 = assocList;
// 792 for ( x = 0; x < assocCnt; x++ )
// 793 {
// 794 *pBuf++ = HI_UINT16( *puint16 );
// 795 *pBuf++ = LO_UINT16( *puint16 );
// 796 puint16++;
// 797 }
// 798
// 799 if ( assocList )
// 800 osal_mem_free( assocList );
// 801
// 802 MT_BuildAndSendZToolResponse( (SPI_0DATA_MSG_LEN + DEVICE_INFO_RESPONSE_LEN),
// 803 (SPI_RESPONSE_BIT | SPI_CMD_SYS_GET_DEVICE_INFO),
// 804 DEVICE_INFO_RESPONSE_LEN, buf );
// 805
// 806 osal_mem_free( buf );
// 807 }
// 808 }
// 809 #endif
// 810
// 811 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
// 812 /***************************************************************************************************
// 813 * @fn MT_ProcessSerialCommand
// 814 *
// 815 * @brief
// 816 *
// 817 * Process Serial Message.
// 818 *
// 819 * @param byte *msg - pointer to event message
// 820 *
// 821 * @return void
// 822 ***************************************************************************************************/
// 823 void MT_ProcessSerialCommand( byte *msg )
// 824 {
// 825 UINT16 cmd;
// 826 UINT16 callbackID;
// 827 byte len;
// 828 byte ret;
// 829 byte *pData;
// 830 uint16 tmp16;
// 831 uint32 tmp32;
// 832 byte extAddr[Z_EXTADDR_LEN];
// 833 byte *retValue;
// 834 byte x = 0;
// 835 #if !defined ( NONWK )
// 836 uint16 attLen;
// 837 #endif // NONWK
// 838
// 839 // dig out header info
// 840 cmd = BUILD_UINT16( msg[1], msg[0] );
// 841 save_cmd = cmd;
// 842 len = msg[2];
// 843 pData = &msg[3];
// 844
// 845 // Setup for return;
// 846 len = 0;
// 847 retValue = &ret;
// 848
// 849 //Process the contents of the message
// 850 switch ( cmd )
// 851 {
// 852 #ifdef MACSIM
// 853 case SPI_CMD_ZIGNET_DATA:
// 854 MACSIM_TranslateMsg( pData, len );
// 855 break;
// 856 #endif
// 857
// 858 case SPI_CMD_SYS_RAM_READ:
// 859 extAddr[0] = MT_RAMRead( (UINT16)BUILD_UINT16( pData[1], pData[0] ), &extAddr[1] );
// 860 len = MT_RAM_READ_RESP_LEN;
// 861 retValue = extAddr;
// 862 break;
// 863
// 864 case SPI_CMD_SYS_RAM_WRITE:
// 865 ret = MT_RAMWrite( (UINT16)BUILD_UINT16( pData[1], pData[0] ), pData[2] );
// 866 len = MT_RAM_WRITE_RESP_LEN;
// 867 break;
// 868
// 869 case SPI_CMD_SYS_SET_DEBUG_THRESHOLD:
// 870 ret = MT_SetDebugThreshold( pData[0], pData[1] );
// 871 len = 1;
// 872 break;
// 873
// 874 case SPI_CMD_TRACE_SUB:
// 875 break;
// 876
// 877 case SPI_CMD_SYS_RESET:
// 878 MT_Reset( pData[0] );
// 879 break;
// 880
// 881 case SPI_CMD_SYS_CALLBACK_SUB_CMD:
// 882 // a callback value of 0xFFFF turns on all available callbacks
// 883 callbackID = BUILD_UINT16( pData[1] , pData[0] );
// 884 if ( callbackID == 0xFFFF )
// 885 {
// 886 // What is the action
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -