Hi pratik,
thanks a lot for your answer.
Of course i filled the variables ''ssid'' and ''password'' with the appropriate data from my home wifi network. I think it is reasonable that i don't show my home network data on the internet.
The error appears in this line:
Code: Select all
struct station_config stationConf; Maybe i am missing some kind if include header file?
Edit: Maybe i missunderstood something,
does this code create a new access point or does this code make the esp8266 connect to a wifi network?
Edit: It looks like another person has had that problem a while ago:
http://41j.com/blog/2015/01/esp8266-wif ... t-connect/But it didn't get fixed.
I googled and i found out that in normal C this error appears when a struct is not known so maybe the struct 'station_config' is also not known? Maybe because i missed some header file?
It looks like the struct 'station_config' is defined in this file:
https://github.com/espressif/ESP8266_RT ... /esp_sta.hOkay, i just copy paste the struct and now it compiles:
Code: Select all
#include <ets_sys.h>
#include <osapi.h>
#include <gpio.h>
#include <os_type.h>
struct station_config {
uint8 ssid[32]; /**< SSID of target AP*/
uint8 password[64]; /**< password of target AP*/
uint8 bssid_set; /**< whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/
uint8 bssid[6]; /**< MAC address of target AP*/
};
void ICACHE_FLASH_ATTR user_set_station_config(void){
char ssid[32] = "";
char password[64] = "";
struct station_config stationConf;
os_memset(stationConf.ssid, 0, 32);
os_memset(stationConf.password, 0, 64);
//need not mac address
stationConf.bssid_set = 0;
//Set ap settings
os_memcpy(&stationConf.ssid, ssid, 32);
os_memcpy(&stationConf.password, password, 64);
wifi_station_set_config(&stationConf);
}
void user_init(void)
{
wifi_set_opmode(0x01);
user_set_station_config();
}