Continuing the discussions on Virtual Stick example https://www.b4x.com/android/forum/t...n-for-dji-mini-and-air-series.140089/#content
I asked ChatGPT how to get the signal quality from the drone, here is its answer:
Can someone help to put it in B4A code ? The flight controller is initialized in "AfterAircraftConnected" sub.
I asked again with request to put it in B4A code:
I asked ChatGPT how to get the signal quality from the drone, here is its answer:
B4X:
DJIFlightController flightController = djiAircraft.getFlightController();
flightController.getSignalQuality(new DJICommonCallbacks.DJICompletionCallbackWith<DJISignalQuality>() {
public void onSuccess(DJISignalQuality signalQuality) {
int quality = signalQuality.getSignalQuality();
// use the quality variable as per your needs.
}
public void onFailure(DJIError error) {
// handle error
}
});
Can someone help to put it in B4A code ? The flight controller is initialized in "AfterAircraftConnected" sub.
I asked again with request to put it in B4A code:
B4X:
Sub GetSignalQuality
Dim flightController As DJIFlightController = djiAircraft.GetFlightController
flightController.GetSignalQuality(SignalQualityCallback)
End Sub
Sub SignalQualityCallback(result As DJICommonCallbacks.DJICompletionCallbackWith(Of DJISignalQuality))
If result.Success Then
Dim signalQuality As DJISignalQuality = result.Value
Log("Signal Quality: " & signalQuality.SignalQuality)
Else
Log("Error getting signal quality: " & result.Error.Description)
End If
End Sub
I'm still lost...This code uses the GetSignalQuality method to request the signal quality from the drone, and the SignalQualityCallback subroutine is called when the signal quality is received. The signal quality is returned as a value between 0 and 100, and it is logged to the console. If there is an error getting the signal quality, the error message is also logged to the console.
Please note that the SDK's method djiAircraft.getFlightController() returns a DJIFlightController object, and the method GetSignalQuality from that object takes a callback as a parameter, which is called when the signal quality is obtained.
Last edited by a moderator: