@@ -29,9 +29,9 @@ public class TestReceiverTelemetry implements Runnable, LifecycleObserver {
29
29
private Thread mThread ;
30
30
31
31
public <T extends Activity & LifecycleOwner > TestReceiverTelemetry (final T t ){
32
- t .getLifecycle ().addObserver (this );
33
32
this .activity =t ;
34
33
telemetryReceiver =new TelemetryReceiver (t );
34
+ t .getLifecycle ().addObserver (this );
35
35
}
36
36
37
37
public void setViews (TextView receivedTelemetryDataTV , TextView ezwbForwardDataTV , TextView telemetryValuesAsString ){
@@ -53,6 +53,44 @@ private void stopUiUpdates(){
53
53
try {mThread .join ();} catch (InterruptedException e ) {e .printStackTrace ();}
54
54
}
55
55
56
+ @ Override
57
+ public void run () {
58
+ long lastCheckMS = System .currentTimeMillis () - 2 *1000 ;
59
+ while (!Thread .currentThread ().isInterrupted ()){
60
+ //if any of the TV are not null, we update its content
61
+ //with the corresponding string, and optionally change color
62
+ if (receivedTelemetryDataTV !=null ){
63
+ final String s = telemetryReceiver .getStatisticsAsString ();
64
+ final int newColor =telemetryReceiver .anyTelemetryDataReceived () ? Color .GREEN : Color .RED ;
65
+ updateViewIfStringChanged (receivedTelemetryDataTV ,s ,true ,newColor );
66
+ }
67
+ if (ezwbForwardDataTV !=null ){
68
+ final String s = telemetryReceiver .getEZWBDataAsString ();
69
+ updateViewIfStringChanged (ezwbForwardDataTV ,s ,false ,0 );
70
+ }
71
+ if (dataAsStringTV !=null ){
72
+ final String s = telemetryReceiver .getTelemetryDataAsString ();
73
+ updateViewIfStringChanged (dataAsStringTV ,s ,false ,0 );
74
+ }
75
+ if (telemetryReceiver .isEZWBIpAvailable ()){
76
+ onEZWBIpDetected (telemetryReceiver .getEZWBIPAdress ());
77
+ }
78
+ //Every 3.5s we check if we are receiving video data, but cannot parse the data. Probably the user did mix up
79
+ //ezwb-versions
80
+ if (System .currentTimeMillis ()- lastCheckMS >=3500 ){
81
+ final boolean errorEZ_WB = telemetryReceiver .receivingEZWBButCannotParse ();
82
+ lastCheckMS =System .currentTimeMillis ();
83
+ if (errorEZ_WB ){
84
+ makeToastOnUI ("You are receiving ez-wifibroadcast telemetry data, but FPV-VR cannot parse it. Probably you are using" +
85
+ " app version 1.5 or higher with ez-wb. 1.6 or lower. Please upgrade to ez-wb 2.0. This also allows you to read all useful" +
86
+ " telemetry data from your EZ-WB rx pi on android." ,Toast .LENGTH_SHORT );
87
+ }
88
+ }
89
+ //Refresh every 200ms
90
+ try {Thread .sleep (200 );} catch (InterruptedException e ) {return ;}
91
+ }
92
+ }
93
+
56
94
@ SuppressLint ("ApplySharedPref" )
57
95
private void onEZWBIpDetected (String ip ){
58
96
//System.out.println("Called from native:"+ip);
@@ -92,44 +130,6 @@ public void run() {
92
130
});
93
131
}
94
132
95
- @ Override
96
- public void run () {
97
- long lastCheckMS = System .currentTimeMillis () - 2 *1000 ;
98
- while (!Thread .currentThread ().isInterrupted ()){
99
- //if any of the TV are not null, we update its content
100
- //with the corresponding string, and optionally change color
101
- if (receivedTelemetryDataTV !=null ){
102
- final String s = telemetryReceiver .getStatisticsAsString ();
103
- final int newColor =telemetryReceiver .anyTelemetryDataReceived () ? Color .GREEN : Color .RED ;
104
- updateViewIfStringChanged (receivedTelemetryDataTV ,s ,true ,newColor );
105
- }
106
- if (ezwbForwardDataTV !=null ){
107
- final String s = telemetryReceiver .getEZWBDataAsString ();
108
- updateViewIfStringChanged (ezwbForwardDataTV ,s ,false ,0 );
109
- }
110
- if (dataAsStringTV !=null ){
111
- final String s = telemetryReceiver .getTelemetryDataAsString ();
112
- updateViewIfStringChanged (dataAsStringTV ,s ,false ,0 );
113
- }
114
- if (telemetryReceiver .isEZWBIpAvailable ()){
115
- onEZWBIpDetected (telemetryReceiver .getEZWBIPAdress ());
116
- }
117
- //Every 3.5s we check if we are receiving video data, but cannot parse the data. Probably the user did mix up
118
- //ezwb-versions
119
- if (System .currentTimeMillis ()- lastCheckMS >=3500 ){
120
- final boolean errorEZ_WB = telemetryReceiver .receivingEZWBButCannotParse ();
121
- lastCheckMS =System .currentTimeMillis ();
122
- if (errorEZ_WB ){
123
- makeToastOnUI ("You are receiving ez-wifibroadcast telemetry data, but FPV-VR cannot parse it. Probably you are using" +
124
- " app version 1.5 or higher with ez-wb. 1.6 or lower. Please upgrade to ez-wb 2.0. This also allows you to read all useful" +
125
- " telemetry data from your EZ-WB rx pi on android." ,Toast .LENGTH_SHORT );
126
- }
127
- }
128
- //Refresh every 200ms
129
- try {Thread .sleep (200 );} catch (InterruptedException e ) {return ;}
130
- }
131
- }
132
-
133
133
public interface EZWBIpAddressDetected {
134
134
void onEZWBIpDetected (String ip );
135
135
}
0 commit comments