int application_start(void) { mxchipInit(); Platform_Init(); UART_Init(); #ifdef RFLowPowerMode ps_enable(); #endif #ifdef MCULowPowerMode mico_mcu_powersave_config(mxEnable); #endif debug_out("\r\n%s\r\nmxchipWNet library version: %s\r\n", APP_INFO, system_lib_version()); debug_out (menu); debug_out ("\nMXCHIP> "); while(1) { Main_Menu(); if(configSuccess){ wNetConfig.wifi_mode = Station; wNetConfig.dhcpMode = DHCP_Client; wNetConfig.wifi_retry_interval = 100; StartNetwork(&wNetConfig); debug_out("connect to %s.....\r\n", wNetConfig.wifi_ssid); configSuccess = 0; debug_out ("\nMXCHIP> "); } } }
static void initializePlatformSpecificModulesWithDebuggerParameters(const char* pDebuggerParameters) { Token tokens; Token_Init(&tokens); __try { __throwing_func( Token_SplitString(&tokens, pDebuggerParameters) ); __throwing_func( Platform_Init(&tokens) ); } __catch __rethrow; }
void Main(void) { InterruptInit(); IntDisableAll(); Platform_Init(); TS_Init(); /* Init the kernel. */ TMR_Init(); /* Init the TMR module */ NvModuleInit(); Uart_ModuleInit(); /* This only creates the MAC TS thread. */ MacInit(); /* Use TS for MAC - the MAC TS ID must be known at this step. */ Init_802_15_4(TRUE); #if gZtcIncluded_d Ztc_TaskInit(); #endif /* gZtcIncluded_d */ /*initialize the application*/ gAppTaskID_c = TS_CreateTask(gTsAppTaskPriority_c, AppTask); MApp_init(); #if (gLpmIncluded_d == 1) /*do not allow the device to enter sleep mode*/ PWR_DisallowDeviceToSleep(); #endif /* gLpmIncluded_d == 1 */ /*All LED's are switched OFF*/ Led1Off(); Led2Off(); Led3Off(); Led4Off(); /* Start the task scheduler. Does not return. */ TS_Scheduler(); }
int application_start(void) { OSStatus err = kNoErr; net_para_st para; Platform_Init(); /*Read current configurations*/ context = ( mico_Context_t *)malloc(sizeof(mico_Context_t) ); require_action( context, exit, err = kNoMemoryErr ); memset(context, 0x0, sizeof(mico_Context_t)); mico_rtos_init_mutex(&context->flashContentInRam_mutex); mico_rtos_init_semaphore(&context->micoStatus.sys_state_change_sem, 1); MICOReadConfiguration( context ); err = MICOInitNotificationCenter ( context ); err = MICOAddNotification( mico_notify_READ_APP_INFO, (void *)micoNotify_ReadAppInfoHandler ); require_noerr( err, exit ); /*wlan driver and tcpip init*/ mxchipInit(); getNetPara(¶, Station); formatMACAddr(context->micoStatus.mac, (char *)¶.mac); mico_log_trace(); mico_log("%s mxchipWNet library version: %s", APP_INFO, system_lib_version()); /*Start system monotor thread*/ err = MICOStartSystemMonitor(context); require_noerr_action( err, exit, mico_log("ERROR: Unable to start the system monitor.") ); err = MICORegisterSystemMonitor(&mico_monitor, APPLICATION_WATCHDOG_TIMEOUT_SECONDS*1000); require_noerr( err, exit ); mico_init_timer(&_watchdog_reload_timer,APPLICATION_WATCHDOG_TIMEOUT_SECONDS*1000-100, _watchdog_reload_timer_handler, NULL); mico_start_timer(&_watchdog_reload_timer); if(context->flashContentInRam.micoSystemConfig.configured != allConfigured){ mico_log("Empty configuration. Starting configuration mode..."); #ifdef CONFIG_MODE_EASYLINK err = startEasyLink( context ); require_noerr( err, exit ); #endif #ifdef CONFIG_MODE_WAC err = startMfiWac( context ); require_noerr( err, exit ); #endif } else{ mico_log("Available configuration. Starting Wi-Fi connection..."); /* Regisist notifications */ err = MICOAddNotification( mico_notify_WIFI_STATUS_CHANGED, (void *)micoNotify_WifiStatusHandler ); require_noerr( err, exit ); err = MICOAddNotification( mico_notify_WiFI_PARA_CHANGED, (void *)micoNotify_WiFIParaChangedHandler ); require_noerr( err, exit ); err = MICOAddNotification( mico_notify_DHCP_COMPLETED, (void *)micoNotify_DHCPCompleteHandler ); require_noerr( err, exit ); if(context->flashContentInRam.micoSystemConfig.rfPowerSaveEnable == true){ ps_enable(); } if(context->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable == true){ mico_mcu_powersave_config(true); } /*Bonjour service for searching*/ if(context->flashContentInRam.micoSystemConfig.bonjourEnable == true){ err = MICOStartBonjourService( Station, context ); require_noerr( err, exit ); } /*Local configuration server*/ if(context->flashContentInRam.micoSystemConfig.configServerEnable == true){ err = MICOStartConfigServer(context); require_noerr_action( err, exit, mico_log("ERROR: Unable to start the local server thread.") ); } /*Start mico application*/ err = MICOStartApplication( context ); require_noerr( err, exit ); _ConnectToAP( context ); } /*System status changed*/ while(mico_rtos_get_semaphore(&context->micoStatus.sys_state_change_sem, MICO_WAIT_FOREVER)==kNoErr){ switch(context->micoStatus.sys_state){ case eState_Normal: break; case eState_Software_Reset: sendNotifySYSWillPowerOff(); mico_thread_msleep(500); PlatformSoftReboot(); break; case eState_Wlan_Powerdown: sendNotifySYSWillPowerOff(); mico_thread_msleep(500); wifi_power_down(); break; case eState_Standby: mico_log("Enter standby mode"); sendNotifySYSWillPowerOff(); mico_thread_msleep(100); wifi_power_down(); Platform_Enter_STANDBY(); break; default: break; } } require_noerr_action( err, exit, mico_log("Closing main thread with err num: %d.", err) ); exit: mico_rtos_delete_thread(NULL); return kNoErr; }
int application_start(void) { OSStatus err = kNoErr; net_para_st para; Platform_Init(); /*Read current configurations*/ context = ( mico_Context_t *)malloc(sizeof(mico_Context_t) ); require_action( context, exit, err = kNoMemoryErr ); memset(context, 0x0, sizeof(mico_Context_t)); mico_rtos_init_mutex(&context->flashContentInRam_mutex); mico_rtos_init_semaphore(&context->micoStatus.sys_state_change_sem, 1); MICOReadConfiguration( context ); err = MICOInitNotificationCenter ( context ); err = MICOAddNotification( mico_notify_READ_APP_INFO, (void *)micoNotify_ReadAppInfoHandler ); require_noerr( err, exit ); /*wlan driver and tcpip init*/ mxchipInit(); getNetPara(¶, Station); formatMACAddr(context->micoStatus.mac, (char *)¶.mac); mico_log_trace(); mico_log("%s mxchipWNet library version: %s", APP_INFO, system_lib_version()); /*Start system monotor thread*/ err = MICOStartSystemMonitor(context); require_noerr_action( err, exit, mico_log("ERROR: Unable to start the system monitor.") ); err = MICORegisterSystemMonitor(&mico_monitor, APPLICATION_WATCHDOG_TIMEOUT_SECONDS*1000); require_noerr( err, exit ); mico_init_timer(&_watchdog_reload_timer,APPLICATION_WATCHDOG_TIMEOUT_SECONDS*1000-100, _watchdog_reload_timer_handler, NULL); mico_start_timer(&_watchdog_reload_timer); if(context->flashContentInRam.micoSystemConfig.configured != allConfigured){ mico_log("Empty configuration. Starting configuration mode..."); #ifdef CONFIG_MODE_EASYLINK err = startEasyLink( context ); require_noerr( err, exit ); #endif #ifdef CONFIG_MODE_WAC WACPlatformParameters_t* WAC_Params = NULL; WAC_Params = calloc(1, sizeof(WACPlatformParameters_t)); require(WAC_Params, exit); str2hex((unsigned char *)para.mac, WAC_Params->macAddress, 6); WAC_Params->isUnconfigured = 1; WAC_Params->supportsAirPlay = 0; WAC_Params->supportsAirPrint = 0; WAC_Params->supports2_4GHzWiFi = 1; WAC_Params->supports5GHzWiFi = 0; WAC_Params->supportsWakeOnWireless = 0; WAC_Params->firmwareRevision = FIRMWARE_REVISION; WAC_Params->hardwareRevision = HARDWARE_REVISION; WAC_Params->serialNumber = SERIAL_NUMBER; WAC_Params->name = context->flashContentInRam.micoSystemConfig.name; WAC_Params->model = MODEL; WAC_Params->manufacturer = MANUFACTURER; WAC_Params->numEAProtocols = 1; WAC_Params->eaBundleSeedID = BUNDLE_SEED_ID; WAC_Params->eaProtocols = (char **)eaProtocols;; err = startMFiWAC( context, WAC_Params, 1200); free(WAC_Params); require_noerr( err, exit ); #endif } else{ mico_log("Available configuration. Starting Wi-Fi connection..."); /* Regisist notifications */ err = MICOAddNotification( mico_notify_WIFI_STATUS_CHANGED, (void *)micoNotify_WifiStatusHandler ); require_noerr( err, exit ); err = MICOAddNotification( mico_notify_WiFI_PARA_CHANGED, (void *)micoNotify_WiFIParaChangedHandler ); require_noerr( err, exit ); err = MICOAddNotification( mico_notify_DHCP_COMPLETED, (void *)micoNotify_DHCPCompleteHandler ); require_noerr( err, exit ); if(context->flashContentInRam.micoSystemConfig.rfPowerSaveEnable == true){ ps_enable(); } if(context->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable == true){ mico_mcu_powersave_config(true); } /*Bonjour service for searching*/ // if(context->flashContentInRam.micoSystemConfig.bonjourEnable == true){ // err = MICOStartBonjourService( Station, context ); // require_noerr( err, exit ); // } err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "mDNSResponder", mDNSResponder_thread, 0x1000, (void*)context ); require_noerr_action( err, exit, mico_log("ERROR: Unable to start mDNSResponder thread.") ); /*Local configuration server*/ if(context->flashContentInRam.micoSystemConfig.configServerEnable == true){ err = MICOStartConfigServer(context); require_noerr_action( err, exit, mico_log("ERROR: Unable to start the local server thread.") ); } /*Start mico application*/ err = MICOStartApplication( context ); require_noerr( err, exit ); _ConnectToAP( context ); } /*System status changed*/ while(mico_rtos_get_semaphore(&context->micoStatus.sys_state_change_sem, MICO_WAIT_FOREVER)==kNoErr){ switch(context->micoStatus.sys_state){ case eState_Normal: break; case eState_Software_Reset: sendNotifySYSWillPowerOff(); mico_thread_msleep(500); PlatformSoftReboot(); break; case eState_Wlan_Powerdown: sendNotifySYSWillPowerOff(); mico_thread_msleep(500); wifi_power_down(); break; case eState_Standby: mico_log("Enter standby mode"); sendNotifySYSWillPowerOff(); mico_thread_msleep(200); wifi_power_down(); Platform_Enter_STANDBY(); break; default: break; } } require_noerr_action( err, exit, mico_log("Closing main thread with err num: %d.", err) ); exit: mico_rtos_delete_thread(NULL); return kNoErr; }
bool_t Context_Init(const tchar_t* Name,const tchar_t* Version,int Id,const tchar_t* CmdLine,void* Application) { context* p = malloc(sizeof(context)); if (!p) return 0; #ifdef PREALLOC { int i; for (i=0;i<PREALLOC;++i) q[i] = malloc(65536); } #endif memset(p,0,sizeof(context)); p->Version = CONTEXT_VERSION; p->ProgramId = Id; p->ProgramName = Name; p->ProgramVersion = Version; p->CmdLine = CmdLine; p->Lang = DefaultLang(); p->StartUpMemory = AvailMemory(); p->LowMemory = p->StartUpMemory < LOWMEMORY_LIMIT; p->Application = Application; SetContext(p); Mem_Init(); DynCode_Init(); String_Init(); PCM_Init(); Blit_Init(); Node_Init(); Platform_Init(); Stream_Init(); Advanced_Init(); Flow_Init(); Codec_Init(); Audio_Init(); Video_Init(); Format_Init(); Playlist_Init(); FormatBase_Init(); NullOutput_Init(); RawAudio_Init(); RawImage_Init(); Timer_Init(); IDCT_Init(); Overlay_Init(); M3U_Init(); PLS_Init(); ASX_Init(); WaveOut_Init(); SoftIDCT_Init(); #if defined(CONFIG_SUBS) SubTitle_Init(); #endif #if defined(TARGET_PALMOS) OverlayHIRES_Init(); //Win_Init(); //About_Init(); //BenchResult_Init(); //MediaInfo_Init(); //Settings_Init(); ASF_Init(); AVI_Init(); WAV_Init(); MP4_Init(); MPG_Init(); NSV_Init(); Law_Init(); ADPCM_Init(); #elif defined(TARGET_WIN32) || defined(TARGET_WINCE) #if defined(TARGET_WINCE) if (QueryPlatform(PLATFORM_TYPENO) != TYPE_SMARTPHONE) { OverlayRAW_Init(); OverlayGAPI_Init(); } else { OverlayGAPI_Init(); // prefer GAPI with smartphones (Sagem MyS-7 crashes with Raw FrameBuffer?) OverlayRAW_Init(); } OverlayDirect_Init(); OverlayS1D13806_Init(); #else OverlayConsole_Init(); #endif OverlayXScale_Init(); OverlayDDraw_Init(); // after GAPI and RAW and XScale OverlayFlyTV_Init(); OverlayGDI_Init(); #elif defined(TARGET_SYMBIAN) OverlaySymbian_Init(); #endif #ifdef NO_PLUGINS Static_Init(); #else Plugins_Init(); #endif Association_Init(); // after all formats are registered Color_Init(); Equalizer_Init(); Player_Init(); // after all output drivers are registered return 1; }