1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 04:46:51 +01:00

Device UM25C: fixed disconnection scenario

This commit is contained in:
Daniel Dakhno 2024-07-09 00:25:01 +02:00
parent 8672dcac3c
commit 6f7844418e
2 changed files with 10 additions and 63 deletions

View File

@ -77,52 +77,11 @@ public class UM25Coordinator extends AbstractBLEDeviceCoordinator {
};
}
@Nullable
@Override
public Class<? extends Activity> getPairingActivity() {
return null;
}
@Override
public boolean supportsActivityDataFetching() {
return false;
}
@Override
public boolean supportsActivityTracking() {
return false;
}
@Override
public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
public boolean supportsFindDevice() {
return false;
}
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {
return null;
}
@Override
public boolean supportsScreenshots(final GBDevice device) {
return false;
}
@Override
public int getAlarmSlotCount(GBDevice device) {
return 0;
}
@Override
public boolean supportsHeartRateMeasurement(GBDevice device) {
return false;
}
@Override
public String getManufacturer() {
return "Ruideng";
@ -138,21 +97,6 @@ public class UM25Coordinator extends AbstractBLEDeviceCoordinator {
return DataActivity.class;
}
@Override
public boolean supportsCalendarEvents() {
return false;
}
@Override
public boolean supportsRealtimeData() {
return false;
}
@Override
public boolean supportsWeather() {
return false;
}
@Override
public int getBatteryCount() {
return 0;

View File

@ -68,6 +68,8 @@ public class UM25Support extends UM25BaseSupport {
private ByteBuffer buffer = ByteBuffer.allocate(PAYLOAD_LENGTH);
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
private static final Logger logger = LoggerFactory.getLogger(UM25Support.class);
SharedPreferences preferences;
@ -142,19 +144,20 @@ public class UM25Support extends UM25BaseSupport {
super.dispose();
LocalBroadcastManager.getInstance(getContext())
.unregisterReceiver(resetReceiver);
executor.shutdown();
}
private void startLoop(){
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
executor.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
sendReadCommand();
}
}, 0, LOOP_DELAY, TimeUnit.MILLISECONDS);
executor.scheduleWithFixedDelay(this::sendReadCommand, 0, LOOP_DELAY, TimeUnit.MILLISECONDS);
}
private void sendReadCommand(){
if(!getDevice().isConnected()){
logger.debug("device disconnected, stopping executor");
executor.shutdown();
return;
}
logger.debug("sending read command");
buffer.reset();
new TransactionBuilder("send read command")