/* * Application's entry point */ int main() { _u8 input[MAX_BUF_SIZE] = {0}; UserIn User = {0}; _i32 flag = 1; _i32 first = 0; _i32 retVal=-1; _i8 *pConfig = NULL; retVal = initializeAppVariables(); ASSERT_ON_ERROR(retVal); #ifdef SL_IF_TYPE_UART params.BaudRate = 115200; params.FlowControlEnable = 1; params.CommPort = COMM_PORT_NUM; pConfig = (_i8 *)¶ms; #endif /* SL_IF_TYPE_UART */ /* This line is for Eclipse CDT only due to a known bug in console buffering * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=173732 */ setvbuf(stdout, NULL, _IONBF, 0); displayBanner(); /* * Following function configures the device to default state by cleaning * the persistent settings stored in NVMEM (viz. connection profiles & * policies, power policy etc) * * Applications may choose to skip this step if the developer is sure * that the device is in its default state at start of application * * Note that all profiles and persistent settings that were done on the * device will be lost */ retVal = configureSimpleLinkToDefaultState(pConfig); if(retVal < 0) { printf(" Failed to configure the device in its default state, Error code: %ld\r\n",retVal); LOOP_FOREVER(); } printf("Device is configured in default state \r\n"); /* * Asumption is that the device is configured in station mode already * and it is in its default state */ retVal = sl_Start(0, pConfig, 0); if ((retVal < 0) || (ROLE_STA != retVal) ) { printf(" Failed to start the device, Error code: %ld\r\n",retVal); LOOP_FOREVER(); } printf("Device started as STATION \r\n"); while(flag) { User = UserInput(); switch(User.choice) { case 1: retVal = TxContinues(User.channel, RATE_11M, User.packets, 100); if(retVal < 0) { printf("Failed to send the packet over phy, Error code: %ld",retVal); LOOP_FOREVER(); } break; case 2: retVal = RxStatisticsCollect(User.channel); if(retVal < 0) { printf("Failed to collect statics, Error code: %ld",retVal); LOOP_FOREVER(); } break; } printf("\nEnter \"1\" to restart or \"0\" to quit: \n"); fgets((char *)input, sizeof(input), stdin); printf("\n"); flag = atoi((const char *)input); first = 1; } return SUCCESS; }
int main() { UserIn User; int iFlag = 1; long lRetVal = -1; char cChar; unsigned char policyVal; // // Initialize Board configuration // BoardInit(); // // //Pin muxing // PinMuxConfig(); // Configuring UART // InitTerm(); DisplayBanner(APPLICATION_NAME); InitializeAppVariables(); // // Following function configure the device to default state by cleaning // the persistent settings stored in NVMEM (viz. connection profiles & // policies, power policy etc) // // Applications may choose to skip this step if the developer is sure // that the device is in its default state at start of applicaton // // Note that all profiles and persistent settings that were done on the // device will be lost // lRetVal = ConfigureSimpleLinkToDefaultState(); if(lRetVal < 0) { if (DEVICE_NOT_IN_STATION_MODE == lRetVal) UART_PRINT("Failed to configure the device in its default state \n\r"); LOOP_FOREVER(); } UART_PRINT("Device is configured in default state \n\r"); CLR_STATUS_BIT_ALL(g_ulStatus); // // Assumption is that the device is configured in station mode already // and it is in its default state // lRetVal = sl_Start(0, 0, 0); if (lRetVal < 0 || ROLE_STA != lRetVal) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER(); } UART_PRINT("Device started as STATION \n\r"); // // reset all network policies // lRetVal = sl_WlanPolicySet( SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(0,0,0,0,0), &policyVal, 1 /*PolicyValLen*/); if (lRetVal < 0) { UART_PRINT("Failed to set policy \n\r"); LOOP_FOREVER(); } while (iFlag) { User = UserInput(); switch(User.choice) { case(1): /*******An example of Tx continuous on user selected channel, rate 11, * user selected number of packets, minimal delay between packets*******/ lRetVal = Tx_continuous(User.channel,User.rate,User.packets, \ User.Txpower,0); if(lRetVal < 0) { UART_PRINT("Error during transmission of raw data\n\r"); LOOP_FOREVER(); } break; case(2): /******An example of Rx statistics using user selected channel *******/ lRetVal = RxStatisticsCollect(); if(lRetVal < 0) { UART_PRINT("Error while collecting statistics data\n\r"); LOOP_FOREVER(); } break; } UART_PRINT("\n\rEnter \"1\" to restart or \"0\" to quit: "); // // Wait to receive a character over UART // cChar = MAP_UARTCharGet(CONSOLE); // // Echo the received character // MAP_UARTCharPut(CONSOLE, cChar); UART_PRINT("\n\r"); iFlag = atoi(&cChar); } UART_PRINT("\r\nEnding the application...."); // // power off network processor // lRetVal = sl_Stop(SL_STOP_TIMEOUT); LOOP_FOREVER(); }