mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-01 14:32:54 +01:00
InfiniTime: support navigation app
This commit is contained in:
parent
93b9ee735c
commit
4cad3b3837
@ -36,6 +36,11 @@ public class PineTimeJFConstants {
|
||||
|
||||
public static final UUID UUID_SERVICE_NAVIGATION = UUID.fromString("00010000-78fc-48fe-8e23-433b3a1942d0");
|
||||
|
||||
public static final UUID UUID_CHARACTERISTICS_NAVIGATION_FLAGS = UUID.fromString("00010001-78fc-48fe-8e23-433b3a1942d0");
|
||||
public static final UUID UUID_CHARACTERISTICS_NAVIGATION_NARRATIVE = UUID.fromString("00010002-78fc-48fe-8e23-433b3a1942d0");
|
||||
public static final UUID UUID_CHARACTERISTICS_NAVIGATION_MAN_DISTANCE = UUID.fromString("00010003-78fc-48fe-8e23-433b3a1942d0");
|
||||
public static final UUID UUID_CHARACTERISTICS_NAVIGATION_PROGRESS = UUID.fromString("00010004-78fc-48fe-8e23-433b3a1942d0");
|
||||
|
||||
public static final UUID UUID_CHARACTERISTIC_ALERT_NOTIFICATION_EVENT = UUID.fromString("00020001-78fc-48fe-8e23-433b3a1942d0");
|
||||
|
||||
public static final UUID UUID_SERVICE_WEATHER = UUID.fromString("00040000-78fc-48fe-8e23-433b3a1942d0");
|
||||
|
@ -1238,6 +1238,10 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
registerReceiver(mAlarmClockReceiver, filter);
|
||||
}
|
||||
|
||||
if (mOsmandAidlHelper == null) {
|
||||
mOsmandAidlHelper = new OsmandEventReceiver(this.getApplication());
|
||||
}
|
||||
|
||||
// Weather receivers
|
||||
if (features.supportsWeather()) {
|
||||
if (GBApplication.isRunningOreoOrLater()) {
|
||||
@ -1245,8 +1249,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
mLineageOsWeatherReceiver = new LineageOsWeatherReceiver();
|
||||
registerReceiver(mLineageOsWeatherReceiver, new IntentFilter("GB_UPDATE_WEATHER"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (mCMWeatherReceiver == null) {
|
||||
mCMWeatherReceiver = new CMWeatherReceiver();
|
||||
registerReceiver(mCMWeatherReceiver, new IntentFilter("GB_UPDATE_WEATHER"));
|
||||
@ -1268,9 +1271,6 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
//Nothing wrong, it just means we're not running on omnirom.
|
||||
}
|
||||
}
|
||||
if (mOsmandAidlHelper == null) {
|
||||
mOsmandAidlHelper = new OsmandEventReceiver(this.getApplication());
|
||||
}
|
||||
}
|
||||
|
||||
if (GBApplication.getPrefs().getBoolean("auto_fetch_enabled", false) &&
|
||||
|
@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
@ -87,6 +88,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NavigationInfoSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WorldClock;
|
||||
@ -257,6 +259,7 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
|
||||
addSupportedService(GattService.UUID_SERVICE_BATTERY_SERVICE);
|
||||
addSupportedService(PineTimeJFConstants.UUID_SERVICE_MUSIC_CONTROL);
|
||||
addSupportedService(PineTimeJFConstants.UUID_SERVICE_WEATHER);
|
||||
addSupportedService(PineTimeJFConstants.UUID_SERVICE_NAVIGATION);
|
||||
addSupportedService(PineTimeJFConstants.UUID_CHARACTERISTIC_ALERT_NOTIFICATION_EVENT);
|
||||
addSupportedService(PineTimeJFConstants.UUID_SERVICE_MOTION);
|
||||
|
||||
@ -317,6 +320,68 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
|
||||
builder.queue(getQueue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetNavigationInfo(NavigationInfoSpec navigationInfoSpec) {
|
||||
TransactionBuilder builder = new TransactionBuilder("navigation info");
|
||||
if (navigationInfoSpec.instruction == null) {
|
||||
navigationInfoSpec.instruction = "";
|
||||
}
|
||||
|
||||
safeWriteToCharacteristic(builder, PineTimeJFConstants.UUID_CHARACTERISTICS_NAVIGATION_NARRATIVE, navigationInfoSpec.instruction.getBytes(StandardCharsets.UTF_8));
|
||||
safeWriteToCharacteristic(builder, PineTimeJFConstants.UUID_CHARACTERISTICS_NAVIGATION_MAN_DISTANCE, (navigationInfoSpec.distanceToTurn + "m").getBytes(StandardCharsets.UTF_8));
|
||||
String iconname;
|
||||
switch (navigationInfoSpec.nextAction) {
|
||||
case NavigationInfoSpec.ACTION_CONTINUE:
|
||||
iconname = "contine";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_TURN_LEFT:
|
||||
iconname = "turn-left";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_TURN_LEFT_SLIGHTLY:
|
||||
iconname = "turn-slight-left";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_TURN_LEFT_SHARPLY:
|
||||
iconname = "turn-sharp-left";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_TURN_RIGHT:
|
||||
iconname = "turn-right";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_TURN_RIGHT_SLIGHTLY:
|
||||
iconname = "turn-slight-right";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_TURN_RIGHT_SHARPLY:
|
||||
iconname = "turn-sharp-right";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_KEEP_LEFT:
|
||||
iconname = "continue-left";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_KEEP_RIGHT:
|
||||
iconname = "continue-right";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_UTURN_LEFT:
|
||||
case NavigationInfoSpec.ACTION_UTURN_RIGHT:
|
||||
iconname = "iturn";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_ROUNDABOUT_RIGHT:
|
||||
iconname = "roundabout-right";
|
||||
break;
|
||||
case NavigationInfoSpec.ACTION_ROUNDABOUT_LEFT:
|
||||
iconname = "roundabout-left";
|
||||
break;
|
||||
default:
|
||||
iconname = "invalid";
|
||||
break;
|
||||
}
|
||||
|
||||
safeWriteToCharacteristic(builder, PineTimeJFConstants.UUID_CHARACTERISTICS_NAVIGATION_FLAGS, iconname.getBytes(StandardCharsets.UTF_8));
|
||||
builder.queue(getQueue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteNotification(int id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetTime() {
|
||||
// Since this is a standard we should generalize this in Gadgetbridge (properly)
|
||||
|
Loading…
Reference in New Issue
Block a user