Added the facility to accept an alarm from the web interface ("/acceptalarm" url), and added button to web interface page.

This commit is contained in:
Graham Jones
2017-05-07 20:13:54 +01:00
parent b0b61b9fd2
commit 98f6af1083
4 changed files with 19 additions and 5 deletions

View File

@@ -755,7 +755,7 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
Log.v(TAG, "startWebServer()");
mUtil.writeToSysLogFile("SdServer.Start Web Server.");
if (webServer == null) {
webServer = new SdWebServer(getApplicationContext(), mUtil.getDataStorageDir(), mSdData);
webServer = new SdWebServer(getApplicationContext(), mUtil.getDataStorageDir(), mSdData, this);
try {
webServer.start();
} catch (IOException ioe) {

View File

@@ -25,14 +25,16 @@ import fi.iki.elonen.NanoHTTPD;
public class SdWebServer extends NanoHTTPD {
private String TAG = "WebServer";
private SdData mSdData;
private SdServer mSdServer;
private Context mContext;
private File mDataStorageDir = null;
public SdWebServer(Context context, File storageDir, SdData sdData) {
public SdWebServer(Context context, File storageDir, SdData sdData, SdServer sdServer) {
// Set the port to listen on (8080)
super(8080);
mSdData = sdData;
mContext = context;
mSdServer = sdServer;
mDataStorageDir = storageDir;
}
@@ -110,6 +112,12 @@ public class SdWebServer extends NanoHTTPD {
}
break;
case "/acceptalarm":
Log.v(TAG, "WebServer.serve() - Accepting alarm");
mSdServer.acceptAlarm();
answer = "Alarm Accepted";
break;
default:
if (uri.startsWith("/index.html") ||
uri.startsWith("/logfiles.html") ||