OSStatus startEasyLink( mico_Context_t * const inContext) { easylink_log_trace(); OSStatus err = kUnknownErr; easylinkClient_fd = -1; mico_mcu_powersave_config(true); err = MICOAddNotification( mico_notify_WIFI_STATUS_CHANGED, (void *)EasyLinkNotify_WifiStatusHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_WiFI_PARA_CHANGED, (void *)EasyLinkNotify_WiFIParaChangedHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_EASYLINK_COMPLETED, (void *)EasyLinkNotify_EasyLinkCompleteHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_EASYLINK_GET_EXTRA_DATA, (void *)EasyLinkNotify_EasyLinkGetExtraDataHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_DHCP_COMPLETED, (void *)EasyLinkNotify_DHCPCompleteHandler ); require_noerr( err, exit ); err = MICOAddNotification( mico_notify_SYS_WILL_POWER_OFF, (void *)EasyLinkNotify_SYSWillPoerOffHandler ); require_noerr( err, exit ); // Start the EasyLink thread ConfigWillStart(inContext); mico_rtos_init_semaphore(&easylink_sem, 1); err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "EASYLINK", easylink_thread, 0x1000, (void*)inContext ); require_noerr_action( err, exit, easylink_log("ERROR: Unable to start the EasyLink thread.") ); exit: return err; }
OSStatus startEasyLinkSoftAP( mico_Context_t * const inContext) { easylink_uap_log_trace(); OSStatus err = kUnknownErr; network_InitTypeDef_st wNetConfig; err = MICOAddNotification( mico_notify_WIFI_STATUS_CHANGED, (void *)_EasyLinkNotify_WifiStatusHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_WiFI_PARA_CHANGED, (void *)_EasyLinkNotify_WiFIParaChangedHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_DHCP_COMPLETED, (void *)_EasyLinkNotify_DHCPCompleteHandler ); require_noerr( err, exit ); // Start the EasyLink thread ConfigWillStart(inContext); if(inContext->flashContentInRam.micoSystemConfig.easyLinkByPass == EASYLINK_BYPASS_NO){ memset(&wNetConfig, 0, sizeof(network_InitTypeDef_st)); wNetConfig.wifi_mode = Soft_AP; snprintf(wNetConfig.wifi_ssid, 32, "EasyLink_%c%c%c%c%c%c", inContext->micoStatus.mac[9], inContext->micoStatus.mac[10], inContext->micoStatus.mac[12], inContext->micoStatus.mac[13], inContext->micoStatus.mac[15], inContext->micoStatus.mac[16] ); strcpy((char*)wNetConfig.wifi_key, ""); strcpy((char*)wNetConfig.local_ip_addr, "10.10.10.1"); strcpy((char*)wNetConfig.net_mask, "255.255.255.0"); strcpy((char*)wNetConfig.gateway_ip_addr, "10.10.10.1"); wNetConfig.dhcpMode = DHCP_Server; micoWlanStart(&wNetConfig); easylink_uap_log("Establish soft ap: %s.....", wNetConfig.wifi_ssid); err = _initBonjourForEasyLink( Soft_AP , inContext ); require_noerr(err, exit); }else{ err = _initBonjourForEasyLink( Station , inContext ); _easylinkConnectWiFi_fast(inContext); require_noerr(err, exit); } start_bonjour_service(); _bonjourStarted = true; err = MICOStartConfigServer ( inContext ); require_noerr(err, exit); ConfigSoftApWillStart( inContext ); exit: return err; }
OSStatus startEasyLink( mico_Context_t * const inContext) { easylink_log_trace(); OSStatus err = kUnknownErr; require_action(inContext->micoStatus.easylink_thread_handler==NULL, exit, err = kParamErr); require_action(inContext->micoStatus.easylink_sem==NULL, exit, err = kParamErr); inContext->micoStatus.easylinkClient_fd = -1; //ps_enable(); mico_mcu_powersave_config(true); mico_rtos_init_mutex(&_mutex); err = MICOAddNotification( mico_notify_WIFI_STATUS_CHANGED, (void *)EasyLinkNotify_WifiStatusHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_WiFI_PARA_CHANGED, (void *)EasyLinkNotify_WiFIParaChangedHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_EASYLINK_COMPLETED, (void *)EasyLinkNotify_EasyLinkCompleteHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_EASYLINK_GET_EXTRA_DATA, (void *)EasyLinkNotify_EasyLinkGetExtraDataHandler ); require_noerr(err, exit); err = MICOAddNotification( mico_notify_DHCP_COMPLETED, (void *)EasyLinkNotify_DHCPCompleteHandler ); require_noerr( err, exit ); err = MICOAddNotification( mico_notify_SYS_WILL_POWER_OFF, (void *)EasyLinkNotify_SYSWillPoerOffHandler ); require_noerr( err, exit ); /*Led trigger*/ mico_init_timer(&_Led_EL_timer, LED_EL_TRIGGER_INTERVAL, _led_EL_Timeout_handler, NULL); mico_start_timer(&_Led_EL_timer); // Start the EasyLink thread ConfigWillStart(inContext); mico_rtos_init_semaphore(&inContext->micoStatus.easylink_sem, 1); err = mico_rtos_create_thread(&inContext->micoStatus.easylink_thread_handler, MICO_APPLICATION_PRIORITY, "EASYLINK", easylink_thread, 0x1000, (void*)inContext ); require_noerr_action( err, exit, easylink_log("ERROR: Unable to start the EasyLink thread.") ); exit: return err; }