Wifi configured

This commit is contained in:
ollo 2018-01-02 12:47:31 +01:00
parent 34bec501ca
commit 989d8b263a
2 changed files with 30 additions and 14 deletions

View File

@ -10,7 +10,9 @@ import org.luaj.vm2.lib.jse.JsePlatform;
import de.c3ma.ollo.mockup.DoFileFunction;
import de.c3ma.ollo.mockup.ESP8266File;
import de.c3ma.ollo.mockup.ESP8266Net;
import de.c3ma.ollo.mockup.ESP8266Node;
import de.c3ma.ollo.mockup.ESP8266Time;
import de.c3ma.ollo.mockup.ESP8266Tmr;
import de.c3ma.ollo.mockup.ESP8266Uart;
import de.c3ma.ollo.mockup.ESP8266Wifi;
@ -40,6 +42,8 @@ public class WS2812Simulation implements LuaSimulation {
globals.load(espFile);
globals.load(espNode);
globals.load(new ESP8266Wifi());
globals.load(new ESP8266Net());
globals.load(new ESP8266Time());
globals.set("dofile", doFile);
try {

View File

@ -26,8 +26,15 @@ public class ESP8266Wifi extends TwoArgFunction {
env.checkglobals();
final LuaTable wifi = new LuaTable();
wifi.set("setmode", new SetModeFunction());
wifi.set("ap", new ApFunction());
final LuaTable ap = new LuaTable();
ap.set("config", new ConfigFunction());
wifi.set("ap", ap);
final LuaTable sta = new LuaTable();
sta.set("status", new StatusFunction());
sta.set("getip", new GetIpFunction());
wifi.set("sta", sta);
wifi.set("SOFTAP", "SOFTAP");
wifi.set("STATION", "STATION");
env.set("wifi", wifi);
env.get("package").get("loaded").set("wifi", wifi);
return wifi;
@ -44,19 +51,6 @@ public class ESP8266Wifi extends TwoArgFunction {
}
private class ApFunction extends TwoArgFunction {
@Override
public LuaValue call(LuaValue modname, LuaValue env) {
final LuaTable ap = new LuaTable();
ap.set("config", new ConfigFunction());
env.set("ap", ap);
env.get("package").get("loaded").set("wifi.ap", ap);
return ap;
}
}
private class ConfigFunction extends OneArgFunction {
@Override
@ -66,4 +60,22 @@ public class ESP8266Wifi extends TwoArgFunction {
}
}
private class StatusFunction extends ZeroArgFunction {
@Override
public LuaValue call() {
return LuaValue.valueOf(5);
}
}
private class GetIpFunction extends ZeroArgFunction {
@Override
public LuaValue call() {
return LuaValue.valueOf("127.0.0.1");
}
}
}