Please select Into the mobile phone version | Continue to access the computer ver.
Remote controller data is null
29 0 11-18 08:59
Uploading and Loding Picture ...(0/1)
o(^-^)o
fernando_s971
lvl.2

Brazil
Offline

Context

I'm trying to get the following data from the remote controller: name, lower signal strength between the two antenna and the GPS data.

Problem

All those data are coming null. The only exception is for the Phantom 4 Pro V2, that the name is coming as a replacement character (black diamond with a white question mark).

Code

@NonNull
public RemoteControllerInfo getRemoteControllerInfo() {
  final String name = (String) getValueFromDjiKey(
    RemoteControllerKey.create(RemoteControllerKey.NAME)
  );

  final LightbridgeAntennaRSSI antennas =
    (LightbridgeAntennaRSSI) getValueFromDjiKey(
      AirLinkKey.create(AirLinkKey.REMOTE_CONTROLLER_ANTENNA_RSSI)
    );
  final Integer signalStrengthInPercent = antennas == null
    ? null
    : Math.min(antennas.getAntenna1(), antennas.getAntenna2());

  final RemoteControllerGps remoteControllerGps;
  final GPSData gpsData = (GPSData) getValueFromDjiKey(
    RemoteControllerKey.create(RemoteControllerKey.GPS_DATA)
  );
  if (gpsData != null && gpsData.isValid()) {
    final GPSData.GPSLocation gpsLocation = gpsData.getLocation();
    final GPSData.Time gpsDateTime = gpsData.getTime();
    remoteControllerGps = RemoteControllerGps.builder()
      .latitude(gpsLocation.getLatitude())
      .longitude(gpsLocation.getLongitude())
      .year(gpsDateTime.getYear())
      .month((int) gpsDateTime.getMonth())
      .day((int) gpsDateTime.getDay())
      .hour((int) gpsDateTime.getHour())
      .minute((int) gpsDateTime.getMinute())
      .second((int) gpsDateTime.getSecond())
      .build();
  }

  return RemoteControllerInfo.builder()
    .name(name)
    .signalStrengthPercentage(signalStrengthInPercent)
    .remoteControllerGps(remoteControllerGps)
    .build();
}

@Nullable
private Object getValueFromDjiKey(@Nullable final DJIKey key) {
  final Object[] result = new Object[1];

  final CountDownLatch onFinishSignal = new CountDownLatch(1);
  KeyManager.getInstance().getValue(key, new GetCallback() {
    @Override
    public void onSuccess(@NonNull final Object o) {
      result[0] = o;

      onFinishSignal.countDown();
    }

    @Override
    public void onFailure(@NonNull final DJIError djiError) {
      onFinishSignal.countDown();
    }
  });
  synchronized (onFinishSignal) {
    try {
      onFinishSignal.await();
    } catch (final InterruptedException ignored) {
    }
  }

  return result[0];
}

Environment:

  • Phantom 4 Pro/Pro V2/Advanced/Standard
  • Android 9
  • MSDK v4.13.1


11-18 08:59
Use props
Advanced
You need to log in before you can reply Login | Register now

Credit Rules