use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class WatchUpdaterService method sendActiveBtDeviceData.
private void sendActiveBtDeviceData() {
// KS
if (is_using_bt) {
// only required for Collector running on watch
forceGoogleApiConnect();
ActiveBluetoothDevice btDevice = ActiveBluetoothDevice.first();
if (btDevice != null) {
if (wear_integration) {
DataMap dataMap = new DataMap();
Log.d(TAG, "sendActiveBtDeviceData name=" + btDevice.name + " address=" + btDevice.address + " connected=" + btDevice.connected);
// MOST IMPORTANT LINE FOR TIMESTAMP
dataMap.putLong("time", new Date().getTime());
dataMap.putString("name", btDevice.name);
dataMap.putString("address", btDevice.address);
dataMap.putBoolean("connected", btDevice.connected);
new SendToDataLayerThread(WEARABLE_ACTIVEBTDEVICE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, dataMap);
}
}
} else {
Log.d(TAG, "Not sending activebluetoothdevice data as we are not using bt");
}
}
use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class WatchUpdaterService method sendWearBloodTestData.
public static boolean sendWearBloodTestData(Integer count, long startTime, List<BloodTest> list) {
// DataMap
try {
if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
googleApiClient.connect();
}
if (googleApiClient != null) {
BloodTest last = list != null && list.size() > 0 ? list.get(0) : BloodTest.last();
if (last != null) {
Log.d(TAG, "sendWearBloodTestData last.timestamp:" + JoH.dateTimeText(last.timestamp));
} else {
Log.d(TAG, "sendWearBloodTestData no BloodTest exist");
return true;
}
List<BloodTest> graph;
if (list != null)
graph = list;
else if (startTime == 0)
graph = BloodTest.last(count);
else
graph = BloodTest.latestForGraph(count, startTime);
if (!graph.isEmpty()) {
Log.d(TAG, "sendWearBloodTestData graph size=" + graph.size());
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph.size());
DataMap entries = dataMap(last);
for (BloodTest data : graph) {
dataMaps.add(dataMap(data));
}
Log.d(TAG, "sendWearBloodTestData entries=" + entries);
// MOST IMPORTANT LINE FOR TIMESTAMP
entries.putLong("time", new Date().getTime());
entries.putDataMapArrayList("entries", dataMaps);
new SendToDataLayerThread(WEARABLE_BLOODTEST_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
} else
Log.d(TAG, "sendWearBloodTestData BloodTest count = 0");
} else {
Log.e(TAG, "sendWearBloodTestData No connection to wearable available for send BloodTest!");
return false;
}
} catch (NullPointerException e) {
Log.e(TAG, "Nullpointer exception in sendWearBloodTestData: " + e);
return false;
}
return true;
}
use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class WatchUpdaterService method dataMap.
private static DataMap dataMap(BgReading bg) {
// KS
DataMap dataMap = new DataMap();
// KS Fix for calibration_uuid not being set in Calibration.create which updates bgReading to new calibration ln 497
// if (bg.calibration_flag == true) {
// bg.calibration_uuid = bg.calibration.uuid;
// }
dataMap.putString("calibrationUuid", bg.calibration.uuid);
String json = bg.toS();
Log.d(TAG, "dataMap BG GSON: " + json);
dataMap.putString("bgs", json);
return dataMap;
}
use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class WatchUpdaterService method dataMap.
private DataMap dataMap(AlertType alert, String type) {
// KS
DataMap dataMap = new DataMap();
String json = alert.toS();
Log.d(TAG, "dataMap BG GSON: " + json);
dataMap.putString(type, json);
return dataMap;
}
use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class WatchUpdaterService method resendData.
private void resendData() {
Log.d(TAG, "resendData ENTER");
forceGoogleApiConnect();
Log.d(TAG, "resendData googleApiClient connected ENTER");
long startTime = new Date().getTime() - (60000 * 60 * 24);
BgReading last_bg = BgReading.last();
if (last_bg != null) {
List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime);
BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getApplicationContext());
if (!graph_bgs.isEmpty()) {
final int battery = PowerStateReceiver.getBatteryLevel(getApplicationContext());
DataMap entries = dataMap(last_bg, mPrefs, bgGraphBuilder, battery);
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
for (BgReading bg : graph_bgs) {
dataMaps.add(dataMap(bg, mPrefs, bgGraphBuilder, battery));
}
// MOST IMPORTANT LINE FOR TIMESTAMP
entries.putLong("time", new Date().getTime());
entries.putDataMapArrayList("entries", dataMaps);
if (mPrefs.getBoolean("extra_status_line", false)) {
entries.putString("extra_status_line", Home.extraStatusLine());
}
new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
}
}
}
Aggregations