int main() { long lRetVal = -1; val=0; BoardInit(); PinMuxConfig(); LedInit(); //create OS tasks lRetVal = osi_TaskCreate(PushButtonHandler, (signed char*) "PushButtonHandler", OSI_STACK_SIZE, NULL, 2, &g_PushButtonTask); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } lRetVal = osi_TaskCreate(MainLoop, (signed char*)"MainLoop", OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } osi_start(); for(;;) { } return 0; }
static void Init() { long lRetVal = -1; BoardInit(); UDMAInit(); PinMuxConfig(); InitTerm(); 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() ; } // // Asumption 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) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER() ; } UART_PRINT("Connecting to AP: '%s'...\r\n", SSID_NAME); // Connecting to WLAN AP - Set with static parameters defined at common.h // After this call we will be connected and have IP address lRetVal = WlanConnect(); if (lRetVal < 0) { UART_PRINT("Connection to AP failed \n\r"); LOOP_FOREVER() ; } UART_PRINT("Connected to AP: '%s' \n\r", SSID_NAME); #ifdef NEW_ID iobeam_Reset(); #endif }
int main(void) { // init the hardware initBoard(); UART_PRINT("[Blink] Start application\r\n"); // create the main application message queue // this call properly enables the OSI scheduler to function short status = osi_MsgQCreate(&g_ApplicationMessageQueue, "ApplicationMessageQueue", sizeof(ApplicationMessage), 1); if (status < 0) { UART_PRINT("[Blink] Create application message queue error\r\n"); ERR_PRINT(status); LOOP_FOREVER(); } // start the main application task // this is necessary because SimpleLink host driver is started by sl_Start(), // which cannot be called on before the OSI scheduler is started status = osi_TaskCreate(startApplication, (signed char *)"Blink", OSI_STACK_SIZE, NULL, OOB_TASK_PRIORITY, NULL); if (status < 0) { UART_PRINT("[Blink] Start application error\r\n"); ERR_PRINT(status); LOOP_FOREVER(); } // start the OSI scheduler osi_start(); return 0; }
tDSPInstance* DSPCeateInstance(uint32_t signalSize, uint32_t Fs) { tDSPInstance* tempInstance; tempInstance = (tDSPInstance*)malloc(sizeof(tDSPInstance)); if (tempInstance == NULL){ UART_PRINT("DSPCreate malloc error!"); LOOP_FOREVER(); //malloc error. heap too small? return NULL; } tempInstance->signalSize = signalSize; tempInstance->Fs = Fs; tempInstance->ucpSignal = (unsigned char*)malloc(sizeof(unsigned char)*signalSize); tempInstance->fpSignal = (float32_t*)malloc(sizeof(float32_t)*signalSize/2); tempInstance->fftSize = signalSize / 4; tempInstance->FFTResults = (float32_t*)malloc(sizeof(float32_t)*tempInstance->fftSize); if (tempInstance->ucpSignal==NULL || \ tempInstance->fpSignal==NULL || \ tempInstance->FFTResults==NULL) { UART_PRINT("DSPCreate malloc error!"); LOOP_FOREVER(); //malloc error. heap too small? return NULL; } tempInstance->maxEnergyBinIndex = 0; tempInstance->maxEnergyBinValue = 0; return tempInstance; }
int main() { /* * Preparation */ // Board Initialization BoardInit(); // Configuring UART InitTerm(); // Connect to AP // Put your SSID and password in common.h long lRetVal = ConnectToAP(); if(lRetVal < 0) { UART_PRINT("Connection to AP failed\n\r"); LOOP_FOREVER(); } UART_PRINT("Connected to AP\n\r"); if(lRetVal < 0) { LOOP_FOREVER(); } // Declare thing Thing_Struct thing; // Connect to thethingsiO server lRetVal = ConnectTo_thethingsiO(&thing.thing_client); if(lRetVal < 0) { LOOP_FOREVER(); } UART_PRINT("Thing client connected\n\r"); // In order to initialize the thing correctly you have to use one of // following two methods: // 1. If you have already activated your thing you should set the token thing.token = "YOUR TOKEN HERE"; // 2. Or if not copy the provided activation code here // and uncomment the following line // char *act_code = "YOUR ACTIVATION CODE HERE"; // and activate the thing (uncomment the following line) // char *token = thing_activate(&thing, act_code); /* Intializes random number generator */ // time_t t; // srand((unsigned) time(&t)); while(1) { char *sub = thing_subscribe(&thing); if (strlen(sub) > 0) { UART_PRINT(sub); UART_PRINT("\n\r"); } // Free memory free(sub); } }
//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Invokes the SLHost task //! 2. Invokes the GetNTPTimeTask //! //! \return None. // //**************************************************************************** void main() { long lRetVal = -1; // // Initialize Board configurations // BoardInit(); // // Enable and configure DMA // UDMAInit(); // // Pinmux for UART // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display Application Banner // DisplayBanner(APP_NAME); // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the GetNTPTime task // lRetVal = osi_TaskCreate(GetNTPTimeTask, (const signed char *)"Get NTP Time", OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
//**************************************************************************** // //! \brief Start simplelink, connect to the ap and run the ping test //! //! This function starts the simplelink, connect to the ap and start the ping //! test on the default gateway for the ap //! //! \param[in] pvParameters - Pointer to the list of parameters that //! can bepassed to the task while creating it //! //! \return None // //**************************************************************************** void WlanStationMode( void *pvParameters ) { long lRetVal = -1; 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"); // // 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"); // //Connecting to WLAN AP // lRetVal = WlanConnect(); if(lRetVal < 0) { UART_PRINT("Failed to establish connection w/ an AP \n\r"); LOOP_FOREVER(); } UART_PRINT("Connection established w/ AP and IP is aquired \n\r"); gizwits_main(); }
//**************************************************************************** // //! \brief Handles HTTP Server Task //! //! \param[in] pvParameters is the data passed to the Task //! //! \return None // //**************************************************************************** static void HTTPServerTask(void *pvParameters) { long lRetVal = -1; 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"); memset(g_ucSSID,'\0',AP_SSID_LEN_MAX); //Read Device Mode Configuration ReadDeviceConfiguration(); //Connect to Network lRetVal = ConnectToNetwork(); //Stop Internal HTTP Server lRetVal = sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } //Start Internal HTTP Server lRetVal = sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } //Handle Async Events while(1) { } }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** int main() { long lRetVal = -1; // // Board Initialization // BoardInit(); // // Enable and configure DMA // UDMAInit(); // // Pinmux for UART // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display Application Banner // DisplayBanner(APP_NAME); // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Receiving file // lRetVal = osi_TaskCreate(cmd_dispatcher, (const signed char *)"TFTP", OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); return 0; }
void initBoard() { #ifndef USE_TIRTOS #if defined(ccs) || defined(gcc) MAP_IntVTableBaseSet((unsigned long) &g_pfnVectors[0]); #endif #if defined(ewarm) MAP_IntVTableBaseSet((unsigned long)&__vector_table); #endif #endif MAP_IntMasterEnable(); MAP_IntEnable(FAULT_SYSTICK); PRCMCC3200MCUInit(); PinMuxConfig(); GPIO_IF_LedConfigure(LED1); GPIO_IF_LedOff(MCU_RED_LED_GPIO); InitTerm(); ClearTerm(); UART_PRINT("Blink - Parse for IoT sample application\r\n"); UART_PRINT("----------------------------------------\r\n"); UART_PRINT("\r\n"); UART_PRINT("[Blink] Board init\r\n"); // start the spawn task short status = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if (status < 0) { UART_PRINT("[Blink] Spawn task failed\r\n"); ERR_PRINT(status); LOOP_FOREVER(); } // initialize the I2C bus status = I2C_IF_Open(I2C_MASTER_MODE_FST); if (status < 0) { UART_PRINT("[Blink] I2C opening error\r\n"); ERR_PRINT(status); LOOP_FOREVER(); } UART_PRINT("[Blink] Device : TI SimpleLink CC3200\r\n"); #ifdef USE_TIRTOS UART_PRINT("[Blink] Operating system : TI-RTOS\r\n"); #endif #ifdef USE_FREERTOS UART_PRINT("[Blink] Operating system : FreeRTOS\r\n"); #endif #ifndef SL_PLATFORM_MULTI_THREADED UART_PRINT("[Blink] Operating system : None\r\n"); #endif }
int main(void) { long lRetVal = -1; // // initialize board configurations // BoardInit(); // // Pinmux GPIO for LEDs // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); #endif // // Configure LEDs // GPIO_IF_LedConfigure(LED1|LED2|LED3); GPIO_IF_LedOff(MCU_ALL_LED_IND); // // Simplelinkspawntask // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } lRetVal = osi_TaskCreate(XmppClient, (const signed char*)"XmppClient",\ OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } osi_start(); while(1) { } }
//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Invokes the SLHost task //! 2. Invokes the LPDSTCPServerTask //! //! \return None. // //**************************************************************************** void main() { long lRetVal = -1; // // Initialize the board // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); ClearTerm(); #endif // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the TCPServer task // lRetVal = osi_TaskCreate(TCPServerTask, (const signed char *)"DeepSleep TCP", OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
//***************************************************************************** // //! Main //! //! \param none //! //! This function //! 1. Invokes the SLHost task //! 2. Invokes the MqttClient //! //! \return None //! //***************************************************************************** void main() { long lRetVal = -1; // // Initialize the board configurations // BoardInit(); // // Pinmux for UART // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display Application Banner // DisplayBanner("MQTT_Client"); // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the MQTT Client task // osi_MsgQCreate(&g_PBQueue,"PBQueue",sizeof(event_msg),10); lRetVal = osi_TaskCreate(MqttClient, (const signed char *)"Mqtt Client App", OSI_STACK_SIZE, NULL, 2, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** void main(void) { int iRetVal; // // Board Initialisation // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Initialize the platform // platform_init(); // // Configuring UART // g_tUartHndl = uart_open(PRCM_UARTA0); // // Start the SimpleLink Host // iRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(iRetVal < 0) { UART_PRINT("could not create simplelink task\n\r"); LOOP_FOREVER(); } // // setting up timer and gpio as source for wake up from HIBERNATE // iRetVal = osi_TaskCreate(TimerGPIOTask, (const signed char *)"set wk_src for hibernate", OSI_STACK_SIZE, NULL, 1, NULL ); if(iRetVal < 0) { UART_PRINT("Task creation failed\n\r"); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
//***************************************************************************** // //! \brief Email Application Main Task - Initializes SimpleLink Driver //! and Handles UART Commands //! //! \param pvParameters - pointer to the task parameter //! //! \return void //! \note //! \warning // //***************************************************************************** static void SimpleEmail(void *pvParameters) { long lRetVal = -1; // Initialize Network Processor lRetVal = Network_IF_InitDriver(ROLE_STA); if(lRetVal < 0) { UART_PRINT("Failed to start SimpleLink Device\n\r"); LOOP_FOREVER(); } //Glow GreenLED to indicate successful initialization GPIO_IF_LedOn(MCU_ON_IND); //Set Default Parameters for Email lRetVal = SetDefaultParameters(); if(lRetVal < 0) { UART_PRINT("Failed to set default params for Email\r\n"); LOOP_FOREVER(); } //Initialize Push Botton Switch Button_IF_Init(SmartConfigInterruptHandler,SendEmailInterruptHandler); while(1) { UART_PRINT("Cmd#"); // // Get command from UART // memset(ucUARTBuffer,0,200); uiUartCmd=GetCmd(&ucUARTBuffer[0], 200); if(uiUartCmd) { // // Parse the command // lRetVal = UARTCommandHandler(ucUARTBuffer); if(lRetVal < 0) { UART_PRINT("Failed to parse the command.\r\n"); LOOP_FOREVER(); } } } }
//***************************************************************************** // //! This function gets triggered when HTTP Server receives Application //! defined GET and POST HTTP Tokens. //! //! \param pHttpServerEvent Pointer indicating http server event //! \param pHttpServerResponse Pointer indicating http server response //! //! \return None //! //***************************************************************************** void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *pSlHttpServerEvent, SlHttpServerResponse_t *pSlHttpServerResponse) { if((pSlHttpServerEvent == NULL) || (pSlHttpServerResponse == NULL)) { UART_PRINT("Null pointer\n\r"); LOOP_FOREVER(); } switch (pSlHttpServerEvent->Event) { case SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT: { if (0 == memcmp (pSlHttpServerEvent-> EventData.httpPostData.token_name.data, "__SL_P_U.C", pSlHttpServerEvent->EventData.httpPostData.token_name.len)) { if(0 == memcmp (pSlHttpServerEvent->EventData.httpPostData.token_value.data, \ "start", \ pSlHttpServerEvent->EventData.httpPostData.token_value.len)) { g_CaptureImage = 1; } else { g_CaptureImage = 0; } } } break; default: break; } }
//***************************************************************************** // //! Main //! //! \param none //! //! \return None //! //***************************************************************************** void main() { long lRetVal = -1; // // Initialize board configuration // BoardInit(); PinMuxConfig(); #ifndef NOTERM InitTerm(); #endif lRetVal = ssl(); if(lRetVal < 0) { ERR_PRINT(lRetVal); } // // power off network processor // sl_Stop(SL_STOP_TIMEOUT); LOOP_FOREVER(); }
//***************************************************************************** // //! \brief Starts Smart Configuration //! //! \param none //! //! \return void //! \note //! \warning //***************************************************************************** void SmartConfigTask(void* pValue) { long lRetVal = -1; DispatcherUartSendPacket((char*)pucUARTSmartConfigString, sizeof(pucUARTSmartConfigString)); //Turn off the Network Status LED GPIO_IF_LedOff(MCU_IP_ALLOC_IND); LedTimerConfigNStart(); //Reset the Network Status before Entering Smart Config Network_IF_UnsetMCUMachineState(STATUS_BIT_CONNECTION); Network_IF_UnsetMCUMachineState(STATUS_BIT_IP_AQUIRED); lRetVal = SmartConfigConnect(); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Wait until IP is acquired // while (!(IS_CONNECTED(Network_IF_CurrentMCUState())) || !(IS_IP_ACQUIRED(Network_IF_CurrentMCUState()))); LedTimerDeinitStop(); // Red LED on GPIO_IF_LedOn(MCU_IP_ALLOC_IND); //Enable GPIO Interrupt Button_IF_EnableInterrupt(SW2); }
//***************************************************************************** // //! This function handles socket events indication //! //! \param[in] pSock - Pointer to Socket Event Info //! //! \return None //! //***************************************************************************** void SimpleLinkSockEventHandler(SlSockEvent_t *pSock) { if(pSock == NULL) { UART_PRINT("Null pointer\n\r"); LOOP_FOREVER(); } // // This application doesn't work w/ socket - Events are not expected // switch( pSock->Event ) { case SL_SOCKET_TX_FAILED_EVENT: switch( pSock->socketAsyncEvent.SockTxFailData.status) { case SL_ECLOSE: UART_PRINT("[SOCK ERROR] - close socket (%d) operation " "failed to transmit all queued packets\n\n", pSock->socketAsyncEvent.SockTxFailData.sd); break; default: UART_PRINT("[SOCK ERROR] - TX FAILED : socket %d , reason " "(%d) \n\n", pSock->socketAsyncEvent.SockTxFailData.sd, pSock->socketAsyncEvent.SockTxFailData.status); break; } break; default: UART_PRINT("[SOCK EVENT] - Unexpected Event [%x0x]\n\n",pSock->Event); break; } }
//***************************************************************************** // //! Check the device mode and switch to P2P mode //! restart the NWP to activate P2P mode //! //! \param None //! //! \return status code - Success:0, Failure:-ve // //***************************************************************************** long StartDeviceInP2P() { long lRetVal = -1; // Reset CC3200 Network State Machine 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 application // // 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"); // // Assumption is that the device is configured in station mode already // and it is in its default state // lRetVal = sl_Start(NULL,NULL,NULL); ASSERT_ON_ERROR(lRetVal); if(lRetVal != ROLE_P2P) { lRetVal = sl_WlanSetMode(ROLE_P2P); ASSERT_ON_ERROR(lRetVal); lRetVal = sl_Stop(0xFF); // reset the Status bits CLR_STATUS_BIT_ALL(g_ulStatus); lRetVal = sl_Start(NULL,NULL,NULL); if(lRetVal < 0 || lRetVal != ROLE_P2P) { ASSERT_ON_ERROR(P2P_MODE_START_FAILED); } else { UART_PRINT("Started SimpleLink Device: P2P Mode\n\r"); return SUCCESS; } } return SUCCESS; }
//***************************************************************************** // //! Main //! //! \param none //! //! \return None //! //***************************************************************************** void main() { long lRetVal = -1; // // Initialize board configuration // BoardInit(); PinMuxConfig(); //Initialize GPIO interrupt GPIOIntInit(); //Initialize Systick interrupt SystickIntInit(); //Initialize Uart interrupt UART1IntInit(); //Initialize SPI SPIInit(); //Initalize Adafruit Adafruit_Init(); InitTerm(); //Connect the CC3200 to the local access point lRetVal = connectToAccessPoint(); //Set time so that encryption can be used lRetVal = set_time(); if(lRetVal < 0) { UART_PRINT("Unable to set time in the device"); LOOP_FOREVER(); } //Connect to the website with TLS encryption lRetVal = tls_connect(); if(lRetVal < 0) { ERR_PRINT(lRetVal); } //remote calls sendMessage() which calls http_post() which requires the return value from tls_connect() remote(lRetVal); //http_post(lRetVal); sl_Stop(SL_STOP_TIMEOUT); LOOP_FOREVER(); }
//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Invokes the SLHost task //! 2. Invokes the HIBUDPBroadcastTask //! //! \return None. // //**************************************************************************** void main() { long lRetVal = -1; // // Initialize board confifurations // BoardInit(); // // Pinmux for UART & LED // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); #endif // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the HIBUDPBroadcast task // lRetVal = osi_TaskCreate(HIBUDPBroadcastTask, (const signed char *)"HIB UDP Broadcast", OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
//***************************************************************************** // //! Network_IF_InitDriver //! The function initializes a CC3200 device and triggers it to start operation //! //! \param uiMode (device mode in which device will be configured) //! //! \return none // //***************************************************************************** void Network_IF_InitDriver(unsigned int uiMode) { long retVal = -1; // Reset CC3200 Network State Machine 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 application // // Note that all profiles and persistent settings that were done on the // device will be lost // retVal = ConfigureSimpleLinkToDefaultState(); if(retVal < 0) { if (DEVICE_NOT_IN_STATION_MODE == retVal) UART_PRINT("Failed to configure the device in its default state \n\r"); LOOP_FOREVER(__LINE__); } UART_PRINT("Device is configured in default state \n\r"); // // Assumption is that the device is configured in station mode already // and it is in its default state // retVal = sl_Start(NULL,NULL,NULL); if (retVal < 0 || retVal != uiMode) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER(__LINE__); } UART_PRINT("Started SimpleLink Device: STA Mode\n\r"); }
int main() { long lRetVal = -1; // // Board Initialization // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display banner // DisplayBanner(APP_NAME); InitializeAppVariables(); lRetVal = ServerFileDownload(); if(lRetVal < 0) { UART_PRINT("Server file download failed\n\r"); LOOP_FOREVER(); } else { UART_PRINT("Downloading File Completed\n\r"); } UART_PRINT("\nThank you\r\n"); // Stop the CC3200 device lRetVal = sl_Stop(SL_STOP_TIMEOUT); LOOP_FOREVER(); }
//***************************************************************************** // //! Network Task //! //! \param pvParameters - Parameters to the task's entry function //! //! \return None //! //***************************************************************************** void Network( void *pvParameters ) { long lRetVal = -1; //Initialize Global Variable InitializeAppVariables(); //Connect to Network lRetVal = ConnectToNetwork(); if(lRetVal < 0) { UART_PRINT("Failed to establish connection w/ an AP \n\r"); LOOP_FOREVER(); } //Cread UDP Socket and Bind to Local IP Address lRetVal = CreateUdpServer(&g_UdpSock); if(lRetVal < 0) { UART_PRINT("Failed to Create UDP Server \n\r"); LOOP_FOREVER(); } #ifdef MULTICAST //Add to Multicast Group lRetVal = ReceiveMulticastPacket(); if(lRetVal < 0) { UART_PRINT("Failed to Create UDP Server \n\r"); LOOP_FOREVER(); } //Delete the Networking Task as Service Discovery is not needed osi_TaskDelete(&g_NetworkTask); #else //Discover CC3200 Audio Devices mDNS_Task(); #endif }
//***************************************************************************** // //! This task will load two different libraries one by one and call //! common APIs having different implementation. //! //! \param pvParameters is the pointer to the the argument for the task //! //! \return none // //***************************************************************************** void Loader(void *pvParameters) { unsigned int uiNumOfLibs = 0; unsigned int uiCounter = 0; int first_num, second_num; first_num = 40; second_num = 10; // Start SimpleLink device to access file System if(sl_Start(NULL, NULL, NULL) < 0) { LOOP_FOREVER(); } uiNumOfLibs = sizeof(libraries)/sizeof(libraries[0]); while(uiCounter < uiNumOfLibs) { UART_PRINT("Loading library %u.. ",uiCounter+1); if(load_library(libraries[uiCounter]) < 0) { UART_PRINT("could not load the library\n\r"); LOOP_FOREVER(); } /* calling common API for both the libraries */ gp_ftable->p_display((char *) libraries[uiCounter]); UART_PRINT("Library loaded successfully\n\r"); UART_PRINT("Calling common APIs..\n\r"); UART_PRINT("AddNums(%u, %u): %d \n\r", first_num, second_num, gp_ftable->p_add(first_num, second_num)); UART_PRINT("SubNums(%u, %u): %d \n\r", first_num, second_num, gp_ftable->p_sub(first_num, second_num)); UART_PRINT("\n\r"); uiCounter++; } UART_PRINT("Application Tested Successfully\n\r"); UART_PRINT("Exiting Application\n\r"); LOOP_FOREVER(); }
int main() { long lRetVal = -1; // // Initialize Board configurations // BoardInit(); // // Configuring UART // #ifndef NOTERM InitTerm(); #endif //NOTERM // // Simplelinkspawntask // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Create 'CameraService' task // lRetVal = osi_TaskCreate(CameraService,(signed char *) "CameraService", OSI_STACK_SIZE, NULL, 1, NULL); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } osi_start(); return 0; }
//***************************************************************************** // //! Speaker Routine //! //! \param pvParameters Parameters to the task's entry function //! //! \return None // //***************************************************************************** void Speaker( void *pvParameters ) { long iRetVal = -1; while(1) { while(g_ucSpkrStartFlag || g_loopback) { if(!g_loopback) { fd_set readfds,writefds; struct SlTimeval_t tv; FD_ZERO(&readfds); FD_ZERO(&writefds); FD_SET(g_UdpSock.iSockDesc,&readfds); FD_SET(g_UdpSock.iSockDesc,&writefds); tv.tv_sec = 0; tv.tv_usec = 2000000; int rv = select(g_UdpSock.iSockDesc, &readfds, NULL, NULL, &tv); if(rv <= 0) { continue; } if (FD_ISSET(g_UdpSock.iSockDesc, &readfds) ) { g_iRetVal = recvfrom(g_UdpSock.iSockDesc, (char*)(speaker_data),\ PACKET_SIZE*16, 0,\ (struct sockaddr *)&(g_UdpSock.Client),\ (SlSocklen_t*)&(g_UdpSock.iClientLength)); } if(g_iRetVal>0) { iRetVal = FillBuffer(pPlayBuffer, (unsigned char*)speaker_data,\ g_iRetVal); if(iRetVal < 0) { UART_PRINT("Unable to fill buffer"); LOOP_FOREVER(); } } } else { MAP_UtilsDelay(1000); } } MAP_UtilsDelay(1000); } }
//***************************************************************************** // //! Control for Wifi Audio Player Speaker //! //! \param None //! //! \return None // //***************************************************************************** static void SpeakerStartStopControl() { long lRetVal = -1; tTxMsg sMsg; sMsg.pEntry = &SpeakerControl; sMsg.pValue = NULL; lRetVal = osi_MsgQWrite(&g_ControlMsgQueue,&sMsg,OSI_NO_WAIT); if(lRetVal < 0) { UART_PRINT("Unable to write to message queue\n\r"); LOOP_FOREVER(); } }
//***************************************************************************** // //! Main //! //! \param none //! //! \return 0 //! //***************************************************************************** int main() { // // Board Initialisation // BoardInit(); // // Call the NwpFilter // NwpFilter(NULL); LOOP_FOREVER(); }