Esempio n. 1
0
static void ICACHE_FLASH_ATTR wifi_check_ip(void *arg)
{
	struct ip_info ipConfig;

	os_timer_disarm(&WiFiLinker);
	wifi_get_ip_info(STATION_IF, &ipConfig);
	wifiStatus = wifi_station_get_connect_status();
	if (wifiStatus == STATION_GOT_IP && ipConfig.ip.addr != 0)
	{

		os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
		os_timer_arm(&WiFiLinker, 2000, 0);


	}
	else
	{
		if(wifi_station_get_connect_status() == STATION_WRONG_PASSWORD)
		{

			INFO("STATION_WRONG_PASSWORD\r\n");
			wifi_station_connect();


		}
		else if(wifi_station_get_connect_status() == STATION_NO_AP_FOUND)
		{

			INFO("STATION_NO_AP_FOUND\r\n");
			wifi_station_connect();


		}
		else if(wifi_station_get_connect_status() == STATION_CONNECT_FAIL)
		{

			INFO("STATION_CONNECT_FAIL\r\n");
			wifi_station_connect();

		}
		else
		{
			INFO("STATION_IDLE\r\n");
		}

		os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
		os_timer_arm(&WiFiLinker, 500, 0);
	}
	if(wifiStatus != lastWifiStatus){
		lastWifiStatus = wifiStatus;
		if(wifiCb)
			wifiCb(wifiStatus);
	}
}
Esempio n. 2
0
void ICACHE_FLASH_ATTR
smartconfig_done(sc_status status, void *pdata)
{
    switch(status) {
        case SC_STATUS_WAIT:
            printf("SC_STATUS_WAIT\n");
            break;
        case SC_STATUS_FIND_CHANNEL:
            printf("SC_STATUS_FIND_CHANNEL\n");
            break;
        case SC_STATUS_GETTING_SSID_PSWD:
            printf("SC_STATUS_GETTING_SSID_PSWD\n");
            break;
        case SC_STATUS_LINK:
            printf("SC_STATUS_LINK\n");
            struct station_config *sta_conf = pdata;
	
	        wifi_station_set_config(sta_conf);
	        wifi_station_disconnect();
	        wifi_station_connect();
            break;
        case SC_STATUS_LINK_OVER:
            printf("SC_STATUS_LINK_OVER\n");
            if (SC_Type == SC_TYPE_ESPTOUCH) {
                uint8 phone_ip[4] = {0};

                memcpy(phone_ip, (uint8*)pdata, 4);
                printf("Phone ip: %d.%d.%d.%d\n",phone_ip[0],phone_ip[1],phone_ip[2],phone_ip[3]);
            }
            smartconfig_stop();
            break;
    }
	
}
Esempio n. 3
0
ICACHE_FLASH_ATTR static v7_val_t Wifi_connect(struct v7 *v7, v7_val_t this_obj,
                                               v7_val_t args) {
  (void) v7;
  (void) this_obj;
  (void) args;
  return v7_create_boolean(wifi_station_connect());
}
Esempio n. 4
0
void ICACHE_FLASH_ATTR smartConfig_done(sc_status status, void *pdata) {
	switch (status) {
	case SC_STATUS_WAIT:
		os_printf("SC_STATUS_WAIT\n");
		break;
	case SC_STATUS_FIND_CHANNEL:
		os_printf("SC_STATUS_FIND_CHANNEL\n");
		break;
	case SC_STATUS_GETTING_SSID_PSWD:
		os_printf("SC_STATUS_GETTING_SSID_PSWD\n");
		break;
	case SC_STATUS_LINK:
		os_printf("SC_STATUS_LINK\n");
		struct station_config *sta_conf = pdata;
		wifi_station_set_config(sta_conf);
		INFOP("Connected to %s (%s) %d", sta_conf->ssid, sta_conf->password, sta_conf->bssid_set);
		strcpy(sysCfg.sta_ssid, sta_conf->ssid);
		strcpy(sysCfg.sta_pwd, sta_conf->password);
		wifi_station_disconnect();
		wifi_station_connect();
		break;
	case SC_STATUS_LINK_OVER:
		os_printf("SC_STATUS_LINK_OVER\n");
		smartconfig_stop();
		checkSmartConfig(SC_HAS_STOPPED);
		sysCfg.sta_ssid;
		break;
	}
}
Esempio n. 5
0
void ICACHE_FLASH_ATTR WIFI_Connect(WifiCallback cb)
{
	struct station_config stationConf;
	struct ip_info info;

	INFO("WIFI_INIT\r\n");
	
	os_timer_disarm(&WiFiLinker);
	
	//wifi_set_opmode(STATION_MODE);
	wifi_station_set_auto_connect(FALSE);
	wifiCb = cb;

	os_memset(&stationConf, 0, sizeof(struct station_config));

	os_sprintf((char *)stationConf.ssid, "%s", sysCfg.sta_ssid);
	os_sprintf((char *)stationConf.password, "%s", sysCfg.sta_pass);

	wifi_get_ip_info(STATION_IF, &info);
	char *dhcp = (char *)sysCfg.sta_mode; 
	char *ip, *mask, *gw;
	if (!dhcp || os_strcmp(dhcp, "dhcp") != 0)
	{
		ip = (char *)sysCfg.sta_ip; 
		mask = (char *)sysCfg.sta_mask;
		gw = (char *)sysCfg.sta_gw;
		if (ip)
			info.ip.addr = ipaddr_addr(ip);
		if (mask)
			info.netmask.addr = ipaddr_addr(mask);
		if (gw)
			info.gw.addr = ipaddr_addr(gw);			
		wifi_set_ip_info(STATION_IF, &info);
	}

	wifi_get_ip_info(SOFTAP_IF, &info);
	ip = (char *)sysCfg.ap_ip; 
	mask = (char *)sysCfg.ap_mask;
	gw = (char *)sysCfg.ap_gw;
	if (ip)
		info.ip.addr = ipaddr_addr(ip);
	if (mask)
		info.netmask.addr = ipaddr_addr(mask);
	if (gw)
		info.gw.addr = ipaddr_addr(gw);
	
	if (wifi_get_opmode() != STATION_MODE)
		wifi_set_ip_info(SOFTAP_IF, &info);


	wifi_station_set_config(&stationConf);
		
	os_timer_disarm(&WiFiLinker);
	os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
	os_timer_arm(&WiFiLinker, 1000, 0);

	wifi_station_set_auto_connect(TRUE);
	wifi_station_connect();
	
}
Esempio n. 6
0
bool StationClass::setIP(IPAddress address, IPAddress netmask, IPAddress gateway)
{
	if (System.isReady())
	{
		debugf("IP can be changed only in init() method");
		return false;
	}

	wifi_station_disconnect();
//	wifi_station_dhcpc_stop();
	struct ip_info ipinfo;
	wifi_get_ip_info(STATION_IF, &ipinfo);
	ipinfo.ip = address;
	ipinfo.netmask = netmask;
	ipinfo.gw = gateway;
	if (wifi_set_ip_info(STATION_IF, &ipinfo))
		debugf("AP IP succesfully updated");
	else
	{
		debugf("AP IP can't be updated");
		enableDHCP(true);
	}
	wifi_station_connect();
	//wifi_station_dhcpc_start();
	return true;
}
Esempio n. 7
0
bool ICACHE_FLASH_ATTR checkSmartConfig(enum SmartConfigAction action) {
	static doingSmartConfig = false;

	switch (action) {
	case SC_CHECK:
		break;
	case SC_HAS_STOPPED:
		os_printf("Finished smartConfig\n");
		stopFlash();
		doingSmartConfig = false;
		MQTT_Connect(&mqttClient);
		break;
	case SC_TOGGLE:
		if (doingSmartConfig) {
			os_printf("Stop smartConfig\n");
			stopFlash();
			smartconfig_stop();
			doingSmartConfig = false;
			wifi_station_disconnect();
			wifi_station_connect();
		} else {
			os_printf("Start smartConfig\n");
			MQTT_Disconnect(&mqttClient);
			mqttConnected = false;
			startFlash(100, true);
			doingSmartConfig = true;
			smartconfig_start(smartConfig_done, true);
		}
		break;
	}
	return doingSmartConfig;
}
Esempio n. 8
0
void ICACHE_FLASH_ATTR setup_station(char ssid[], char password[]) {
    // Stop previous connection
    wifi_station_disconnect();
    wifi_station_dhcpc_stop();

    // Create config struct
    struct station_config staConfig;
    wifi_station_get_config(&staConfig);

    // Set SSID in struct
    os_memset(staConfig.ssid, 0, sizeof(staConfig.ssid));
    os_memcpy(staConfig.ssid, ssid, os_strlen(ssid));

    // Set Password in struct
    os_memset(staConfig.password, 0, sizeof(staConfig.password));
    os_memcpy(staConfig.password, password, os_strlen(password));

    // Use config struct
    wifi_station_set_config(&staConfig);
    //print("Set Station info");
    wifi_station_connect();
    wifi_station_dhcpc_start();
    wifi_station_set_auto_connect(1);

    connection_status = CONNECTION_CONNECTING;
}
Esempio n. 9
0
int sj_wifi_setup_sta(const struct sys_config_wifi_sta *cfg) {
  int res;
  struct station_config sta_cfg;
  /* If in AP-only mode, switch to station. If in STA or AP+STA, keep it. */
  if (wifi_get_opmode() == SOFTAP_MODE) {
    wifi_set_opmode_current(STATION_MODE);
  }
  wifi_station_disconnect();

  memset(&sta_cfg, 0, sizeof(sta_cfg));
  sta_cfg.bssid_set = 0;
  strncpy((char *) &sta_cfg.ssid, cfg->ssid, 32);
  strncpy((char *) &sta_cfg.password, cfg->pass, 64);

  res = wifi_station_set_config_current(&sta_cfg);
  if (!res) {
    LOG(LL_ERROR, ("Failed to set station config"));
    return 0;
  }

  if (cfg->ip != NULL && cfg->netmask != NULL) {
    struct ip_info info;
    memset(&info, 0, sizeof(info));
    info.ip.addr = ipaddr_addr(cfg->ip);
    info.netmask.addr = ipaddr_addr(cfg->netmask);
    if (cfg->gw != NULL) info.gw.addr = ipaddr_addr(cfg->gw);
    wifi_station_dhcpc_stop();
    wifi_set_ip_info(STATION_IF, &info);
    LOG(LL_INFO, ("WiFi STA IP config: %s %s %s", cfg->ip, cfg->netmask,
                  (cfg->gw ? cfg->ip : "")));
  }

  LOG(LL_INFO, ("WiFi STA: Joining %s", sta_cfg.ssid));
  return wifi_station_connect();
}
Esempio n. 10
0
void ICACHE_FLASH_ATTR user_init(void) {
	uart_div_modify(0, UART_CLK_FREQ / BAUD);

	wifi_set_opmode(STATION_MODE);
	wifi_station_connect();

	/*** I²C init ***/
	i2c_master_gpio_init();
	mpu9250_init();
	ak8963_init();

	os_delay_us(10000);
	i2c_scanbus();

	/*** LCD Init ***/
	ssd1306_init(0);
	ssd1306_text_small(10, 10, "Init...");
	ssd1306_flip();

	// ~Charge input
	PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
	gpio_output_set(0, 0, 0, BIT13);

	// Button inputs
	buttons_init();

	ak8963_calibration_start(10000, on_ak8963_calibration);

	os_printf("Startup\r\n");
}
Esempio n. 11
0
/**
  * @brief  Setup commad of join to wifi ap.
  * @param  id: commad id number
  * @param  pPara: AT input param
  * @retval None
  */
static void ICACHE_FLASH_ATTR wifi_connect(char * ssid, char * password, char * bssid)
{
	char temp[64];
	struct station_config stationConf;
	int8_t len;
	connect_attempts++;
	//wifi_station_get_config(&stationConf);
	os_bzero(&stationConf, sizeof(struct station_config));
	os_memcpy(&stationConf.ssid, ssid, os_strlen(ssid));
	//os_memcpy(&stationConf.password, password, os_strlen(password));
	os_memcpy(&stationConf.bssid, bssid, 6);
	stationConf.bssid_set = 1;
    wifi_station_disconnect();
    os_printf("stationConf.ssid: -%s-\r\n", stationConf.ssid);
    os_printf("stationConf.password: -%s-\r\n", stationConf.password);

    ETS_UART_INTR_DISABLE();
    wifi_station_set_config(&stationConf);
    ETS_UART_INTR_ENABLE();
    wifi_station_connect();
    os_timer_disarm(&at_japDelayChack);
    os_timer_setfn(&at_japDelayChack, (os_timer_func_t *)at_japChack, NULL);
    os_timer_arm(&at_japDelayChack, 3000, 0);

}
Esempio n. 12
0
ICACHE_FLASH_ATTR static v7_val_t Wifi_setup(struct v7 *v7, v7_val_t this_obj,
                                             v7_val_t args) {
  struct station_config stationConf;
  v7_val_t ssidv = v7_array_get(v7, args, 0);
  v7_val_t passv = v7_array_get(v7, args, 1);
  const char *ssid, *pass;
  size_t ssid_len, pass_len;
  int res;

  if (!v7_is_string(ssidv) || !v7_is_string(passv)) {
    printf("ssid/pass are not strings\n");
    return v7_create_undefined();
  }

  wifi_station_disconnect();

  ssid = v7_to_string(v7, &ssidv, &ssid_len);
  pass = v7_to_string(v7, &passv, &pass_len);

  stationConf.bssid_set = 0;
  strncpy((char *) &stationConf.ssid, ssid, 32);
  strncpy((char *) &stationConf.password, pass, 64);

  res = v7_create_boolean(wifi_station_set_config(&stationConf));
  if (!res) {
    printf("Failed to set station config\n");
    return v7_create_boolean(0);
  }

  return v7_create_boolean(wifi_station_connect());
}
Esempio n. 13
0
void setup_wifi_st_mode(void)
{
//	wifi_set_opmode((wifi_get_opmode()|STATION_MODE)&STATIONAP_MODE);
	wifi_set_opmode(wifi_get_opmode() | STATION_MODE);

	struct station_config stconfig;
	wifi_station_disconnect();
	wifi_station_dhcpc_stop();
	if(wifi_station_get_config(&stconfig))
		{
		memset(stconfig.ssid, 0, sizeof(stconfig.ssid));
		memset(stconfig.password, 0, sizeof(stconfig.password));
		os_sprintf(stconfig.ssid, "%s", sysCfg.sta_ssid);
		os_sprintf(stconfig.password, "%s", sysCfg.sta_pwd);
		if(!wifi_station_set_config(&stconfig))
			{
			#ifdef PLATFORM_DEBUG
			INFO("ESP8266 not set station config!\r\n");
			#endif
			}
		}
	wifi_station_connect();
	wifi_station_dhcpc_start();
	wifi_station_set_auto_connect(1);
	#ifdef PLATFORM_DEBUG
	INFO("ESP8266 in STA mode configured.\r\n");
	#endif
}
void ICACHE_FLASH_ATTR 
    WIFI_Connect(uint8_t* ssid, uint8_t* pass, WifiCallback cb)
{
    struct station_config stationConf;

    INFO("WIFI_INIT\r\n");
    wifi_set_opmode(STATIONAP_MODE);//
    if(cb){
        wifiCb = cb;
    }else{
        wifiCb = WIFI_ConnectCb;
    }
    os_memset(&stationConf, 0, sizeof(struct station_config));

    os_sprintf(stationConf.ssid, "%s", ssid);
    os_sprintf(stationConf.password, "%s", pass);

    wifi_station_set_config(&stationConf);

    os_timer_disarm(&WiFiLinker);
    os_timer_setfn(&WiFiLinker, (os_timer_func_t *)WIFI_CheckIp, NULL);
    os_timer_arm(&WiFiLinker, 1000, 0);

    wifi_station_connect();
}
Esempio n. 15
0
/**
 * WPS callback
 * @param status wps_cb_status
 */
void wifi_wps_status_cb(wps_cb_status status) {
    DEBUGV("wps cb status: %d\r\n", status);
    switch(status) {
        case WPS_CB_ST_SUCCESS:
            if(!wifi_wps_disable()) {
                DEBUGV("wps disable failed\n");
            }
            wifi_station_connect();
            break;
        case WPS_CB_ST_FAILED:
            DEBUGV("wps FAILED\n");
            break;
        case WPS_CB_ST_TIMEOUT:
            DEBUGV("wps TIMEOUT\n");
            break;
        case WPS_CB_ST_WEP:
            DEBUGV("wps WEP\n");
            break;
        case WPS_CB_ST_UNK:
            DEBUGV("wps UNKNOWN\n");
            if(!wifi_wps_disable()) {
                DEBUGV("wps disable failed\n");
            }
            break;
    }
    // TODO user function to get status

    esp_schedule(); // resume the beginWPSConfig function
}
Esempio n. 16
0
// Lua: wifi.sta.config(ssid, password)
static int wifi_station_config( lua_State* L )
{
  size_t sl, pl;
  struct station_config sta_conf;
  int i;
  const char *ssid = luaL_checklstring( L, 1, &sl );
  if (sl>32 || ssid == NULL)
    return luaL_error( L, "ssid:<32" );
  const char *password = luaL_checklstring( L, 2, &pl );
  if (pl>64 || password == NULL)
    return luaL_error( L, "pwd:<64" );

  c_memset(sta_conf.ssid, 0, 32);
  c_memset(sta_conf.password, 0, 64);
  c_memset(sta_conf.bssid, 0, 6);
  c_memcpy(sta_conf.ssid, ssid, sl);
  c_memcpy(sta_conf.password, password, pl);
  sta_conf.bssid_set = 0;

  NODE_DBG(sta_conf.ssid);
  NODE_DBG(" %d\n", sl);
  NODE_DBG(sta_conf.password);
  NODE_DBG(" %d\n", pl);

  wifi_station_set_config(&sta_conf);
  wifi_station_set_auto_connect(true);
  wifi_station_disconnect();
  wifi_station_connect();
  // station_check_connect(0);
  return 0;  
}
Esempio n. 17
0
int sj_wifi_setup_sta(const char *ssid, const char *pass) {
  int res;
  struct station_config stationConf;
  /* Switch to station mode if not already in it. */
  if (wifi_get_opmode() != 0x1) {
    wifi_set_opmode_current(0x1);
  }
  wifi_station_disconnect();

  stationConf.bssid_set = 0;
  strncpy((char *) &stationConf.ssid, ssid, 32);
  strncpy((char *) &stationConf.password, pass, 64);

  res = wifi_station_set_config_current(&stationConf);
  if (!res) {
    fprintf(stderr, "Failed to set station config\n");
    return 0;
  }

  res = wifi_station_connect();
  if (res) {
    wifi_setting_up = 1;
  }
  return 1;
}
Esempio n. 18
0
void wifiConnectTimerCb(void *arg)
{
	/* Do we have an IP already? */
	int status = wifi_station_get_connect_status();
	if( status != STATION_GOT_IP)
	{
		/* No, then connect to the WiFi station */
		wifi_station_disconnect();

		os_printf("Trying to connect to %s\n", stconf.ssid );

		/* connect to a WiFi station */
		wifi_station_connect();
	}
	else
	{
		/* yes, then disable the timer WiFi setup timer*/
		os_timer_disarm(&wifi_setup_timer);

		/* enable POST timer in periodic mode */
		os_timer_disarm((ETSTimer*)&post_timer);
		os_timer_setfn((ETSTimer*)&post_timer, (os_timer_func_t *) startHttpRequestTimerCallback, NULL);
		os_timer_arm((ETSTimer*)&post_timer, 10000, 0); // thingspeak needs minimum 15 sec delay between updates
	}
}
Esempio n. 19
0
void ICACHE_FLASH_ATTR WIFI_999_Connect(uint8_t* ssid, uint8_t* pass, WifiCallback cb)
{
	struct station_config stationConf;

	INFO("WIFI_INIT\r\n");
	wifi_set_opmode(STATION_MODE);
	wifi_station_set_auto_connect(FALSE);
	wifiCb = cb;

	os_memset(&stationConf, 0, sizeof(struct station_config));

	os_sprintf(stationConf.ssid, "%s", ssid);
	os_sprintf(stationConf.password, "%s", pass);

	wifi_station_set_config(&stationConf);

	os_timer_disarm(&WiFiLinker);
	os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
	os_timer_arm(&WiFiLinker, 1000, 0);

	wifi_station_set_auto_connect(TRUE);
	/*
	 * Reconnect is only in SDK 1.2 and newer.  :-(
	 *
	 * wifi_station_set_reconnect_policy(TRUE);	// After a hint from Pete Scargill.
	 */
	wifi_station_connect();
}
Esempio n. 20
0
/**
 * will force a disconnect an then start reconnecting to AP
 * @return ok
 */
bool ESP8266WiFiSTAClass::reconnect() {
    if((WiFi.getMode() & WIFI_STA) != 0) {
        if(wifi_station_disconnect()) {
            return wifi_station_connect();
        }
    }
    return false;
}
Esempio n. 21
0
void ESP8266WiFiClass::_smartConfigDone(void* result)
{
    station_config* sta_conf = reinterpret_cast<station_config*>(result);
  
    wifi_station_set_config(sta_conf);
    wifi_station_disconnect();
    wifi_station_connect();
}
Esempio n. 22
0
void ICACHE_FLASH_ATTR
smartconfig_done(void *data)
{
	struct station_config *sta_conf = data;

	wifi_station_set_config(sta_conf);
	wifi_station_disconnect();
	wifi_station_connect();
}
Esempio n. 23
0
LOCAL void initDone() {
wifi_set_opmode_current(STATION_MODE);
struct station_config stationConfig;
strncpy(stationConfig.ssid, "ur_ssid", 32);
strncpy(stationConfig.password, "ur_password", 64);
wifi_station_set_config(&stationConfig);
wifi_station_connect();

} 
Esempio n. 24
0
// setMode must be called with Client or ClientAndAccessPoint
void STC_FLASHMEM WiFi::configureClient(char const *SSID, char const *securityKey) {
  station_config config = {0};
  f_strcpy((char *)config.ssid, SSID);
  f_strcpy((char *)config.password, securityKey);
  Critical critical;
  wifi_station_disconnect();
  wifi_station_set_config(&config);
  wifi_station_connect();
}
Esempio n. 25
0
int ESP8266WiFiClass::begin()
{
    ETS_UART_INTR_DISABLE();
    wifi_station_connect();
    ETS_UART_INTR_ENABLE();

    if(!_useStaticIp)
        wifi_station_dhcpc_start();
    return status();
}
Esempio n. 26
0
bool StationClass::config(String ssid, String password, bool autoConnectOnStartup /* = true*/)
{
	station_config config = {0};

	if (ssid.length() >= sizeof(config.ssid)) return false;
	if (password.length() >= sizeof(config.password)) return false;

	bool enabled = isEnabled();
	bool dhcp = isEnabledDHCP();
	enable(true); // Power on for configuration

	wifi_station_disconnect();
	if (dhcp) enableDHCP(false);
	bool cfgreaded = wifi_station_get_config(&config);
	if (!cfgreaded) debugf("Can't read station configuration!");

	memset(config.ssid, 0, sizeof(config.ssid));
	memset(config.password, 0, sizeof(config.password));
	config.bssid_set = false;
	strcpy((char*)config.ssid, ssid.c_str());
	strcpy((char*)config.password, password.c_str());

	noInterrupts();
	if(!wifi_station_set_config(&config))
	{
		interrupts();
		debugf("Can't set station configuration!");
		wifi_station_connect();
		enableDHCP(dhcp);
		enable(enabled);
		return false;
	}
	debugf("Station configuration was updated to: %s", ssid.c_str());

	interrupts();
	wifi_station_connect();
	enableDHCP(dhcp);
	enable(enabled);

	wifi_station_set_auto_connect(autoConnectOnStartup);

	return true;
}
Esempio n. 27
0
// Function that will run after initialization is done, contains information to connect to the WIFI and SNTP settings
LOCAL ICACHE_FLASH_ATTR void initDone()
{
    wifi_set_opmode_current(STATION_MODE);
    struct station_config stationConfig;
    strncpy(stationConfig.ssid, ur_ssid, 32);
    strncpy(stationConfig.password, ur_ssid_password, 64);
    wifi_station_set_config(&stationConfig);
    wifi_station_connect();
    my_sntp_init(); // This will setup the sntp and it seems to take some time.
}
Esempio n. 28
0
// Callback actually doing reassociation
static void ICACHE_FLASH_ATTR reassTimerCb(void *arg) {
	os_printf("Wifi changing association\n");
	wifi_station_disconnect();
	wifi_station_set_config(&stconf);
	wifi_station_connect();
	// Schedule check
	os_timer_disarm(&resetTimer);
	os_timer_setfn(&resetTimer, resetTimerCb, NULL);
	os_timer_arm(&resetTimer, RESET_TIMEOUT, 0);
}
Esempio n. 29
0
LOCAL void initDone() {
  os_printf("Initialized! \n");

  struct station_config config;
  strncpy(config.ssid, SSID, 32);
  strncpy(config.password, SSID_PASSWORD, 64);

  wifi_set_opmode_current(STATION_MODE);
  wifi_station_set_config_current(&config);
  wifi_station_connect();
}
/**
 * wake up WiFi Modem
 * @return ok
 */
bool ESP8266WiFiGenericClass::forceSleepWake() {
    wifi_fpm_do_wakeup();
    wifi_fpm_close();

    // restore last mode
    if(mode(_forceSleepLastMode)) {
        if((_forceSleepLastMode & WIFI_STA) != 0){
            wifi_station_connect();
        }
        return true;
    }
    return false;
}