Пример #1
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();
}
Пример #2
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;
}
Пример #3
0
int ESP8266WiFiClass::disconnect(bool wifioff)
{
    struct station_config conf;
    *conf.ssid = 0;
    *conf.password = 0;
    ETS_UART_INTR_DISABLE();
    if (_persistent)
        wifi_station_set_config(&conf);
    else
        wifi_station_set_config_current(&conf);
    wifi_station_disconnect();
    ETS_UART_INTR_ENABLE();

    if(wifioff) {
        _useClientMode = false;

        if(_useApMode) {
            // turn on AP
            _mode(WIFI_AP);
        } else {
            // turn wifi off
            _mode(WIFI_OFF);
        }
    }

    return 0;
}
Пример #4
0
void ICACHE_FLASH_ATTR set_wifi()
{
	wifi_set_opmode(0x01);
	char myssid[32] = "";
	char mypasswd[64] = "";
	struct station_config my_wifi;
	os_memcpy(&my_wifi.ssid, myssid, 32);
	os_memcpy(&my_wifi.password, mypasswd, 64);
	wifi_station_set_config(&my_wifi);
	wifi_station_set_config_current(&my_wifi);
}
Пример #5
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();
}
Пример #6
0
static void wifi_connect() {
  struct station_config conf;
  wifi_station_set_auto_connect(FALSE);
  wifi_set_event_handler_cb(wifi_change_cb);
  strcpy((char *) conf.ssid, NETWORK_SSID);
  strcpy((char *) conf.password, NETWORK_PWD);
  printf("connecting to %s\n", conf.ssid);
  conf.bssid_set = 0;
  wifi_set_opmode_current(STATION_MODE);
  wifi_station_disconnect();
  wifi_station_set_config_current(&conf);
  wifi_station_connect();
}
Пример #7
0
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_current(STATION_MODE);
  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_current(&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_connect();
}
Пример #8
0
//Init function 
void ICACHE_FLASH_ATTR
user_init()
{
    char ssid[32] = "MY_SSID";
    char password[64] = "MY_PASS";
    struct station_config stationConf;
    
    os_printf("Init a\n\r");

    uart_init(BIT_RATE_115200, BIT_RATE_115200);

    gpio16_output_conf();

    gpio16_output_set(0);

    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);
    
    gpio_output_set(0, BIT12|BIT13|BIT14, BIT12|BIT13|BIT14, 0);

    //Set station mode
    //wifi_set_macaddr(uint8 if_index, uint8 *macaddr)
    wifi_set_opmode_current( STATION_MODE );
    os_memcpy(&stationConf.ssid, ssid, 32);
    os_memcpy(&stationConf.password, password, 64);
    stationConf.bssid_set = 0;
    wifi_station_set_config_current(&stationConf);
//    wifi_status_led_install (16, uint32 gpio_name, FUNC_GPIO16)

    os_printf("Init Ok! %d\n\r", wifi_station_get_connect_status());


    wifi_station_set_auto_connect(1);

    wifi_station_connect();

    wifi_station_dhcpc_start();
    
    user_server_init(8888);

    //Start os task
    system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);

  //  system_os_post(user_procTaskPrio, 0, 0 );

}
Пример #9
0
/**
 * Disconnect from the network
 * @param wifioff
 * @return  one value of wl_status_t enum
 */
bool ESP31BWiFiSTAClass::disconnect(bool wifioff) {
    bool ret;
    struct station_config conf;
    *conf.ssid = 0;
    *conf.password = 0;

    if(WiFi._persistent) {
        wifi_station_set_config(&conf);
    } else {
        wifi_station_set_config_current(&conf);
    }
    ret = wifi_station_disconnect();

    if(wifioff) {
        WiFi.enableSTA(false);
    }

    return ret;
}
Пример #10
0
void ICACHE_FLASH_ATTR configure(void){
	restartActive=0;
        struct station_config st_config;
       	memset(st_config.ssid, 0, sizeof(st_config.ssid));
	memcpy(st_config.ssid, ssid_name, strlen(ssid_name));
	//st_config.ssid_len=strlen(ssid_name);
	memset(st_config.password, 0, sizeof(st_config.password));
	memcpy(st_config.password, password, strlen(password));
//	if(!isnew){
	     memset(user_config.ssid, 0, sizeof(user_config.ssid));
	     memcpy(user_config.ssid, ssid_name, strlen(ssid_name));
	     memset(user_config.pwd, 0, sizeof(user_config.pwd));
	     memcpy(user_config.pwd, password, strlen(password));
//	}
	printf("STA config: SSID: %s, PASSWORD: %s\r\n",st_config.ssid,st_config.password );
	printf("info: SSID: %s, PASSWORD: %s\r\n",ssid_name,password );
int ch;
        wifi_softap_dhcps_stop();
	wifi_set_event_handler_cb(wifi_event_cb);
	//vTaskDelay( xDelay );
         wifi_set_opmode(NULL_MODE);
	vTaskDelay( xDelay );
       //save_user_config(&user_config);
        wifi_set_opmode(STATION_MODE);
        //vTaskDelay( xDelay );
        wifi_station_set_config_current(&st_config);
	
//	int ret = wifi_station_set_auto_connect(1);
	//vTaskDelay( xDelay );
        wifi_station_connect();
	//vTaskDelay( xDelay );
        wifi_station_dhcpc_start();
	//vTaskDelay( 100 );
	//vTaskDelay( 100 );
	

	coap_restart(1);
}
Пример #11
0
/**
 * Start Wifi connection
 * if passphrase is set the most secure supported mode will be automatically selected
 * @param ssid const char*          Pointer to the SSID string.
 * @param passphrase const char *   Optional. Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal).
 * @param bssid uint8_t[6]          Optional. BSSID / MAC of AP
 * @param channel                   Optional. Channel of AP
 * @param connect                   Optional. call connect
 * @return
 */
wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_t channel, const uint8_t* bssid, bool connect) {

    if(!WiFi.enableSTA(true)) {
        // enable STA failed
        return WL_CONNECT_FAILED;
    }

    if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
        // fail SSID too long or missing!
        return WL_CONNECT_FAILED;
    }

    if(passphrase && strlen(passphrase) > 63) {
        // fail passphrase too long!
        return WL_CONNECT_FAILED;
    }

    struct station_config conf;
    strcpy(reinterpret_cast<char*>(conf.ssid), ssid);

    if(passphrase) {
        strcpy(reinterpret_cast<char*>(conf.password), passphrase);
    } else {
        *conf.password = 0;
    }

    if(bssid) {
        conf.bssid_set = 1;
        memcpy((void *) &conf.bssid[0], (void *) bssid, 6);
    } else {
        conf.bssid_set = 0;
    }

    struct station_config current_conf;
    wifi_station_get_config(&current_conf);
    if(sta_config_equal(current_conf, conf)) {
        DEBUGV("sta config unchanged");
        return status();
    }

    ETS_UART_INTR_DISABLE();

    if(WiFi._persistent) {
        wifi_station_set_config(&conf);
    } else {
        wifi_station_set_config_current(&conf);
    }

    if(connect) {
        wifi_station_connect();
    }

    ETS_UART_INTR_ENABLE();

    if(channel > 0 && channel <= 13) {
        wifi_set_channel(channel);
    }

    if(!_useStaticIp) {
        wifi_station_dhcpc_start();
    }

    return status();
}
Пример #12
0
static void _esp_wifi_setup(void)
{
    esp_wifi_netdev_t* dev = &_esp_wifi_dev;

    ESP_WIFI_DEBUG("%p", dev);

    if (dev->netdev.driver) {
        ESP_WIFI_DEBUG("early returning previously initialized device");
        return;
    }

    /* initialize netdev data structure */
    dev->rx_len = 0;
    dev->state = ESP_WIFI_DISCONNECTED;
    dev->event = EVENT_MAX;

    /* set the netdev driver */
    dev->netdev.driver = &_esp_wifi_driver;

#ifndef MODULE_ESP_NOW
    /* set the WiFi interface mode */
    if (!wifi_set_opmode_current(ESP_WIFI_MODE)) {
        ESP_WIFI_LOG_ERROR("could not set WiFi working mode");
        return;
    }

    /* set the WiFi SoftAP configuration */
    if (!wifi_softap_set_config_current((struct softap_config *)&softap_cfg)) {
        ESP_WIFI_LOG_ERROR("could not set WiFi configuration");
        return;
    }
#endif

    /* set the WiFi station configuration */
    if (!wifi_station_set_config_current((struct station_config *)&station_cfg)) {
        ESP_WIFI_LOG_ERROR("could not set WiFi configuration");
        return;
    }

    /* get station mac address and store it in device address */
    if (!wifi_get_macaddr(ESP_WIFI_STATION_IF, dev->mac)) {
        ESP_WIFI_LOG_ERROR("could not get MAC address of WiFi interface");
        return;
    }
    ESP_WIFI_DEBUG("own MAC addr is " MAC_STR, MAC_STR_ARG(dev->mac));

    /* set auto reconnect policy */
    wifi_station_set_reconnect_policy(true);
    wifi_station_set_auto_connect(true);

    /* register callbacks */
    wifi_set_event_handler_cb(_esp_wifi_handle_event_cb);

    /* reconnect timer initialization */
    _esp_wifi_reconnect_timer.callback = &_esp_wifi_reconnect_timer_cb;
    _esp_wifi_reconnect_timer.arg = dev;

    /* set the the reconnect timer */
    xtimer_set(&_esp_wifi_reconnect_timer, ESP_WIFI_RECONNECT_TIME);

    /* avoid the WiFi modem going into sleep mode */
    wifi_set_sleep_type(NONE_SLEEP_T);

    /* connect */
    wifi_station_connect();
    _esp_wifi_dev.state = ESP_WIFI_CONNECTING;

    return;
}
Пример #13
0
void wifi_init() {
	wifi_set_opmode(NULL_MODE); //Next time start up in NULL mode
	wifi_set_opmode_current(NULL_MODE);

	//Initialize station config parameters
	struct station_config stconf;
	memset(&stconf, 0, sizeof(stconf));
	strncpy((char *)stconf.ssid, szWifiSsid, sizeof(stconf.ssid));
	strncpy((char *)stconf.password, szWifiPassword, sizeof(stconf.password));
	stconf.ssid[sizeof(stconf.ssid)-1]='\0';
	stconf.password[sizeof(stconf.password)-1]='\0';

	//Initialize AP config parameters
	struct softap_config apconf;
	memset(&apconf, 0, sizeof(apconf));
	// SSID
	strncpy((char *)apconf.ssid, szWifiSsid, sizeof(apconf.ssid));
	apconf.ssid[sizeof(apconf.ssid)-1]='\0';
	// Password & encryption
	strncpy((char *)apconf.password, szWifiPassword, sizeof(apconf.password));
	apconf.password[sizeof(apconf.password)-1]='\0';
	if (strlen(szWifiPassword) >= 8) {
		apconf.authmode = AUTH_WPA_WPA2_PSK;
	} else {
		// if password <8 characters, don't use password.
		apconf.authmode = AUTH_WEP;
		memset(apconf.password, 0, sizeof(apconf.password));
	}
	apconf.max_connection = 255;
	apconf.beacon_interval = 100;

	wifi_set_opmode_current(nWifiMode);
	wifi_softap_set_config_current(&apconf);
	wifi_station_set_config_current(&stconf);

	struct ip_info ipinfo;
	memset(&ipinfo, 0, sizeof(ipinfo));
	ipinfo.ip.addr = aIP;
	ipinfo.netmask.addr = aNetmask;
	ipinfo.gw.addr = aGateway;

	if (nWifiMode == STATION_MODE) {
		wifi_station_dhcpc_stop();
		wifi_station_set_hostname(szHostname);
		if (bUseDhcp) {
			wifi_station_dhcpc_start();
		} else {
			wifi_set_ip_info(STATION_IF, &ipinfo);
		}
	} else {
		// DHCP Server should be stopped to change IP information
		wifi_softap_dhcps_stop();
		wifi_set_ip_info(SOFTAP_IF, &ipinfo);

		uint32_t aFirstIp = (aIP & aNetmask) | 1;
		uint32_t aLastIp = (aIP & aNetmask) | (-1 & ~aNetmask);
		struct dhcps_lease leases;
		memset(&leases, 0, sizeof(leases));
		// Determine whether the range before or after our IP is bigger
		if (aIP - aFirstIp > aLastIp - aIP) {
			leases.start_ip.addr = aFirstIp;
			leases.end_ip.addr = aIP - 1;
		} else {
			leases.start_ip.addr = aIP + 1;
			leases.end_ip.addr = aLastIp;
		}
		wifi_softap_set_dhcps_lease(&leases);
		uint8_t offer_router = 0;
		wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &offer_router);
		wifi_softap_dhcps_start();
	}
}
Пример #14
0
/**
 * Start Wifi connection
 * if passphrase is set the most secure supported mode will be automatically selected
 * @param ssid const char*          Pointer to the SSID string.
 * @param passphrase const char *   Optional. Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal).
 * @param bssid uint8_t[6]          Optional. BSSID / MAC of AP
 * @param channel                   Optional. Channel of AP
 * @param connect                   Optional. call connect
 * @return
 */
wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_t channel, const uint8_t* bssid, bool connect) {

    if(!WiFi.enableSTA(true)) {
        // enable STA failed
        return WL_CONNECT_FAILED;
    }

    if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
        // fail SSID too long or missing!
        return WL_CONNECT_FAILED;
    }

    if(passphrase && strlen(passphrase) > 64) {
        // fail passphrase too long!
        return WL_CONNECT_FAILED;
    }

    struct station_config conf;
    strcpy(reinterpret_cast<char*>(conf.ssid), ssid);

    if(passphrase) {
        if (strlen(passphrase) == 64) // it's not a passphrase, is the PSK, which is copied into conf.password without null term
            memcpy(reinterpret_cast<char*>(conf.password), passphrase, 64);
        else
            strcpy(reinterpret_cast<char*>(conf.password), passphrase);
    } else {
        *conf.password = 0;
    }

    conf.threshold.rssi = -127;

    // TODO(#909): set authmode to AUTH_WPA_PSK if passphrase is provided
    conf.threshold.authmode = AUTH_OPEN;

    if(bssid) {
        conf.bssid_set = 1;
        memcpy((void *) &conf.bssid[0], (void *) bssid, 6);
    } else {
        conf.bssid_set = 0;
    }

    struct station_config conf_compare;
    if(WiFi._persistent){
        wifi_station_get_config_default(&conf_compare);
    }
    else {
        wifi_station_get_config(&conf_compare);
    }

    if(sta_config_equal(conf_compare, conf)) {
        DEBUGV("sta config unchanged");
    }
    else {
        ETS_UART_INTR_DISABLE();

        if(WiFi._persistent) {
            wifi_station_set_config(&conf);
        } else {
            wifi_station_set_config_current(&conf);
        }

        ETS_UART_INTR_ENABLE();
    }

    ETS_UART_INTR_DISABLE();
    if(connect) {
        wifi_station_connect();
    }
    ETS_UART_INTR_ENABLE();

    if(channel > 0 && channel <= 13) {
        wifi_set_channel(channel);
    }

    if(!_useStaticIp) {
        wifi_station_dhcpc_start();
    }

    return status();
}
Пример #15
0
void ICACHE_FLASH_ATTR network_connect(void) {
    wifi_set_opmode_current(STATION_MODE);
    wifi_station_set_config_current(&station_config);
    wifi_station_connect();
}
Пример #16
0
int ESP8266WiFiClass::begin_internal(const char* ssid, const char *passphrase, int32_t channel, const uint8_t* bssid)
{
    _useClientMode = true;

    if(_useApMode) {
        // turn on AP+STA mode
        _mode(WIFI_AP_STA);
    } else {
        // turn on STA mode
        _mode(WIFI_STA);
    }

    if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
        // fail SSID too long or missing!
        return WL_CONNECT_FAILED;
    }

    if(passphrase && strlen(passphrase) > 63) {
        // fail passphrase too long!
        return WL_CONNECT_FAILED;
    }

    struct station_config conf;
    strcpy(reinterpret_cast<char*>(conf.ssid), ssid);

    if (passphrase) {
        strcpy(reinterpret_cast<char*>(conf.password), passphrase);
    } else {
        *conf.password = 0;
    }

    if (bssid) {
        conf.bssid_set = 1;
        memcpy((void *) &conf.bssid[0], (void *) bssid, 6);
    } else {
        conf.bssid_set = 0;
    }

    struct station_config current_conf;
    wifi_station_get_config(&current_conf);
    if (sta_config_equal(current_conf, conf)) {
        DEBUGV("sta config unchanged");
        return status();
    }

    ETS_UART_INTR_DISABLE();
    if (_persistent)
        wifi_station_set_config(&conf);
    else
        wifi_station_set_config_current(&conf);
    wifi_station_connect();
    ETS_UART_INTR_ENABLE();

    if(channel > 0 && channel <= 13) {
        wifi_set_channel(channel);
    }

    if(!_useStaticIp)
        wifi_station_dhcpc_start();
    return status();
}
Пример #17
0
/**
 * Start Wifi connection
 * if passphrase is set the most secure supported mode will be automatically selected
 * @param ssid const char*          Pointer to the SSID string.
 * @param passphrase const char *   Optional. Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal).
 * @param bssid uint8_t[6]          Optional. BSSID / MAC of AP
 * @param channel                   Optional. Channel of AP
 * @param connect                   Optional. call connect
 * @return
 */
wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_t channel, const uint8_t* bssid, bool connect) {

    if(!WiFi.enableSTA(true)) {
        // enable STA failed
        return WL_CONNECT_FAILED;
    }

    if(!ssid || *ssid == 0x00 || strlen(ssid) > 32) {
        // fail SSID too long or missing!
        return WL_CONNECT_FAILED;
    }

    int passphraseLen = passphrase == nullptr ? 0 : strlen(passphrase);
    if(passphraseLen > 64) {
        // fail passphrase too long!
        return WL_CONNECT_FAILED;
    }

    struct station_config conf;
    conf.threshold.authmode = (passphraseLen == 0) ? AUTH_OPEN : (_useInsecureWEP ? AUTH_WEP : AUTH_WPA_PSK);

    if(strlen(ssid) == 32)
        memcpy(reinterpret_cast<char*>(conf.ssid), ssid, 32); //copied in without null term
    else
        strcpy(reinterpret_cast<char*>(conf.ssid), ssid);

    if(passphrase) {
        if (passphraseLen == 64) // it's not a passphrase, is the PSK, which is copied into conf.password without null term
            memcpy(reinterpret_cast<char*>(conf.password), passphrase, 64);
        else
            strcpy(reinterpret_cast<char*>(conf.password), passphrase);
    } else {
        *conf.password = 0;
    }

    conf.threshold.rssi = -127;
    conf.open_and_wep_mode_disable = !(_useInsecureWEP || *conf.password == 0);

    if(bssid) {
        conf.bssid_set = 1;
        memcpy((void *) &conf.bssid[0], (void *) bssid, 6);
    } else {
        conf.bssid_set = 0;
    }

    struct station_config conf_compare;
    if(WiFi._persistent){
        wifi_station_get_config_default(&conf_compare);
    }
    else {
        wifi_station_get_config(&conf_compare);
    }

    if(sta_config_equal(conf_compare, conf)) {
        DEBUGV("sta config unchanged");
    }
    else {
        ETS_UART_INTR_DISABLE();

        if(WiFi._persistent) {
            wifi_station_set_config(&conf);
        } else {
            wifi_station_set_config_current(&conf);
        }

        ETS_UART_INTR_ENABLE();
    }

    ETS_UART_INTR_DISABLE();
    if(connect) {
        wifi_station_connect();
    }
    ETS_UART_INTR_ENABLE();

    if(channel > 0 && channel <= 13) {
        wifi_set_channel(channel);
    }

    if(!_useStaticIp) {
        wifi_station_dhcpc_start();
    }

    return status();
}
Пример #18
0
void ICACHE_FLASH_ATTR settings_apply( userSettings_t *settings )
{
  //Description
  if (!((settings->magic==0x42)&&(settings->version==SETTINGS_VERSION))) {
    os_printf("<ERROR: CAN NOT APPLY CORRUPT SETTINGS!>\n\r");
    return;
  }
  
  if (settings->connection_successful) {
    ap_stop();
  } else {
    ap_start();
  }
  
  //Device information
  wifi_station_set_hostname(settings->name);
  
  //Network
  struct station_config stationConf;
  wifi_station_get_config( &stationConf );
  stationConf.bssid_set = 0;
  os_memcpy( &stationConf.ssid, settings->ssid, 32 );
  os_memcpy( &stationConf.password, settings->password, 64 );
  wifi_station_set_config_current( &stationConf );
  os_printf("########################## Wifi config set to SSID '%s' and PASSWORD '%s'.\n\r", settings->ssid, settings->password);
  if (settings->enable_dhcp) {
    wifi_station_dhcpc_start();
  } else {
    wifi_station_dhcpc_stop();
    struct ip_info dhcpc_ip_info;
    IP4_ADDR(&dhcpc_ip_info.ip, settings->static_ip_1, settings->static_ip_2, settings->static_ip_3, settings->static_ip_4);
    IP4_ADDR(&dhcpc_ip_info.gw, settings->static_gateway_1, settings->static_gateway_2, settings->static_gateway_3, settings->static_gateway_4);
    IP4_ADDR(&dhcpc_ip_info.netmask, settings->static_netmask_1, settings->static_netmask_2, settings->static_netmask_3, settings->static_netmask_4);
    wifi_set_ip_info(STATION_IF, &dhcpc_ip_info);
  }
  wifi_station_disconnect();
  
  //MDNS
  if (settings->enable_mdns)
  {
    /*wifi_set_broadcast_if(STATIONAP_MODE);
    struct mdns_info *info = (struct mdns_info *) os_zalloc(sizeof(struct mdns_info));
    info->host_name = settings->mdns_hostname;
    info->ipAddr = station_ipconfig.ip.addr; //ESP8266 station IP
    info->server_name = "FirmwaRe MDNS";
    info->server_port = 80;
    info->txt_data[0] = “version = now”;
    info->txt_data[1] = “user1 = data1”;
    info->txt_data[2] = “user2 = data2”;
    espconn_mdns_init(info);*/
  }
  
  //NTP
  if (settings->enable_ntp)
  {
    //settings->ntpserver
    //settings->timezone
    //settings->enable_summertime
  }
  
  //Security
  /* settings->password; */

  //Digital outputs
  #if OUTPUT1>-1
    if (settings->bootstate&1){
      board_setOutput(OUTPUT1, true);
    } else {
      board_setOutput(OUTPUT1, false);
    }
  #endif
  #if OUTPUT2>-1
    if (settings->bootstate&2) {
      board_setOutput(OUTPUT2, true);
    } else {
      board_setOutput(OUTPUT2, false);
    }
  #endif
  #if OUTPUT3>-1
    if (settings->bootstate&4) {
      board_setOutput(OUTPUT3, true);
    } else {
      board_setOutput(OUTPUT3, false);
    }
  #endif
  #if OUTPUT4>-1
    if (settings->bootstate&8) {
      board_setOutput(OUTPUT4, true);
    } else {
      board_setOutput(OUTPUT4, false);
    }
  #endif
  #if OUTPUT5>-1
    if (settings->bootstate&16) {
      board_setOutput(OUTPUT5, true);
    } else {
      board_setOutput(OUTPUT5, false);
    }
  #endif
  #if OUTPUT6>-1
    if (settings->bootstate&32) {
      board_setOutput(OUTPUT6, true);
    } else {
      board_setOutput(OUTPUT6, false);
    }
  #endif
  #if OUTPUT7>-1
    if (settings->bootstate&64) {
      board_setOutput(OUTPUT7, true);
    } else {
      board_setOutput(OUTPUT7, false);
    }
  #endif
  #if OUTPUT8>-1
    if (settings->bootstate&128) {
      board_setOutput(OUTPUT8, true);
    } else {
      board_setOutput(OUTPUT8, false);
    }
  #endif

  //ESPLight
  setPWM(settings->bootstate_R, settings->bootstate_G, settings->bootstate_B);
  //settings->ledstrip_type;
  //settings->ledstrip_length;
  
  //PKA
  /* settings->pka_wb settings->pka_wb_time */
}