Progressing with uploading datapoints to the server...not working yet...

This commit is contained in:
Graham Jones
2021-12-17 05:56:36 +00:00
parent bec437e858
commit 361e4a09fd
2 changed files with 5 additions and 0 deletions

View File

@@ -17,6 +17,8 @@ import android.widget.TextView;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
public class AuthenticateActivity extends AppCompatActivity public class AuthenticateActivity extends AppCompatActivity
@@ -150,8 +152,10 @@ public class AuthenticateActivity extends AppCompatActivity
String jsonStr = ""; String jsonStr = "";
JSONObject dataObj; JSONObject dataObj;
try { try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
jsonStr = "{HR:70}"; jsonStr = "{HR:70}";
dataObj = new JSONObject(jsonStr); dataObj = new JSONObject(jsonStr);
dataObj.put("dataTime", dateFormat.format(new Date()));
Log.v(TAG, "Creating Datapoint..."+dataObj.toString()); Log.v(TAG, "Creating Datapoint..."+dataObj.toString());
mWac.createDatapoint(dataObj,10); mWac.createDatapoint(dataObj,10);
} catch (JSONException e) { } catch (JSONException e) {

View File

@@ -225,6 +225,7 @@ public class WebApiConnection {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
try { try {
jsonObject.put("eventId", String.valueOf(eventId)); jsonObject.put("eventId", String.valueOf(eventId));
jsonObject.put("dataTime", dataObj.getString("dataTime"));
jsonObject.put("dataJSON", dataObj.toString()); jsonObject.put("dataJSON", dataObj.toString());
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG, "Error generating event JSON string"); Log.e(TAG, "Error generating event JSON string");