Started code to retrieve cnn model from server - not working!

This commit is contained in:
Graham Jones
2022-10-22 17:29:54 +01:00
parent 31e68eef86
commit 9d7eef8d5f
2 changed files with 51 additions and 0 deletions

View File

@@ -103,6 +103,8 @@ public abstract class WebApiConnection {
*/ */
public abstract boolean getEventTypes(JSONObjectCallback callback); public abstract boolean getEventTypes(JSONObjectCallback callback);
public abstract boolean getCnnModelInfo(JSONObjectCallback callback);
/** /**
* Retrieve a trivial file from the server to check we have a good server connection. * Retrieve a trivial file from the server to check we have a good server connection.

View File

@@ -633,6 +633,55 @@ public class WebApiConnection_osdapi extends WebApiConnection {
} }
/**
* Retrieve the file containing the CNN Models information from the server.
* Calls the specified callback function, passing a JSONObject as a parameter when the data has been received and parsed.
*
* @return true if request sent successfully or else false.
*/
public boolean getCNNModelInfo(JSONObjectCallback callback) {
Log.v(TAG, "getCNNModelInfo()");
String urlStr = mUrlBase + "/static/cnnModelInfo.json";
Log.v(TAG, "urlStr=" + urlStr);
final String authtoken = getStoredToken();
StringRequest req = new StringRequest(Request.Method.GET, urlStr,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.v(TAG, "getCNNModelInfo.onResponse(): Response is: " + response);
mServerConnectionOk = true;
try {
JSONObject retObj = new JSONObject(response);
callback.accept(retObj);
} catch (JSONException e) {
Log.e(TAG, "getCNNModelInfo.onRespons(): Error: " + e.getMessage() + "," + e.toString());
callback.accept(null);
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mServerConnectionOk = false;
if (error != null) {
Log.e(TAG, "getCNNModelInfo.onErrorResponse(): " + error.toString() + ", message:" + error.getMessage());
} else {
Log.e(TAG, "getCNNModelInfo.onErrorResponse() - returned null response");
}
callback.accept(null);
}
}) {
};
mQueue.add(req);
return (true);
}
/** /**
* Retrieve a trivial file from the server to check we have a good server connection. * Retrieve a trivial file from the server to check we have a good server connection.
* sets mServerConnectionOk. * sets mServerConnectionOk.