mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Casio: Signal activity fetch finish
This commit is contained in:
parent
88c2c159f6
commit
af17e55c11
@ -203,8 +203,8 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared
|
|||||||
|
|
||||||
public void stepCountDataFetched(int totalCount, int totalCalories, ArrayList<CasioGBX100ActivitySample> data) {
|
public void stepCountDataFetched(int totalCount, int totalCalories, ArrayList<CasioGBX100ActivitySample> data) {
|
||||||
LOG.info("Got the following step count data: ");
|
LOG.info("Got the following step count data: ");
|
||||||
LOG.info("Total Count: " + totalCount);
|
LOG.info("Total Count: {}", totalCount);
|
||||||
LOG.info("Total Calories: " + totalCalories);
|
LOG.info("Total Calories: {}", totalCalories);
|
||||||
|
|
||||||
addGBActivitySamples(data);
|
addGBActivitySamples(data);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ import nodomain.freeyourgadget.gadgetbridge.entities.CasioGBX100ActivitySample;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
|
||||||
@ -56,7 +55,7 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
builder.notify(getCharacteristic(CasioConstants.CASIO_CONVOY_CHARACTERISTIC_UUID), enable);
|
builder.notify(getCharacteristic(CasioConstants.CASIO_CONVOY_CHARACTERISTIC_UUID), enable);
|
||||||
builder.queue(getQueue());
|
builder.queue(getQueue());
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
LOG.info("Error enabling required notifications" + e.getMessage());
|
LOG.error("Error enabling required notifications", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
builder.write(getCharacteristic(CasioConstants.CASIO_DATA_REQUEST_SP_CHARACTERISTIC_UUID), command);
|
builder.write(getCharacteristic(CasioConstants.CASIO_DATA_REQUEST_SP_CHARACTERISTIC_UUID), command);
|
||||||
builder.queue(getQueue());
|
builder.queue(getQueue());
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
LOG.info("Error requesting step count data: " + e.getMessage());
|
LOG.error("Error requesting step count data", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +81,7 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
builder.write(getCharacteristic(CasioConstants.CASIO_DATA_REQUEST_SP_CHARACTERISTIC_UUID), command);
|
builder.write(getCharacteristic(CasioConstants.CASIO_DATA_REQUEST_SP_CHARACTERISTIC_UUID), command);
|
||||||
builder.queue(getQueue());
|
builder.queue(getQueue());
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
LOG.info("Error requesting step count data: " + e.getMessage());
|
LOG.error("Error writing step count ack", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,10 +100,10 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void operationFinished() {
|
protected void operationFinished() {
|
||||||
LOG.info("SetConfigurationOperation finished");
|
LOG.info("FetchStepCountDataOperation finished");
|
||||||
unsetBusy();
|
unsetBusy();
|
||||||
GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), false, 100, getContext());
|
GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), false, 100, getContext());
|
||||||
|
GB.signalActivityDataFinish(getDevice());
|
||||||
|
|
||||||
operationStatus = OperationStatus.FINISHED;
|
operationStatus = OperationStatus.FINISHED;
|
||||||
if (getDevice() != null) {
|
if (getDevice() != null) {
|
||||||
@ -114,7 +113,7 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
builder.wait(0);
|
builder.wait(0);
|
||||||
builder.queue(getQueue());
|
builder.queue(getQueue());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LOG.info("Error resetting Gatt callback: " + ex.getMessage());
|
LOG.error("Error resetting Gatt callback", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,7 +132,7 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
if (data.length > 3) {
|
if (data.length > 3) {
|
||||||
length = (data[2] & 0xff) | ((data[3] & 0xff) << 8);
|
length = (data[2] & 0xff) | ((data[3] & 0xff) << 8);
|
||||||
}
|
}
|
||||||
LOG.debug("Response is going to be " + length + " bytes long");
|
LOG.debug("Response is going to be {} bytes long", length);
|
||||||
GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, 10, getContext());
|
GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, 10, getContext());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -149,7 +148,7 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
if(data.length == (payloadLength + 2)) {
|
if(data.length == (payloadLength + 2)) {
|
||||||
LOG.debug("Payload length and data length match.");
|
LOG.debug("Payload length and data length match.");
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Payload length and data length do not match: " + payloadLength + " vs. " + data.length);
|
LOG.warn("Payload length and data length do not match: {} vs. {}", payloadLength, data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||||
@ -172,8 +171,8 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
int yearOfBirth = ((data[13] & 0xff) | ((data[14] & 0xff) << 8));
|
int yearOfBirth = ((data[13] & 0xff) | ((data[14] & 0xff) << 8));
|
||||||
int monthOfBirth = data[15];
|
int monthOfBirth = data[15];
|
||||||
int dayOfBirth = data[16];
|
int dayOfBirth = data[16];
|
||||||
LOG.debug("Current step count value: " + stepCount);
|
LOG.debug("Current step count value: {}", stepCount);
|
||||||
LOG.debug("Current calories: " + calories);
|
LOG.debug("Current calories: {}", calories);
|
||||||
// data[17]:
|
// data[17]:
|
||||||
// 0x01 probably means finished.
|
// 0x01 probably means finished.
|
||||||
// 0x00 probably means more data.
|
// 0x00 probably means more data.
|
||||||
@ -207,12 +206,12 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
packetIndex = 0;
|
packetIndex = 0;
|
||||||
inPacket = true;
|
inPacket = true;
|
||||||
index = index + 3;
|
index = index + 3;
|
||||||
LOG.debug("Decoding packet with type: " + type + " and length: " + packetLength);
|
LOG.debug("Decoding packet with type: {} and length: {}", type, packetLength);
|
||||||
}
|
}
|
||||||
int count = ((data[index] & 0xff) | ((data[index + 1] & 0xff) << 8));
|
int count = ((data[index] & 0xff) | ((data[index + 1] & 0xff) << 8));
|
||||||
if(count == 0xfffe)
|
if(count == 0xfffe)
|
||||||
count = 0;
|
count = 0;
|
||||||
LOG.debug("Got count " + count);
|
LOG.debug("Got count {}", count);
|
||||||
|
|
||||||
index = index+2;
|
index = index+2;
|
||||||
if(index >= data.length) {
|
if(index >= data.length) {
|
||||||
@ -263,7 +262,7 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
cal.set(year + 2000, month, day, hour, 30, 0);
|
cal.set(year + 2000, month, day, hour, 30, 0);
|
||||||
int ts = (int) (cal.getTimeInMillis() / 1000);
|
int ts = (int) (cal.getTimeInMillis() / 1000);
|
||||||
|
|
||||||
LOG.debug("Artificial timestamp: " + cals + " calories and " + steps + " steps");
|
LOG.debug("Artificial timestamp: {} calories and {} steps", cals, steps);
|
||||||
CasioGBX100ActivitySample sample = new CasioGBX100ActivitySample();
|
CasioGBX100ActivitySample sample = new CasioGBX100ActivitySample();
|
||||||
sample.setSteps(steps);
|
sample.setSteps(steps);
|
||||||
sample.setCalories(cals);
|
sample.setCalories(cals);
|
||||||
@ -282,7 +281,7 @@ public class FetchStepCountDataOperation extends AbstractBTLEOperation<CasioGBX
|
|||||||
writeStepCountAck();
|
writeStepCountAck();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LOG.info("Unhandled characteristic changed: " + characteristicUUID);
|
LOG.warn("Unhandled characteristic changed: {}", characteristicUUID);
|
||||||
return super.onCharacteristicChanged(gatt, characteristic);
|
return super.onCharacteristicChanged(gatt, characteristic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user