clang-format
This commit is contained in:
parent
f764f7d612
commit
01a722bef8
2 changed files with 189 additions and 20 deletions
|
@ -2,34 +2,29 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/cyw43_arch.h"
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
int wifi_setup(uint32_t country, const string &ssid, const string &pw)
|
||||
{
|
||||
if (cyw43_arch_init_with_country(country))
|
||||
{
|
||||
int wifi_setup(uint32_t country, const string &ssid, const string &pw) {
|
||||
if (cyw43_arch_init_with_country(country)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
cyw43_arch_enable_sta_mode();
|
||||
|
||||
if (cyw43_arch_wifi_connect_async(ssid.c_str(), pw.c_str(), CYW43_AUTH_WPA2_MIXED_PSK))
|
||||
{
|
||||
if (cyw43_arch_wifi_connect_async(ssid.c_str(), pw.c_str(), CYW43_AUTH_WPA2_MIXED_PSK)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
int flashrate = 1000;
|
||||
int status = CYW43_LINK_UP + 1;
|
||||
|
||||
while (status >= 0 && status != CYW43_LINK_UP)
|
||||
{
|
||||
while (status >= 0 && status != CYW43_LINK_UP) {
|
||||
int status_new = cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_STA);
|
||||
|
||||
if (status_new != status)
|
||||
{
|
||||
if (status_new != status) {
|
||||
status = status_new;
|
||||
flashrate = flashrate / (status + 1);
|
||||
printf("Connect status: %d %d\n", status, flashrate);
|
||||
|
@ -40,20 +35,16 @@ int wifi_setup(uint32_t country, const string &ssid, const string &pw)
|
|||
sleep_ms(flashrate);
|
||||
}
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
if (status < 0) {
|
||||
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
const string ssid{"Apis cerana"};
|
||||
const string pw{"2JkJEh2vptVT"};
|
||||
const uint32_t country{CYW43_COUNTRY_GERMANY};
|
||||
|
@ -62,8 +53,7 @@ int main()
|
|||
|
||||
wifi_setup(country, ssid, pw);
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
sleep_ms(1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue