Android Question Signal quality in DJI virtual strick example

derez

Expert
Licensed User
Longtime User
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:

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...
 
Last edited by a moderator:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Both the Java code and the B4A code are wrong.

Start with this code:
B4X:
Dim RemoteController As JavaObject = AirCraft.As(JavaObject).RunMethod("getRemoteController", Null)
Dim cc As Object = RemoteController .CreateEventFromUI("dji.common.util.CommonCallbacks.CompletionCallbackWith", "AvailableMasters", Null)
RemoteController.RunMethod("getAvailableMasters", Array(cc ))
Wait For AvailableMasters_Event (MethodName As String, Args() As Object)
Log(MethodName)
Log(Args(0))

If it works then Args(0) should be an array of "Information" and the first entry will include the data you are looking for.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Thanks, I'll try it !
 
Upvote 0

derez

Expert
Licensed User
Longtime User
I checked, got for methodname "onFailure" and for args(0) "not supported(255)"
It requires something else if at all.
I use mini 2 which works only using virtual stick methods, not the mission builder, this is probably the reason for the results.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…