コード例 #1
1
ファイル: wifi.c プロジェクト: wriley/iMailbox
void setup_wifi_ap_mode(void)
{
	wifi_set_opmode((wifi_get_opmode()|SOFTAP_MODE)&STATIONAP_MODE);
	struct softap_config apconfig;
	if(wifi_softap_get_config(&apconfig))
	{
		wifi_softap_dhcps_stop();
		memset(apconfig.ssid, 0, sizeof(apconfig.ssid));
		memset(apconfig.password, 0, sizeof(apconfig.password));
		apconfig.ssid_len = os_sprintf(apconfig.ssid, WIFI_AP_NAME);
		os_sprintf(apconfig.password, "%s", WIFI_AP_PASSWORD);
		apconfig.authmode = AUTH_WPA_WPA2_PSK;
		apconfig.ssid_hidden = 0;
		apconfig.channel = 7;
		apconfig.max_connection = 4;
		if(!wifi_softap_set_config(&apconfig))
		{
			#ifdef PLATFORM_DEBUG
			os_printf("ESP8266 not set AP config!\r\n");
			#endif
		};
		struct ip_info ipinfo;
		wifi_get_ip_info(SOFTAP_IF, &ipinfo);
		IP4_ADDR(&ipinfo.ip, 192, 168, 4, 1);
		IP4_ADDR(&ipinfo.gw, 192, 168, 4, 1);
		IP4_ADDR(&ipinfo.netmask, 255, 255, 255, 0);
		wifi_set_ip_info(SOFTAP_IF, &ipinfo);
		wifi_softap_dhcps_start();
	}
	#ifdef PLATFORM_DEBUG
	os_printf("ESP8266 in AP mode configured.\r\n");
	#endif
}
コード例 #2
0
ファイル: user_main.c プロジェクト: ray-d/MeWifiModule
void ICACHE_FLASH_ATTR
load_userParam(void)
{
	struct softap_config config;
    spi_flash_read((ESP_PARAM_START_SEC + 1) * SPI_FLASH_SEC_SIZE,
                   (uint32 *)&myParam, sizeof(USER_PARAM));

	// default setup
	if(myParam.sign!=4771215){
		myParam.sign = 4771215;
		myParam.baud_rate = BIT_RATE_115200;
		myParam.port = 1025;
		spi_flash_erase_sector(ESP_PARAM_START_SEC + 1);
        spi_flash_write((ESP_PARAM_START_SEC + 1) * SPI_FLASH_SEC_SIZE,
                        (uint32 *)&myParam, sizeof(USER_PARAM));
		wifi_set_opmode(STATIONAP_MODE);
		wifi_softap_get_config(&config);
		
		config.authmode = AUTH_OPEN;
        wifi_softap_set_config(&config);
		
	}
    spi_flash_read((ESP_PARAM_START_SEC + 1) * SPI_FLASH_SEC_SIZE,
                   (uint32 *)&myParam, sizeof(USER_PARAM));
}
コード例 #3
0
/******************************************************************************
 * FunctionName : mesh_SetSoftap
 * Description  : If the device failed to join mesh network,
                  open the SoftAP interface for webserver
                  The SSID should not be the same form as that of the device in mesh network
*******************************************************************************/
void ICACHE_FLASH_ATTR
mesh_SetSoftap()
{
    MESH_INFO("----------------------\r\n");
    MESH_INFO("MESH ENABLE SOFTAP \r\n");
    MESH_INFO("----------------------\r\n");
    struct softap_config config_softap;
    char ssid[33]={0};
    wifi_softap_get_config(&config_softap);
    os_memset(config_softap.password, 0, sizeof(config_softap.password));
    os_memset(config_softap.ssid, 0, sizeof(config_softap.ssid));
    os_sprintf(ssid,"ESP_%06X",system_get_chip_id());
    os_memcpy(config_softap.ssid, ssid, os_strlen(ssid));
    config_softap.ssid_len = os_strlen(ssid);
    config_softap.ssid_hidden = 0;
    config_softap.channel = wifi_get_channel();
    #ifdef SOFTAP_ENCRYPT
        char password[33];
        char macaddr[6];
        os_sprintf(password, MACSTR "_%s", MAC2STR(macaddr), PASSWORD);
        os_memcpy(config_softap.password, password, os_strlen(password));
        config_softap.authmode = AUTH_WPA_WPA2_PSK;
    #else
        os_memset(config_softap.password,0,sizeof(config_softap.password));
        config_softap.authmode = AUTH_OPEN;
    #endif
    wifi_set_opmode(STATIONAP_MODE);
    wifi_softap_set_config(&config_softap);
    wifi_set_opmode(STATIONAP_MODE);
    wifi_softap_get_config(&config_softap);
    MESH_INFO("SSID: %s \r\n",config_softap.ssid);
    MESH_INFO("CHANNEL: %d \r\n",config_softap.channel);
    MESH_INFO("-------------------------\r\n");
}
コード例 #4
0
ファイル: wifi.c プロジェクト: JanisIOT/JanisEsp8266
void ICACHE_FLASH_ATTR config_wifi_new(void){
        wifi_softap_dhcps_stop();
	//vTaskDelay( xDelay );
        wifi_set_opmode(NULL_MODE);
	//vTaskDelay( xDelay );
	wifi_set_opmode(SOFTAP_MODE);
	//vTaskDelay( xDelay );
	struct softap_config apConfig;
	char ssid[8];
	wifi_set_event_handler_cb(wifi_event_cb);
	//mode_info();
	memset(apConfig.ssid, 0, sizeof(apConfig.ssid));
	sprintf(ssid, "%s\0", WIFI_APSSID);
	memcpy(apConfig.ssid, ssid, strlen(ssid));
	printf("SSID %s\n",apConfig.ssid);
	apConfig.authmode = AUTH_OPEN;
	apConfig.channel = 5;
	apConfig.ssid_len=strlen(ssid);
	apConfig.max_connection = 255;
	apConfig.ssid_hidden = 0;
	wifi_softap_set_config(&apConfig);
	//vTaskDelay( xDelay );
	wifi_softap_dhcps_start();
	//vTaskDelay( xDelay*10 );
	coap_restart(0);
}
コード例 #5
0
ファイル: ESP8266WiFi.cpp プロジェクト: ccaroon/arduino
int ESP8266WiFiClass::softAPdisconnect(bool wifioff)
{
    struct softap_config conf;
    *conf.ssid = 0;
    *conf.password = 0;
    ETS_UART_INTR_DISABLE();
    if (_persistent)
        wifi_softap_set_config(&conf);
    else
        wifi_softap_set_config_current(&conf);
    ETS_UART_INTR_ENABLE();

    if(wifioff) {
        _useApMode = false;

        if( _useClientMode) {
            // turn on STA
            _mode(WIFI_STA);
        } else {
            // turn wifi off
            _mode(WIFI_OFF);
        }
    }

    return 0;
}
コード例 #6
0
ファイル: user_main.c プロジェクト: andresvidal/esp-ginx
static void config_wifi(){
    NODE_DBG("Putting AP UP");

    platform_key_led(0);    
    
    wifi_station_set_auto_connect(1); 
    wifi_set_opmode(0x03); // station+ap mode                       

    struct softap_config config;
    wifi_softap_get_config(&config);

    char ssid[]="SmartRelay"SERIAL_NUMBER;

    strcpy(config.ssid,ssid);
    memset(config.password,0,64);
    config.ssid_len=strlen(ssid);
    config.channel=11;
    config.authmode=AUTH_OPEN;
    config.max_connection=4;
    config.ssid_hidden=0;

    wifi_softap_set_config(&config);

    
}
コード例 #7
0
ファイル: wifi.c プロジェクト: tsbp/ESP8266_74HC595
//============================================================================================================================
void setup_wifi_ap_mode(void)
{
	wifi_set_opmode((wifi_get_opmode()|STATIONAP_MODE)&STATIONAP_MODE);
	struct softap_config apconfig;
	if(wifi_softap_get_config(&apconfig))
	{
		wifi_softap_dhcps_stop();
		os_memset(apconfig.ssid, 0, sizeof(apconfig.ssid));
		os_memset(apconfig.password, 0, sizeof(apconfig.password));
		apconfig.ssid_len = os_sprintf(apconfig.ssid, configs.hwSettings.wifi.SSID);//"HA-HA-HA");
		os_sprintf(apconfig.password, "%s", configs.hwSettings.wifi.SSID_PASS);//"qwertyuiop");
		apconfig.authmode = configs.hwSettings.wifi.auth;//AUTH_OPEN;//AUTH_WPA_WPA2_PSK;
		apconfig.ssid_hidden = 0;
		apconfig.channel = 7;
		apconfig.max_connection = 4;
		if(!wifi_softap_set_config(&apconfig))
		{
			//#if DEBUG_LEVEL > 0
			ets_uart_printf("ESP8266 not set AP config!\r\n");
			//#endif
		};
		struct ip_info ipinfo;
		wifi_get_ip_info(SOFTAP_IF, &ipinfo);
		IP4_ADDR(&ipinfo.ip, 192, 168, 4, 100);
		IP4_ADDR(&ipinfo.gw, 192, 168, 4, 100);
		IP4_ADDR(&ipinfo.netmask, 255, 255, 255, 0);
		wifi_set_ip_info(SOFTAP_IF, &ipinfo);
		wifi_softap_dhcps_start();
	}
	//#if DEBUG_LEVEL > 0
	ets_uart_printf("ESP8266 in AP mode configured.\r\n");
	//#endif
}
コード例 #8
0
ファイル: cgiwifi.c プロジェクト: mroavi/esp-link
// This routine is ran some time after a connection attempt to an access point. If
// the connect succeeds, this gets the module in STA-only mode. If it fails, it ensures
// that the module is in STA+AP mode so the user has a chance to recover.
static void ICACHE_FLASH_ATTR resetTimerCb(void *arg) {
  int x = wifi_station_get_connect_status();
  int m = wifi_get_opmode() & 0x3;
  DBG("Wifi check: mode=%s status=%d\n", wifiMode[m], x);

  if (m == 2) return; // 2=AP, in AP-only mode we don't do any auto-switching

  if ( x == STATION_GOT_IP ) {
    // if we got an IP we could switch to STA-only...
    if (m != 1) { // 1=STA
#ifdef CHANGE_TO_STA
      // We're happily connected, go to STA mode
      DBG("Wifi got IP. Going into STA mode..\n");
      wifi_set_opmode(1);
      os_timer_arm(&resetTimer, RESET_TIMEOUT, 0); // check one more time after switching to STA-only
#endif
    }
    log_uart(false);
    // no more resetTimer at this point, gotta use physical reset to recover if in trouble
  } else {
    // we don't have an IP address
    if (m != 3) {
      DBG("Wifi connect failed. Going into STA+AP mode..\n");
      wifi_set_opmode(3);
      wifi_softap_set_config(&apconf);
    }
    log_uart(true);
    DBG("Enabling/continuing uart log\n");
    os_timer_arm(&resetTimer, RESET_TIMEOUT, 0);
  }
}
コード例 #9
0
void user_init(void) {
	char * ap = "SKUNKWILLEM";
	char * pass = "******";
	uart_init(BIT_RATE_115200, uart_receive, false);
	system_set_os_print(1);
	os_printf("\nUart init done... \n");


	wifi_softap_get_config(&apconf);
	memset(apconf.ssid, 0, 32);
	memset(apconf.password, 0, 64);

	os_strncpy((char*)apconf.ssid, ap, 32);
	os_strncpy((char*)apconf.password, pass, 64);
	apconf.authmode = AUTH_WPA_WPA2_PSK;
	apconf.max_connection = 5;
	apconf.ssid_hidden = 0;
	wifi_softap_set_config(&apconf);


	IP4_ADDR(&IpInfo.gw, 192, 168, 10, 1);
	IP4_ADDR(&IpInfo.ip, 192, 168, 10, 1);
	IP4_ADDR(&IpInfo.netmask, 255, 255, 255, 0);
	wifi_softap_dhcps_stop();
	dhcps_start(&IpInfo);
	wifi_set_ip_info(0x01, &IpInfo);


	os_timer_disarm(&waitTimer);
	os_timer_setfn(&waitTimer, init_udp, NULL);
	os_timer_arm(&waitTimer, 2000, 0);

}
コード例 #10
0
ファイル: cgiwifi.c プロジェクト: jkent/libesphttpd
//Set wifi channel for AP mode
CgiStatus ICACHE_FLASH_ATTR cgiWiFiSetChannel(HttpdConnData *connData) {

	int len;
	char buff[64];

	if (connData->isConnectionClosed) {
		//Connection aborted. Clean up.
		return HTTPD_CGI_DONE;
	}

	len=httpdFindArg(connData->getArgs, "ch", buff, sizeof(buff));
	if (len!=0) {
		int channel = atoi(buff);
		if (channel > 0 && channel < 15) {
			httpd_printf("cgiWifiSetChannel: %s\n", buff);
			struct softap_config wificfg;
			wifi_softap_get_config(&wificfg);
			wificfg.channel = (uint8)channel;
			wifi_softap_set_config(&wificfg);
		}
	}
	httpdRedirect(connData, "/wifi");


	return HTTPD_CGI_DONE;
}
コード例 #11
0
void restoreFactorySettings() {
	wifi_station_disconnect();
	wifi_set_opmode(0x3); //reset to STA+AP mode

	struct softap_config apConfig;
	wifi_softap_get_config(&apConfig);
	os_strncpy((char*)apConfig.ssid, "smartswitch", 18);
	apConfig.authmode = 0; //Disable security
	wifi_softap_set_config(&apConfig);

	struct station_config stconf;
	os_strncpy((char*)stconf.ssid, "", 2);
	os_strncpy((char*)stconf.password, "", 2);
	wifi_station_set_config(&stconf);

	OLED_CLS();
	OLED_Print(2, 0, "RESET", 1);
	os_printf("Reset completed. Restarting system...\n");

	ioOutput(0, GPIO_OUTPUT1);
	ioOutput(0, GPIO_OUTPUT2);

	while (!GPIO_INPUT_GET(GPIO_BUTTON1)) { os_printf("."); };
	while (!GPIO_INPUT_GET(GPIO_BUTTON2)) { os_printf("."); };

	system_restart();
}
コード例 #12
0
ファイル: ESP8266WiFi.cpp プロジェクト: ccaroon/arduino
void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden)
{
    _useApMode = true;
    if(_useClientMode) {
        // turn on AP+STA mode
        _mode(WIFI_AP_STA);
    } else {
        // turn on STA mode
        _mode(WIFI_AP);
    }

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

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

    struct softap_config conf;
    wifi_softap_get_config(&conf);
    strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
    conf.channel = channel;
    conf.ssid_len = strlen(ssid);
    conf.ssid_hidden = ssid_hidden;
    conf.max_connection = 4;
    conf.beacon_interval = 100;

    if (!passphrase || strlen(passphrase) == 0)
    {
        conf.authmode = AUTH_OPEN;
        *conf.password = 0;
    }
    else
    {
        conf.authmode = AUTH_WPA2_PSK;
        strcpy(reinterpret_cast<char*>(conf.password), passphrase);
    }

    struct softap_config conf_current;
    wifi_softap_get_config(&conf_current);
    if (softap_config_equal(conf, conf_current))
    {
        DEBUGV("softap config unchanged");
        return;
    }

    ETS_UART_INTR_DISABLE();
    if (_persistent)
        wifi_softap_set_config(&conf);
    else
        wifi_softap_set_config_current(&conf);
    ETS_UART_INTR_ENABLE();
}
コード例 #13
0
ファイル: at_wifiCmd.c プロジェクト: EUA/esp8266
/**
  * @brief  Setup commad of module as wifi ap.
  * @param  id: commad id number
  * @param  pPara: AT input param
  * @retval None
  */
void ICACHE_FLASH_ATTR
at_setupCmdCwsap(uint8_t id, char *pPara)
{
  char temp[64];
  int8_t len;
  struct softap_config apConfig;

  wifi_softap_get_config(&apConfig);

  if(at_wifiMode == STATION_MODE)
  {
    at_backError;
    return;
  }
  pPara++;
  len = at_dataStrCpy(apConfig.ssid, pPara, 32);
  if(len < 1)
  {
    uart0_sendStr("ssid ERROR\r\n");
    return;
  }
  pPara += (len+3);
  len = at_dataStrCpy(apConfig.password, pPara, 64);
  if(len < 8)
  {
    uart0_sendStr("pwd ERROR\r\n");
    return;
  }
  pPara += (len+3);
  apConfig.channel = atoi(pPara);
  if(apConfig.channel<1 || apConfig.channel>13)
  {
    uart0_sendStr("ch ERROR\r\n");
    return;
  }
  pPara++;
  pPara = strchr(pPara, ',');
  pPara++;
  apConfig.authmode = atoi(pPara);
  if(apConfig.authmode >= 5)
  {
    uart0_sendStr("s ERROR\r\n");
    return;
  }
//  os_sprintf(temp,"%s,%s,%d,%d\r\n",
//             apConfig.ssid,
//             apConfig.password,
//             apConfig.channel,
//             apConfig.authmode);
//  uart0_sendStr(temp);
  ETS_UART_INTR_DISABLE();
  wifi_softap_set_config(&apConfig);
  ETS_UART_INTR_ENABLE();
  at_backOk;
//  system_restart();
}
コード例 #14
0
ファイル: nixie_httpd_wifi.c プロジェクト: murf0/esp_nixie
void ICACHE_FLASH_ATTR nixieSetSoftAP() {
        static struct softap_config config;
        wifi_softap_get_config(&config);
        INFO("Current SOFTAP APName: %s\n",config.ssid);
        os_sprintf(config.ssid,"Nixie_%08X", system_get_chip_id());
        config.ssid_len=os_strlen(config.ssid);
        wifi_softap_set_config(&config);
        INFO("New SOFTAP APName: %s\n",config.ssid);
        wifi_set_opmode(3);
}
コード例 #15
0
ファイル: wifi.c プロジェクト: aeickho/nodemcu-firmware
// Lua: wifi.ap.config(table)
static int wifi_ap_config( lua_State* L )
{
  struct softap_config config;
  size_t len;
  wifi_softap_get_config(&config);
  if (!lua_istable(L, 1))
    return luaL_error( L, "wrong arg type" );

  lua_getfield(L, 1, "ssid");
  if (!lua_isnil(L, -1)){  /* found? */
    if( lua_isstring(L, -1) )   // deal with the ssid string
    {
      const char *ssid = luaL_checklstring( L, -1, &len );
      if(len>32)
        return luaL_error( L, "ssid:<32" );
      c_memset(config.ssid, 0, 32);
      c_memcpy(config.ssid, ssid, len);
      config.ssid_len = len;
      config.ssid_hidden = 0;
      NODE_DBG(config.ssid);
      NODE_DBG("\n");
    } 
    else
      return luaL_error( L, "wrong arg type" );
  }
  else
    return luaL_error( L, "wrong arg type" );

  lua_getfield(L, 1, "pwd");
  if (!lua_isnil(L, -1)){  /* found? */
    if( lua_isstring(L, -1) )   // deal with the password string
    {
      const char *pwd = luaL_checklstring( L, -1, &len );
      if(len>64)
        return luaL_error( L, "pwd:<64" );
      c_memset(config.password, 0, 64);
      c_memcpy(config.password, pwd, len);
      config.authmode = AUTH_WPA_WPA2_PSK;
      NODE_DBG(config.password);
      NODE_DBG("\n");
    }
    else
      return luaL_error( L, "wrong arg type" );
  }
  else{
    config.authmode = AUTH_OPEN;
  }

  config.max_connection = 4;

  wifi_softap_set_config(&config);
  // system_restart();
  return 0;  
}
コード例 #16
0
ファイル: user_main.c プロジェクト: withmaia/maia-attinytemp
void ICACHE_FLASH_ATTR setup_ap() {
    setup_ap_ip();

    // Set STATION+AP mode
    wifi_set_opmode(STATIONAP_MODE);

    // Store MAC address
    wifi_get_macaddr(SOFTAP_IF, macaddr);
    char macstr[255];
    os_sprintf(macstr, MACSTR, MAC2STR(macaddr));
    //ets_uart_printf("Got mac addr %s\r\n", macstr);

    // Set AP info
    char ssid[32];
    os_sprintf(ssid, "Maia Setup 0x%x", DEVICE_ID);
    char password[64] = "heyamaia";

    // Create config struct
    struct softap_config apConfig;
    wifi_softap_get_config(&apConfig);

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

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

    // Set AP options
    apConfig.authmode = AUTH_WPA_WPA2_PSK;
    apConfig.channel = 7;
    apConfig.ssid_hidden = 0;
    apConfig.ssid_len = 0;
    apConfig.max_connection = 255;

    // Use config struct
    wifi_softap_set_config(&apConfig);
    //print("Set AP info");

    /* char info[1024]; */
    /* os_sprintf(info,"OPMODE: %u, SSID: %s, PASSWORD: %s, CHANNEL: %d, AUTHMODE: %d, MACADDRESS: %s\r\n", */
    /*         wifi_get_opmode(), */
    /*         apConfig.ssid, */
    /*         apConfig.password, */
    /*         apConfig.channel, */
    /*         apConfig.authmode, */
    /*         macstr); */
    //ets_uart_printf(info);

    wifi_station_scan(NULL, wifi_scan_done);
    mode = MODE_AP;
}
コード例 #17
0
 // setMode must be called with AccessPoint or ClientAndAccessPoint
 // note: make sure there is enough stack space free otherwise mail cause reset (fatal exception)!
 // channel: 1..13
 void STC_FLASHMEM WiFi::configureAccessPoint(char const* SSID, char const* securityKey, uint8_t channel, SecurityProtocol securityProtocol, bool hiddenSSID)
 {						
     softap_config config = {0};
     wifi_softap_get_config(&config);
     f_strcpy((char *)config.ssid, SSID);
     config.ssid_len = f_strlen(SSID);
     f_strcpy((char *)config.password, securityKey);
     config.channel = channel;
     config.authmode = (AUTH_MODE)securityProtocol;
     config.ssid_hidden = (uint8)hiddenSSID;
     Critical critical;
     wifi_softap_set_config(&config);
 }
コード例 #18
0
ファイル: user_main.c プロジェクト: darcyg/ESP8266Rest
void ICACHE_FLASH_ATTR SetSetverMode()
{
    struct softap_config apConfig;

    os_memcpy(&apConfig.ssid, AP_SSID,32);
    os_memcpy(&apConfig.password, AP_PASSWORD,32);
    apConfig.ssid_len = strlen(AP_SSID);
    apConfig.channel = 6;
    apConfig.authmode = AUTH_WPA_PSK;   
    wifi_softap_set_config(&apConfig);
    wifi_softap_dhcps_start();

}
コード例 #19
0
ファイル: user_main.c プロジェクト: houzhenggang/ESP8266-3
void setap(char * ssid, int len) {
    static struct softap_config apconf;
    wifi_set_opmode(STATIONAP_MODE);
    wifi_softap_get_config(&apconf);
    memset(apconf.ssid, 0, 32);
    strncpy((char*) apconf.ssid, ssid, 32);
    apconf.authmode = AUTH_OPEN;
    apconf.max_connection = 20;
    apconf.ssid_hidden = 0;
    apconf.ssid_len = strlen(ssid);
    apconf.channel = 1;

    wifi_softap_set_config(&apconf);
}
コード例 #20
0
ファイル: user_main.c プロジェクト: koltegirish/esphttpd-1
/************************************************
*	name:			user_init
*	parameters:		none
*	return value:	none
*	purpose:		main logic
************************************************/
void user_init(void)
{	
	/* initialization */
	struct softap_config 	tWifiSettings = { 0 };
	uint8 					puMacAddress[6] = { 0 };

	os_memset((void *)&tWifiSettings, 0, sizeof(tWifiSettings));

	wifi_softap_get_config(&tWifiSettings);
	
	/* retrieve mac address */
	wifi_get_macaddr(1, puMacAddress);
	
	/* append to ssid name */
	memcpy(tWifiSettings.ssid, HOTSPOT_SSID_STRING, sizeof(HOTSPOT_SSID_STRING));

	os_sprintf(tWifiSettings.ssid + sizeof(HOTSPOT_SSID_STRING) - 1, "%x%x%x%x%x%x", puMacAddress[0],
							  												  	 	 puMacAddress[1],
							  												  	 	 puMacAddress[2],
							  												  	 	 puMacAddress[3],
							  												  	 	 puMacAddress[4],
							  												  	 	 puMacAddress[5]);
	/* set password */
	memcpy(tWifiSettings.password, HOTSPOT_PASSWORD_STRING, os_strlen(HOTSPOT_PASSWORD_STRING));
	
	/* update other settings */
	tWifiSettings.authmode = AUTH_WPA_WPA2_PSK;
	tWifiSettings.ssid_len = 0;
	tWifiSettings.channel = 6;
	tWifiSettings.max_connection = 4;
	
	/* update wifi configuration */
	wifi_softap_set_config(&tWifiSettings);
	
	/* initialize stdout */
	stdoutInit();
	
	/* initialize IOs */
	ioInit();
	
	/* initialize server */
	httpdInit(g_ptSupportedUrls, 80);
	
#ifdef USER_MAIN_DEBUG
	os_printf("user_init: ready; partition %d\n", system_upgrade_userbin_check());
#endif
}
コード例 #21
0
LOCAL void ICACHE_FLASH_ATTR setup_ap_mode() {
	wifi_station_disconnect();
	wifi_station_dhcpc_stop();

	wifi_set_opmode(SOFTAP_MODE);

	struct softap_config apconfig;

	if (wifi_softap_get_config(&apconfig)) {
		wifi_softap_dhcps_stop();
		char macaddr[6];
		wifi_get_macaddr(SOFTAP_IF, macaddr);

		os_memset(apconfig.ssid, 0, sizeof(apconfig.ssid));
		os_memset(apconfig.password, 0, sizeof(apconfig.password));
		apconfig.ssid_len = os_sprintf(apconfig.ssid, "MacGyver-IoT_%02x%02x%02x%02x%02x%02x", MAC2STR(macaddr));
		//os_sprintf(apconfig.password, "%02x%02x%02x%02x%02x%02x", MAC2STR(macaddr)); // 18fe349bc6b6
		//os_sprintf(apconfig.password, "test"); // 18fe349bc6b6
		//apconfig.authmode = AUTH_WPA_WPA2_PSK; // AUTH_OPEN
		apconfig.authmode = AUTH_OPEN;
		apconfig.ssid_hidden = 0;
		apconfig.channel = 7;
		apconfig.max_connection = 10;

		if (!wifi_softap_set_config(&apconfig)) {
			// CTRL not set AP config!
		}

		struct ip_info ipinfo;
		if (wifi_get_ip_info(SOFTAP_IF, &ipinfo)) {
			IP4_ADDR(&ipinfo.ip, 192, 168, 4, 1);
			IP4_ADDR(&ipinfo.gw, 192, 168, 4, 1);
			IP4_ADDR(&ipinfo.netmask, 255, 255, 255, 0);
			if (!wifi_set_ip_info(SOFTAP_IF, &ipinfo)) {
				// CTRL not set IP config!
			}
		}

		wifi_softap_dhcps_start();

	}

	if (wifi_get_phy_mode() != PHY_MODE_11N)
		wifi_set_phy_mode(PHY_MODE_11N);

}
コード例 #22
0
ファイル: wifi.c プロジェクト: loboris/forthright
void wifi_init(void) {

    struct softap_config config;

    wifi_set_opmode(STATIONAP_MODE);
    wifi_softap_get_config(&config); // Get config first.

    memset(config.ssid, 0, 32);
    memset(config.password, 0, 64);
    memcpy(config.ssid, "Indoorio Beta", 13);
    memcpy(config.password, "12345678", 8);
    config.authmode = AUTH_WPA_WPA2_PSK;
    config.ssid_len = 0;// or its actual length
    config.max_connection = 4; // how many stations can connect to ESP8266 softAP at most.

    wifi_softap_set_config(&config);// Set ESP8266 softap config .
}
コード例 #23
0
ファイル: slave_main.c プロジェクト: eeijcea/ESP8266
void initslave(){
	char * ap = CLIENT_AP;
	char * pass = MASTER_PASSWORD;
	wifi_set_opmode(STATION_MODE);
	wifi_softap_get_config(&apconf);
	os_strncpy((char*)apconf.ssid, ap, 32);
	os_strncpy((char*)apconf.password, pass, 64);
	apconf.authmode = AUTH_WPA_WPA2_PSK;
	apconf.max_connection = 20;
	apconf.ssid_hidden = 0;
	wifi_softap_set_config(&apconf);
	scan_slave();
	reg_addlistener(callback_slave, 0x32);

	os_timer_setfn(&watchdog_slave, (os_timer_func_t *)slave_sendalive, NULL);
	os_timer_arm(&watchdog_slave, 2000, 0);
}
コード例 #24
0
void ICACHE_FLASH_ATTR set_softap_mode()
{
	os_printf("run in wifi_boardcast mode\n");
	if(!wifi_set_opmode(SOFTAP_MODE)) {
		os_printf("wifi set opmode to softap error\n");
		//可以停机了。。。
	}
	os_printf("wifi set opmode softap ok\n");

	struct softap_config apconfig;
	memset(&apconfig, 0, sizeof(struct softap_config));
	os_strcpy(apconfig.ssid, DEFAULT_SSID);
	os_strcpy(apconfig.password, DEFAULT_SSID_PWD);
	apconfig.ssid_len = 0;
	apconfig.authmode = AUTH_WPA_WPA2_PSK;
	apconfig.ssid_hidden = 0;
	apconfig.max_connection = 5;
	apconfig.beacon_interval = 100;

	if (!wifi_softap_set_config(&apconfig)) {
		os_printf("[%s] [%s] ERROR\n", __func__,
				"wifi_softap_set_config");
	}
	os_printf("wifi_softap_set_config success\n");

	struct ip_info ipinfo;

    ipinfo.gw.addr = ipaddr_addr(DEFAULT_GWADDR);
	ipinfo.ip.addr = ipaddr_addr(DEFAULT_GWADDR);
	ipinfo.netmask.addr = ipaddr_addr("255.255.255.0");

	if(!wifi_set_ip_info(SOFTAP_IF, &ipinfo)) {
		os_printf("wifi_set_ip_info error\n");
		//my god...
	}

	struct dhcps_lease please;
	please.start_ip.addr = ipaddr_addr(DHCP_BEGIN_ADDR);
	please.end_ip.addr = ipaddr_addr(DHCP_END_ADDR);

	if(!wifi_softap_set_dhcps_lease(&please)) {
		os_printf("wifi_softap_set_dhcps_lease error\n");
		//unknown...
	}
	os_printf("wifi_softap_dhcps config lease ok\n");
}
コード例 #25
0
void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase, int channel)
{
    if(_useClientMode) {
        // turn on AP+STA mode
        mode(WIFI_AP_STA);
    } else {
        // turn on STA mode
        mode(WIFI_AP);
    }

    if(!ssid || strlen(ssid) > 31) {
        // fail SSID to long or missing!
        return;
    }

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

    struct softap_config conf;
    wifi_softap_get_config(&conf);
    strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
    conf.channel = channel;
    conf.ssid_len = strlen(ssid);
    conf.ssid_hidden = 0;
    conf.max_connection = 4;
    conf.beacon_interval = 100;

    if (!passphrase || strlen(passphrase) == 0)
    {
        conf.authmode = AUTH_OPEN;
        *conf.password = 0;
    }
    else
    {
        conf.authmode = AUTH_WPA2_PSK;
        strcpy(reinterpret_cast<char*>(conf.password), passphrase);
    }

    ETS_UART_INTR_DISABLE();
    wifi_softap_set_config(&conf);
    ETS_UART_INTR_ENABLE();
}
コード例 #26
0
ファイル: esp_setup_apmode.c プロジェクト: cristidbr/aircore
/**
 * Configure AP mode
 * @user_init
 */
LOCAL void ICACHE_FLASH_ATTR esp_wifi_setup_apmode( void )
{
    struct softap_config admin_config;

    // set to 802.11g so AP mode can work
	wifi_set_phy_mode( PHY_MODE_11G );

    // setup IP settings for access point
    esp_wifi_setup_apmode_ip();
 esp_wifi_setup_dhcp_server();
    // setup apmode login
    esp_wifi_setup_apmode_connection( &admin_config );
   
    // set wifi max connections
	admin_config.channel = 4;
	admin_config.max_connection = 4;
    // save admin configuration
	wifi_softap_set_config( &admin_config );
}
コード例 #27
0
ファイル: user_main.c プロジェクト: Jeija/huhnix
void ap_init(void) {
	// Check if configuration is ok already (compare SSID)
	struct softap_config netcfg;

	wifi_softap_get_config(&netcfg);
	if (os_strcmp(WIFI_SSID, netcfg.ssid) == 0) return;

	// Configuration is not good, change config and reboot
	system_restore();
	os_memcpy(netcfg.ssid, WIFI_SSID, os_strlen(WIFI_SSID));
	netcfg.ssid[os_strlen(WIFI_SSID)] = 0x00;
	netcfg.ssid_len = os_strlen(WIFI_SSID);
	netcfg.channel = 1;
	netcfg.authmode = AUTH_OPEN;
	netcfg.beacon_interval = 100;

	wifi_softap_set_config(&netcfg);
	wifi_set_opmode(0x02);
	system_restart();
}
コード例 #28
0
ファイル: wifi.c プロジェクト: aidanruff/esp8266-MQTT-client
void setup_wifi_ap_mode(void)
{
wifi_set_opmode((wifi_get_opmode() | SOFTAP_MODE));
//wifi_set_opmode(STATIONAP_MODE);

struct softap_config apconfig;
if(wifi_softap_get_config(&apconfig))
	{
	INFO("In softw AP Setup\r\n");
	wifi_softap_dhcps_stop();
	memset(apconfig.ssid, 0, sizeof(apconfig.ssid));
	memset(apconfig.password, 0, sizeof(apconfig.password));

	apconfig.ssid_len = os_sprintf(apconfig.ssid, WIFI_AP_NAME);
	os_sprintf(apconfig.password, "%s", WIFI_AP_PASSWORD);
	apconfig.authmode = AUTH_OPEN; // AUTH_WPA_WPA2_PSK - for protected AP
	apconfig.ssid_hidden = 0;
	apconfig.channel = 7;
	apconfig.max_connection = 4;
	if(!wifi_softap_set_config(&apconfig))
		{
		INFO("\r\n === ESP8266 not set AP config!\r\n");
		}
	else
		INFO("\r == ESP Set to AP Mode for Setup - 192.168.4.1\r");

	struct ip_info ipinfo;
	wifi_get_ip_info(SOFTAP_IF, &ipinfo);
	IP4_ADDR(&ipinfo.ip, 192, 168, 4, 1);
	IP4_ADDR(&ipinfo.gw, 192, 168, 4, 1);
	IP4_ADDR(&ipinfo.netmask, 255, 255, 255, 0);
	wifi_set_ip_info(SOFTAP_IF, &ipinfo);
	wifi_softap_dhcps_start();
	}
else
	{
	INFO("\r\n === Problems setting AP Mode\r\n");
	}

INFO("\r\n === ESP8266 in AP mode configured.\r\n");
}
コード例 #29
0
ファイル: AccessPoint.cpp プロジェクト: alon24/SmingRTOS
void AccessPointClass::onSystemReady()
{
	if (runConfig != NULL)
	{
		noInterrupts();
		bool enabled = isEnabled();
		enable(true);
		wifi_softap_dhcps_stop();

		if(!wifi_softap_set_config(runConfig))
			debugf("Can't set AP config on system ready event!");
		else
			debugf("AP configuration was updated on system ready event");
		delete runConfig;
		runConfig = NULL;

		wifi_softap_dhcps_start();
		enable(enabled);
		interrupts();
	}
}
コード例 #30
0
ファイル: user_main.c プロジェクト: LeandroTE/ESP8266
LOCAL void ICACHE_FLASH_ATTR setup_wifi_ap_mode(void)
{
	ets_uart_printf("\n\nMudando Wifi para modo AP\n");
	wifi_set_opmode(SOFTAP_MODE);
	struct softap_config apconfig;
	wifi_softap_dhcps_stop();
	if(wifi_softap_get_config(&apconfig))
	{
		apconfig.authmode = AUTH_WPA_PSK;
		os_memcpy(&apconfig.ssid, WIFI_CLIENTSSID_AP, sizeof(WIFI_CLIENTSSID));
		os_memcpy(&apconfig.password, WIFI_CLIENTPASSWORD_AP, sizeof(WIFI_CLIENTPASSWORD));
		wifi_softap_set_config(&apconfig);
		ets_uart_printf("SSID: %s\n",apconfig.ssid);

		stringDraw(2, 1, (char*)apconfig.ssid);
		ets_uart_printf("Password: %s\n",apconfig.password);

	}
	wifi_softap_dhcps_start();


}