using wifi cred. from cmake
This commit is contained in:
parent
4227a33c9e
commit
32d24c3712
2 changed files with 6 additions and 4 deletions
|
@ -33,6 +33,8 @@ target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
|
||||||
SNTP_STARTUP_DELAY=0
|
SNTP_STARTUP_DELAY=0
|
||||||
SNTP_SET_SYSTEM_TIME=set_system_time
|
SNTP_SET_SYSTEM_TIME=set_system_time
|
||||||
SNTP_UPDATE_DELAY=86400
|
SNTP_UPDATE_DELAY=86400
|
||||||
|
WLAN_SSID="<YOUR SSID>"
|
||||||
|
WLAN_PW="<YOUR PW>"
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(${CMAKE_PROJECT_NAME}
|
set_target_properties(${CMAKE_PROJECT_NAME}
|
||||||
|
|
|
@ -160,22 +160,22 @@ int wifi_setup(uint32_t country, const string &ssid, const string &pw, bool firs
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifi_enable() {
|
void wifi_enable() {
|
||||||
const string ssid{"Apis cerana"};
|
|
||||||
const string pw{"2JkJEh2vptVT"};
|
|
||||||
const uint32_t country{CYW43_COUNTRY_GERMANY};
|
const uint32_t country{CYW43_COUNTRY_GERMANY};
|
||||||
|
|
||||||
bool firstTry = true;
|
bool firstTry = true;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
do {
|
do {
|
||||||
if (firstTry) {
|
if (firstTry) {
|
||||||
res = wifi_setup(country, ssid, pw, true);
|
res = wifi_setup(country, WLAN_SSID, WLAN_PW,
|
||||||
|
true); // WLAN_SSID and WLAN_PW come from CMakeLists.txt
|
||||||
firstTry = false;
|
firstTry = false;
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Setting up connection failed. Trying again after 5 sec...\n");
|
printf("Setting up connection failed. Trying again after 5 sec...\n");
|
||||||
#endif
|
#endif
|
||||||
sleep_ms(5000);
|
sleep_ms(5000);
|
||||||
res = wifi_setup(country, ssid, pw, false);
|
res = wifi_setup(country, WLAN_SSID, WLAN_PW,
|
||||||
|
false); // WLAN_SSID and WLAN_PW come from CMakeLists.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (res != CYW43_LINK_UP);
|
} while (res != CYW43_LINK_UP);
|
||||||
|
|
Loading…
Reference in a new issue