mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Vesc: Deprecate DeviceType constructor
This commit is contained in:
-53
@@ -24,20 +24,14 @@ import android.os.ParcelUuid;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.vesc.VescDeviceSupport;
|
||||
|
||||
@@ -50,7 +44,6 @@ public class VescCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
public final static String UUID_CHARACTERISTIC_SERIAL_TX_NRF = "0000ffe0-0000-1000-8000-00805f9b34fb";
|
||||
public final static String UUID_CHARACTERISTIC_SERIAL_RX_NRF = "0000ffe1-0000-1000-8000-00805f9b34fb";
|
||||
|
||||
|
||||
@Override
|
||||
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
|
||||
|
||||
@@ -100,36 +93,11 @@ public class VescCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
return BONDING_STYLE_NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsActivityTracking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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 "Benjamin Vedder";
|
||||
@@ -145,27 +113,6 @@ public class VescCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
return VescControlActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsCalendarEvents() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRealtimeData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsWeather() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsFindDevice() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getDeviceNameResource() {
|
||||
return R.string.devicetype_vesc;
|
||||
|
||||
+10
-10
@@ -38,12 +38,13 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vesc.VescCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.CheckSums;
|
||||
|
||||
public class VescDeviceSupport extends VescBaseDeviceSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(VescDeviceSupport.class);
|
||||
|
||||
BluetoothGattCharacteristic serialWriteCharacteristic, serialReadCharacteristic;
|
||||
|
||||
public static final String COMMAND_SET_RPM = "nodomain.freeyourgadget.gadgetbridge.vesc.command.SET_RPM";
|
||||
@@ -56,17 +57,12 @@ public class VescDeviceSupport extends VescBaseDeviceSupport {
|
||||
|
||||
public static final String ACTION_GOT_VALUES = "nodomain.freeyourgadget.gadgetbridge.vesc.action.GOT_VALUES";
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private final ByteBuffer responseBuffer = ByteBuffer.allocate(100);
|
||||
|
||||
private DeviceType deviceType;
|
||||
|
||||
private ByteBuffer responseBuffer = ByteBuffer.allocate(100);
|
||||
|
||||
public VescDeviceSupport(DeviceType type) {
|
||||
public VescDeviceSupport() {
|
||||
super();
|
||||
responseBuffer.order(ByteOrder.BIG_ENDIAN);
|
||||
|
||||
deviceType = type;
|
||||
addSupportedService(UUID.fromString(VescCoordinator.UUID_SERVICE_SERIAL_NRF));
|
||||
addSupportedService(UUID.fromString(VescCoordinator.UUID_SERVICE_SERIAL_HM10));
|
||||
}
|
||||
@@ -78,7 +74,7 @@ public class VescDeviceSupport extends VescBaseDeviceSupport {
|
||||
|
||||
@Override
|
||||
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
||||
logger.debug("initializing device");
|
||||
LOG.debug("initializing device");
|
||||
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
||||
|
||||
@@ -116,7 +112,7 @@ public class VescDeviceSupport extends VescBaseDeviceSupport {
|
||||
if (characteristic != serialReadCharacteristic) return;
|
||||
|
||||
responseBuffer.put(characteristic.getValue());
|
||||
short length = 0;
|
||||
short length;
|
||||
int oldPosition = responseBuffer.position();
|
||||
responseBuffer.position(0);
|
||||
byte lengthType = responseBuffer.get();
|
||||
@@ -247,6 +243,10 @@ public class VescDeviceSupport extends VescBaseDeviceSupport {
|
||||
BroadcastReceiver commandReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction() == null) {
|
||||
LOG.warn("Null action, ignoring");
|
||||
return;
|
||||
}
|
||||
if (intent.getAction().equals(COMMAND_SET_RPM)) {
|
||||
VescDeviceSupport.this.setRPM(
|
||||
intent.getIntExtra(EXTRA_RPM, 0)
|
||||
|
||||
Reference in New Issue
Block a user