It is probably just a case of modifying the codebase you are using. Here is some code that runs ESP8266 as station and access point.
let ap_ssid="test";
let ap_authMode="wpa_wpa2";
let ap_pwd="testtest";
let st_ssid="ssid";
let st_pwd="pwd";
let port=8080;
let http = require('http');
let wifi = require("Wifi");
let startServer = function(port){
let server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(`AP IP: ${wifi.getAPIP().ip}</br>STA IP: ${wifi.getIP().ip}`);
});
console.log("server started");
server.listen(port);
};
console.log("disconnecting all..");
wifi.disconnect();
// start ap
wifi.startAP(ap_ssid,{
"authMode" : ap_authMode,
"password" : ap_pwd
},(err)=>{
if (!err) {
console.log("AP started");
} else {
console.log("could not start AP");
}
// conect as station
wifi.connect(st_ssid, {password:st_pwd}, (err) => {
if (!err){
console.log("station connected");
startServer(port);
}else{
console.log("could not connect as station");
}
});
});
The server/page can be connected to on AP IP: 192.168.4.1 (port 8080) and the router allocated IP of 192.168.1.34 in this example.
Both the AP IP and station IP are displayed in the page.
AP IP: 192.168.4.1
STA IP: 192.168.1.34
Perhaps you can modify from here to suit your needs.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
It is probably just a case of modifying the codebase you are using. Here is some code that runs ESP8266 as station and access point.
The server/page can be connected to on AP IP: 192.168.4.1 (port 8080) and the router allocated IP of 192.168.1.34 in this example.
Both the AP IP and station IP are displayed in the page.
Perhaps you can modify from here to suit your needs.