Accomodate latest ESP-IDF changes

This commit is contained in:
kolban 2016-11-09 20:14:59 -06:00
parent ad6dd5fbb0
commit add9e89fb1
2 changed files with 57 additions and 3 deletions

View File

@ -1791,6 +1791,7 @@ LDFLAGS +=-L$(ESP_IDF_PATH)/lib -L$(ESP_IDF_PATH)/ld -L$(ESP_IDF_PATH)/component
-L$(ESP_APP_TEMPLATE_PATH)/build/tcpip_adapter \
-L$(ESP_APP_TEMPLATE_PATH)/build/vfs \
-L$(ESP_APP_TEMPLATE_PATH)/build/newlib \
-L$(ESP_APP_TEMPLATE_PATH)/build/wpa_supplicant \
-L$(ESP_APP_TEMPLATE_PATH)/build/arduino-esp32
ESPTOOL?=
INCLUDE+=\
@ -1824,10 +1825,10 @@ $(ESP_IDF_PATH)/components/newlib/lib/libm.a \
-ldriver \
-lesp32 \
$(ESP_IDF_PATH)/components/esp32/libhal.a \
-lcrypto \
-lcore \
-lnet80211 \
-lphy \
-lwpa_supplicant \
-lrtc \
-lpp \
-lwpa \

View File

@ -1,13 +1,66 @@
// Start being an access point.
// Start being a web server.
// Listen on:
// - /list - Return a list of access points
// - /select?ssid=<SSID>&password=<password> - Select an SSID and supply a password.
// When a request arrives from a browser, build a page which contains the
// list of access points to which we can connect.
// When the user selects an access point with password, connect to that access point.
// 1. Be an access point
// 2. Configure a Web Server.
function startWebServer() {
var http = require("http");
var httpServer = http.createServer(function(request, response) {
console.log("Received a browser request looking for " + request.url);
// Handle browser requests here ...
var parsedURL = url.parse(request.url, true);
if (parsedURL.pathname == "/list") {
// Process the list request here ...
// Handle the list request
response.writeHead(200);
response.end("process /list");
return;
} else if (parsedURL.pathname == "/select") {
// Handle the select request
if (!parsedURL.query.hasOwnProperty("ssid") || !parsedURL.query.hasOwnProperty("password")) {
console.log("No ssid or no password in /select request: " + JSON.stringify(parsedURL));
response.writeHead(200);
response.end("Hello World");
return;
}
// Process the select request here...
response.writeHead(200);
response.end("Process /select");
return;
}
// Unknown service
response.writeHead(200);
response.end("Hello World");
});
httpServer.listen(80);
console.log("Web Server now started ... listening on port 80");
}
var wifi = require("Wifi");
// 1. Be an access point
wifi.startAP("MYESP32", {
"authMode": "open"
}, function(err) {
console.log("AP now started: " + err);
});
startWebServer();
});
//Connect to an access point and be a simple web server
//
/*
var ssid="guest";
var password="kolbanpassword";
wifi.connect(ssid, {password: password}, function() {
startWebServer();
});
*/