Got the post and the internet connecting working
This commit is contained in:
19
src/main.cpp
19
src/main.cpp
@@ -4,11 +4,12 @@
|
|||||||
#include "lwip/apps/httpd.h"
|
#include "lwip/apps/httpd.h"
|
||||||
#include "pico/cyw43_arch.h"
|
#include "pico/cyw43_arch.h"
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
|
#include "webserver.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
/* void ap_init() {
|
void ap_init() {
|
||||||
cyw43_arch_enable_ap_mode("SensorAP", "passwort123", CYW43_AUTH_WPA2_AES_PSK);
|
cyw43_arch_enable_ap_mode("SensorAP", "passwort123", CYW43_AUTH_WPA2_AES_PSK);
|
||||||
|
|
||||||
ip_addr_t gw{};
|
ip_addr_t gw{};
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
|
|
||||||
static dhcp_server_t dhcp_server{};
|
static dhcp_server_t dhcp_server{};
|
||||||
dhcp_server_init(&dhcp_server, &gw, &mask);
|
dhcp_server_init(&dhcp_server, &gw, &mask);
|
||||||
} */
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int ret{};
|
int ret{};
|
||||||
@@ -28,20 +29,19 @@ int main() {
|
|||||||
httpd_init();
|
httpd_init();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/* memset(saved_ssid, 0, sizeof(saved_ssid));
|
memset(saved_ssid, 0, sizeof(saved_ssid));
|
||||||
memset(saved_password, 0, sizeof(saved_password));
|
memset(saved_password, 0, sizeof(saved_password));
|
||||||
ap_init(); */
|
ap_init();
|
||||||
printf("Return Code: %d\n", ret);
|
printf("Return Code: %d\n", ret);
|
||||||
|
|
||||||
/* while (saved_ssid[0] == '\0') {
|
while (saved_ssid[0] == '\0') {
|
||||||
cyw43_arch_poll();
|
cyw43_arch_poll();
|
||||||
sleep_ms(100);
|
sleep_ms(100);
|
||||||
} */
|
}
|
||||||
// cyw43_arch_disable_ap_mode();
|
cyw43_arch_disable_ap_mode();
|
||||||
cyw43_arch_enable_sta_mode();
|
cyw43_arch_enable_sta_mode();
|
||||||
|
|
||||||
ret = cyw43_arch_wifi_connect_timeout_ms("HainerErnst-IoT",
|
ret = cyw43_arch_wifi_connect_timeout_ms(saved_ssid, saved_password,
|
||||||
"vpUaR68xLZzXanS7",
|
|
||||||
CYW43_AUTH_WPA2_MIXED_PSK, 10000);
|
CYW43_AUTH_WPA2_MIXED_PSK, 10000);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
break;
|
break;
|
||||||
@@ -56,3 +56,4 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,17 +5,6 @@
|
|||||||
char saved_ssid[33];
|
char saved_ssid[33];
|
||||||
char saved_password[65];
|
char saved_password[65];
|
||||||
|
|
||||||
/* static const char *config_handler(int iIndex, int iNumParams, char
|
|
||||||
*pcParam[], char *pcValue[]) { for (int i = 0; i < iNumParams; i++) { if
|
|
||||||
(strcmp(pcParam[i], "ssid") == 0) { strncpy(saved_ssid, pcValue[i], 32);
|
|
||||||
}
|
|
||||||
if (strcmp(pcParam[i], "password") == 0) {
|
|
||||||
strncpy(saved_password, pcValue[i], 64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "/index.html";
|
|
||||||
} */
|
|
||||||
|
|
||||||
err_t httpd_post_begin(void *connection, const char *uri,
|
err_t httpd_post_begin(void *connection, const char *uri,
|
||||||
const char *http_request, u16_t http_request_len,
|
const char *http_request, u16_t http_request_len,
|
||||||
int content_len, char *response_uri,
|
int content_len, char *response_uri,
|
||||||
@@ -61,9 +50,5 @@ void httpd_post_finished(void *connection, char *response_uri,
|
|||||||
strncpy(saved_password, pos2, len2);
|
strncpy(saved_password, pos2, len2);
|
||||||
|
|
||||||
saved_ssid[len] = '\0';
|
saved_ssid[len] = '\0';
|
||||||
saved_password[len] = '\0';
|
saved_password[len2] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// static const tCGI cgi_handlers[] = {{"/config", config_handler}};
|
|
||||||
|
|
||||||
// void webserver_init(void) { http_set_cgi_handlers(cgi_handlers, 1); }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user