void micoNotify_WifiStatusHandler(WiFiEvent event, mico_Context_t * const inContext) { mico_log_trace(); (void)inContext; switch (event) { case NOTIFY_STATION_UP: mico_log("Station up"); MicoRfLed(true); break; case NOTIFY_STATION_DOWN: mico_log("Station down"); MicoRfLed(false); break; case NOTIFY_AP_UP: mico_log("uAP established"); MicoRfLed(true); break; case NOTIFY_AP_DOWN: mico_log("uAP deleted"); MicoRfLed(false); break; default: break; } return; }
void micoNotify_WifiStatusHandler(WiFiEvent event, const int inContext) { switch (event) { case NOTIFY_STATION_UP: power_log("Station up"); MicoRfLed(true); break; case NOTIFY_STATION_DOWN: power_log("Station down"); MicoRfLed(false); break; default: break; } return; }
void micoNotify_WifiStatusHandler(WiFiEvent event, const int inContext) { (void)inContext; switch (event) { case NOTIFY_AP_UP: wifi_softap_log("AP established"); MicoRfLed(true); break; case NOTIFY_AP_DOWN: wifi_softap_log("AP deleted"); MicoRfLed(false); break; default: break; } return; }
void micoNotify_WifiStatusHandler(WiFiEvent event, const int inContext) { (void)inContext; switch (event) { case NOTIFY_STATION_UP: tcp_server_log("Station up"); mico_rtos_set_semaphore(&tcp_sem); MicoRfLed(true); break; case NOTIFY_STATION_DOWN: tcp_server_log("Station down"); MicoRfLed(false); break; default: break; } return; }
// for station connect ap error state(no station down event when AP down) static void appNotify_ConnectFailedHandler(OSStatus err, mico_Context_t * const inContext) { system_log_trace(); (void)inContext; app_log("Wlan Connection Err %d", err); if(NULL != app_context_global){ app_context_global->appStatus.isWifiConnected = false; MicoRfLed(false); } }
/************************************************* * Function: MICOStartUart * Description: * Author: cxy * Returns: * Parameter: * History: *************************************************/ void MICORfLed_thread(void * inContext ) { static bool onoff = true; while(1){ mico_rtos_get_semaphore(&query_sem, 1000); onoff = !onoff; MicoRfLed(onoff); } }
void swNotify_WifiStatusHandler(WiFiEvent event, app_context_t * const inContext) { (void)inContext; switch (event) { case NOTIFY_STATION_UP: inContext->appStatus.isWifiConnected = true; MicoRfLed(true); break; case NOTIFY_STATION_DOWN: inContext->appStatus.isWifiConnected = false; MicoRfLed(false); break; case NOTIFY_AP_UP: break; case NOTIFY_AP_DOWN: break; default: break; } return; }
void init_platform( void ) { MicoGpioInitialize( (mico_gpio_t)MICO_SYS_LED, OUTPUT_PUSH_PULL ); MicoSysLed(false); MicoGpioInitialize( (mico_gpio_t)MICO_RF_LED, OUTPUT_PUSH_PULL ); MicoRfLed(false); // Initialise EasyLink buttons //MicoGpioInitialize( (mico_gpio_t)EasyLink_BUTTON, INPUT_PULL_UP ); //mico_init_timer(&_button_EL_timer, RestoreDefault_TimeOut, _button_EL_Timeout_handler, NULL); //MicoGpioEnableIRQ( (mico_gpio_t)EasyLink_BUTTON, IRQ_TRIGGER_FALLING_EDGE, _button_EL_irq_handler, NULL ); // // // Initialise Standby/wakeup switcher // MicoGpioInitialize( Standby_SEL, INPUT_PULL_UP ); // MicoGpioEnableIRQ( Standby_SEL , IRQ_TRIGGER_FALLING_EDGE, _button_STANDBY_irq_handler, NULL); }
int application_start(void) { app_log_trace(); OSStatus err = kNoErr; app_context_t* app_context; mico_Context_t* mico_context; LinkStatusTypeDef wifi_link_status; /* Create application context */ app_context = ( app_context_t *)calloc(1, sizeof(app_context_t) ); require_action( app_context, exit, err = kNoMemoryErr ); /* Create mico system context and read application's config data from flash */ mico_context = mico_system_context_init( sizeof( application_config_t) ); require_action(mico_context, exit, err = kNoResourcesErr); app_context->appConfig = mico_system_context_get_user_data( mico_context ); app_context->mico_context = mico_context; app_context_global = app_context; /* user params restore check */ if(app_context->appConfig->configDataVer != CONFIGURATION_VERSION){ err = mico_system_context_restore(mico_context); require_noerr( err, exit ); } /* mico system initialize */ err = mico_system_init( mico_context ); require_noerr( err, exit ); MicoSysLed(true); // fix for AP down problem err = mico_system_notify_register( mico_notify_WIFI_CONNECT_FAILED, (void *)appNotify_ConnectFailedHandler, app_context->mico_context ); require_noerr_action(err, exit, app_log("ERROR: MICOAddNotification (mico_notify_WIFI_CONNECT_FAILED) failed!") ); //#ifdef USE_MiCOKit_EXT // /* user test mode to test MiCOKit-EXT board */ // if(MicoExtShouldEnterTestMode()){ // app_log("Enter ext-board test mode by key2."); // micokit_ext_mfg_test(mico_context); // } //#endif // block here if no wifi configuration. while(1){ if( mico_context->flashContentInRam.micoSystemConfig.configured == wLanUnConfigured || mico_context->flashContentInRam.micoSystemConfig.configured == unConfigured){ mico_thread_msleep(100); } else{ break; } } /* Bonjour for service searching */ MICOStartBonjourService( Station, app_context ); /* check wifi link status */ do{ err = micoWlanGetLinkStatus(&wifi_link_status); if(kNoErr != err){ mico_thread_sleep(3); } }while(kNoErr != err); if(1 == wifi_link_status.is_connected){ app_context->appStatus.isWifiConnected = true; MicoRfLed(true); } else{ app_context->appStatus.isWifiConnected = false; MicoRfLed(false); } /* start cloud service */ #if (MICO_CLOUD_TYPE == CLOUD_FOGCLOUD) app_log("MICO CloudService: FogCloud."); err = MiCOStartFogCloudService( app_context ); require_noerr_action( err, exit, app_log("ERROR: Unable to start FogCloud service.") ); #elif (MICO_CLOUD_TYPE == CLOUD_ALINK) app_log("MICO CloudService: Alink."); #elif (MICO_CLOUD_TYPE == CLOUD_DISABLED) app_log("MICO CloudService: disabled."); #else #error "MICO cloud service type is not defined"? #endif /* start user thread */ err = startUserMainThread( app_context ); require_noerr_action( err, exit, app_log("ERROR: start user_main thread failed!") ); exit: mico_rtos_delete_thread(NULL); return err; }
int application_start(void) { app_log_trace(); OSStatus err = kNoErr; app_context_t* app_context; mico_Context_t* mico_context; LinkStatusTypeDef wifi_link_status; /* Create application context */ app_context = ( app_context_t *)calloc(1, sizeof(app_context_t) ); require_action( app_context, exit, err = kNoMemoryErr ); /* Create mico system context and read application's config data from flash */ mico_context = mico_system_context_init( sizeof( application_config_t) ); require_action(mico_context, exit, err = kNoResourcesErr); app_context->appConfig = mico_system_context_get_user_data( mico_context ); app_context->mico_context = mico_context; /* user params restore check */ if(app_context->appConfig->configDataVer != CONFIGURATION_VERSION){ err = mico_system_context_restore(mico_context); require_noerr( err, exit ); } /* mico system initialize */ err = mico_system_init( mico_context ); require_noerr( err, exit ); MicoSysLed(true); /* Bonjour for service searching */ MICOStartBonjourService( Station, app_context ); /* user test mode: MiCOKit-EXT */ /* check wifi link status */ do{ err = micoWlanGetLinkStatus(&wifi_link_status); if(kNoErr != err){ mico_thread_sleep(3); } }while(kNoErr != err); if(1 == wifi_link_status.is_connected){ app_context->appStatus.isWifiConnected = true; MicoRfLed(true); } else{ app_context->appStatus.isWifiConnected = false; MicoRfLed(false); } /* start cloud service */ #if (MICO_CLOUD_TYPE == CLOUD_FOGCLOUD) app_log("MICO CloudService: FogCloud."); err = MiCOStartFogCloudService( app_context ); require_noerr_action( err, exit, app_log("ERROR: Unable to start FogCloud service.") ); #elif (MICO_CLOUD_TYPE == CLOUD_ALINK) app_log("MICO CloudService: Alink."); #elif (MICO_CLOUD_TYPE == CLOUD_SITEWHERE) app_log("MICO CloudService: SiteWhere."); err = MiCOStartSiteWhereService( app_context ); require_noerr_action( err, exit, app_log("ERROR: Unable to start SiteWhere service.") ); #elif (MICO_CLOUD_TYPE == CLOUD_DISABLED) app_log("MICO CloudService: disabled."); #else #error "MICO cloud service type is not defined"? #endif /* start user thread */ err = startUserMainThread( app_context ); require_noerr_action( err, exit, app_log("ERROR: start user_main thread failed!") ); exit: mico_rtos_delete_thread(NULL); return err; }