Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LoRaWAN-lib SX1272Lib lib_gps lib_mma8451q lib_mpl3115a2 mbed
Fork of LoRaWAN-NAMote72-Application-Demo_Multitech by
ComplianceTest.cpp
00001 /* 00002 / _____) _ | | 00003 ( (____ _____ ____ _| |_ _____ ____| |__ 00004 \____ \| ___ | (_ _) ___ |/ ___) _ \ 00005 _____) ) ____| | | || |_| ____( (___| | | | 00006 (______/|_____)_|_|_| \__)_____)\____)_| |_| 00007 (C)2015 Semtech 00008 00009 Description: Compliance Test for LoRaWAN End-Device 00010 00011 License: Revised BSD License, see LICENSE.TXT file include in the project 00012 00013 Maintainer: Uttam Bhat 00014 */ 00015 00016 #include "ComplianceTest.h" 00017 00018 00019 void PrepareComplianceTestFrame( McpsIndication_t *McpsIndication ) 00020 { 00021 uint8_t *pData; 00022 00023 pData = &McpsIndication->Buffer[0]; 00024 00025 if( ComplianceTest.Running == false ) 00026 { 00027 // Check compliance test enable command (i) 00028 if( ( McpsIndication->BufferSize == 4 ) && 00029 ( pData[0] == 0x01 ) && ( pData[1] == 0x01 ) && ( pData[2] == 0x01 ) && (pData[3] == 0x01 ) ) 00030 { 00031 AppPort = 224; 00032 AppDataSize = 2; 00033 ComplianceTest.DownLinkCounter = 0; 00034 ComplianceTest.LinkCheck = false; 00035 ComplianceTest.DemodMargin = 0; 00036 ComplianceTest.NbGateways = 0; 00037 ComplianceTest.Running = true; 00038 ComplianceTest.State = 1; 00039 } 00040 } 00041 else 00042 { 00043 ComplianceTest.State = pData[0]; 00044 switch( ComplianceTest.State ) 00045 { 00046 case 0: // Check compliance test disable command (ii) 00047 IsTxConfirmed = LORAWAN_CONFIRMED_MSG_ON; 00048 AppPort = LORAWAN_APP_PORT; 00049 AppDataSize = LORAWAN_APP_DATA_SIZE; 00050 ComplianceTest.DownLinkCounter = 0; 00051 ComplianceTest.Running = false; 00052 00053 MibRequestConfirm_t mibReq; 00054 mibReq.Type = MIB_ADR; 00055 mibReq.Param.AdrEnable = LORAWAN_ADR_ON; 00056 LoRaMacMibSetRequestConfirm( &mibReq ); 00057 break; 00058 case 1: // (iii, iv) 00059 AppDataSize = 2; 00060 break; 00061 case 2: // Enable confirmed messages (v) 00062 IsTxConfirmed = true; 00063 ComplianceTest.State = 1; 00064 break; 00065 case 3: // Disable confirmed messages (vi) 00066 IsTxConfirmed = false; 00067 ComplianceTest.State = 1; 00068 break; 00069 case 4: // (vii) 00070 AppDataSize = McpsIndication->BufferSize; 00071 00072 AppData[0] = 4; 00073 for( uint8_t i = 1; i < AppDataSize; i++ ) 00074 { 00075 AppData[i] = McpsIndication->Buffer[i] + 1; 00076 } 00077 break; 00078 case 5: // (viii) 00079 { 00080 MlmeReq_t mlmeReq; 00081 mlmeReq.Type = MLME_LINK_CHECK; 00082 LoRaMacMlmeRequest( &mlmeReq ); 00083 } 00084 break; 00085 default: 00086 break; 00087 } 00088 } 00089 } 00090 00091 void RunComplianceTest( void ) 00092 { 00093 if( ComplianceTest.LinkCheck == true ) 00094 { 00095 ComplianceTest.LinkCheck = false; 00096 AppDataSize = 3; 00097 AppData[0] = 5; 00098 AppData[1] = ComplianceTest.DemodMargin; 00099 AppData[2] = ComplianceTest.NbGateways; 00100 ComplianceTest.State = 1; 00101 } 00102 else 00103 { 00104 switch( ComplianceTest.State ) 00105 { 00106 case 1: 00107 AppDataSize = 2; 00108 AppData[0] = ComplianceTest.DownLinkCounter >> 8; 00109 AppData[1] = ComplianceTest.DownLinkCounter; 00110 break; 00111 00112 case 4: 00113 ComplianceTest.State = 1; 00114 break; 00115 } 00116 } 00117 }
Generated on Thu Jul 28 2022 06:45:12 by
1.7.2
