Android Question how to access rc signal strenght with java object?

shb777

Active Member
Licensed User
Longtime User
I've got the drone first working the way i want it. the most important thing missing is RC signal strength. Will that be included in the new SDK you're working on. any rough timetable for that?


Should be possible to access it with JavaObject. Please start a new thread in the questions forum.

So how do you do this with java object? is there a java object tutorial? Steve

looks like it would be in the airlink part of sdk
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please try this:
B4X:
Sub AfterAircraftConnected
   If aircraft.CameraReady = False Or aircraft.BatteryReady = False Then
     Log("Camera / battery not ready")
     Sleep(500)
     If aircraft.Connected Then AfterAircraftConnected
     Return
   End If
   aircraft.RegisterBatteryStateEvent
   controller.Initialize("controller", aircraft)
   Log($"simulator: ${controller.SimulatorStarted)}"$
   camera.Initialize("camera", aircraft)
   pnlCamera.AddView(camera.CreateVideoView, 0, 0, pnlCamera.Width, pnlCamera.Height)
   timer1.Enabled = True
   WaypointOperator.Initialize("WaypointOperator")
   aircraftName = "N/A"
   Wait for (aircraft.GetName) Aircraft_ResultWithValue (Success As Boolean, ErrorMessage As String, Value As Object)
   If Success Then
     aircraftName = Value
   End If
 'new code ***************************
   Dim jo As JavaObject = aircraft
   Dim airlink As JavaObject = jo.RunMethod("getAirLink", Null)
   Dim event As Object = airlink.CreateEventFromUI("dji.common.airlink.SignalQualityCallback", "DownloadSignalChanged", Null)
   airlink.RunMethod("setDownlinkSignalQualityCallback", Array(event))
   
End Sub

Sub DownloadSignalChanged_Event (MethodName As String, Args() As Object) As Object
   Dim strength As Int = Args(0)
   Log(strength)
   Return Null
End Sub
 
Upvote 0

shb777

Active Member
Licensed User
Longtime User
I tried it and got a signal strength of 90. I was getting 5 bars on the RC because I was right next to the Mavic. I can test it outdoors tomorrow. Thanks Steve
 
Upvote 0

shb777

Active Member
Licensed User
Longtime User
took it to the park today, and the tablet wouldn't connect to the rc. tried for
10 minutes turning things on and off and it wouldn't connect.
got it home and they connected right away! tried moving the drone further away and no change in signal strength. folded the antennas up and no change
so i don't think it's working. DownloadSignalChanged_Event got called at least once. I'll keep trying Steve
 
Upvote 0

shb777

Active Member
Licensed User
Longtime User
the only reason I can think that it didn't connect in the Park, is I started a screen capture before trying to connect, and maybe it was using to much cpu.
but i did restart the shield, so that ended screen capture, and it still didn't connect. I do use laptop for development, but the android sdk is on a usb drive that needs to be plugged in. maybe i'll try by my house now. steve

just flew it outside. went 2,500 feet away and down to 3 bars but never changed from 90.
everything else was working. steve

i put in a counter to count how many times DownloadSignalChanged_Event was called,
and on connecting to drone. it was called exactly 2 times.



Sub DownloadSignalChanged_Event (MethodName As String, Args() As Object) As Object
Dim strength As Int = Args(0)

RCSignalStrenghtMavic=strength
ssc=ssc+1
Labelssc.text=ssc

Log(strength)
Return Null
End Sub

I see signal strength is returned as a percentage, so 90 would be a valid value.
 
Last edited:
Upvote 0

shb777

Active Member
Licensed User
Longtime User
i implemented your java object for signal strength and it's not working. steve
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I see signal strength is returned as a percentage, so 90 would be a valid value.
You mean that it is not a valid value, right?

You can try to replace setDownlinkSignalQualityCallback with setUplinkSignalQualityCallback

What is the output of
B4X:
Log(airlink.RunMethod("isLightbridgeLinkSupported", Null))
Log("airlink: " & airlink.RunMethod("getLightbridgeLink", Null))
 
Upvote 0

shb777

Active Member
Licensed User
Longtime User
ok I'll try that. 90 would be a valid value for a percentage(it's between 0 and 100)
 
Upvote 0

shb777

Active Member
Licensed User
Longtime User
I found this. I guess my Mavic doesn't use lightbridge. Think that's the problem?

DJI Mavic doesn’t have LightBridge, it has Ocusync
The DJI Mavic doesn’t come with LightBridge. But, before you get disappointed, it comes with Ocusync instead.

And rather than being disappointed about it not having LightBridge, you should be very excited about Ocusync on the DJI Mavic Pro.

Thanks to Ocusync the DJI Mavic can stream a 1080p feed from the DJI Mavic Pro and it can stream it up until 4.3 miles (7KM).
 
Upvote 0

shb777

Active Member
Licensed User
Longtime User
the output is airlink: null steve
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Change it to:
B4X:
Dim synclink As JavaObject = airlink.RunMethod("getOcuSyncLink", Null)
Log("link: " & synclink)

If it is not null then you can add a listener with:
B4X:
   synclink.RunMethod("setDownlinkSignalQualityCallback", Array(event))
  
End Sub

Sub DownloadSignalChanged_Event (MethodName As String, Args() As Object) As Object
   Dim strength As Int = Args(0)
   Log(strength)
   Return Null
End Sub
Instead of adding it to airlink directly.
 
Upvote 0

shb777

Active Member
Licensed User
Longtime User
ok thanks. I'll try it. Steve
 
Upvote 0

shb777

Active Member
Licensed User
Longtime User
I put in the new code. "link: & synclink was link: (OcuSynLink) dji.sdk.airlink.OcuSync@c52730c

but when I put in the callback function, I got the exact same result as before. Signal Strength was 90 and the callback only was called twice. I moved
the mavic around in my room but no more callbacks. rc showed 5 bars. I'll recheck to see if i've made any mistakes. steve
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I moved
the mavic around in my room but no more callbacks. rc showed 5 bars
Maybe i do not understand correctly.
But when i move my drone around (in my room) then i would not expect to get any changes in the signalstrength!? After a time i would expect changing in the baterylevel but not really in the Signalstrength.

Or did i understand it wrong?
 
Upvote 0

shb777

Active Member
Licensed User
Longtime User
Yesterday I got a different result. I was flying a GPS waypoint mission and I lost rc signal. Went the mavic came back into signal range, the signal strength callback function got called 7 times. The signal strength had a value of 55. That's the first time it's been anything besides 0 and 90. But I've flown it a lot now with the signal strength code and it's hardly worked at all. Yes, in the house is not the best test bed but you would think it would change a little. Does anyone else have a mavic they could test this with? Steve
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…