Skip to content

Commit

Permalink
Fix issue where mavlink stats were shown in the bottom osd instead of…
Browse files Browse the repository at this point in the history
… video link stat. Fix issue when stopping activity.
  • Loading branch information
gehee committed Apr 29, 2024
1 parent 4a9d3cd commit 7039e78
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
15 changes: 14 additions & 1 deletion .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 7 additions & 14 deletions app/src/main/java/com/geehe/fpvue/VideoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import com.geehe.fpvue.databinding.ActivityVideoBinding;
Expand Down Expand Up @@ -123,7 +122,9 @@ public void onReceive(Context context, Intent intent) {

protected void onStop() {
MavlinkNative.nativeStop(this);
unregisterReceiver(usbReceiver);
try {
unregisterReceiver(usbReceiver);
} catch(java.lang.IllegalArgumentException ignored) {}
Log.d(TAG, "onStop");
StopWfbNg();
super.onStop();
Expand Down Expand Up @@ -255,10 +256,6 @@ public void run() {
@Override
public void onNothingSelected(AdapterView<?> parent) {}

private int count_p_dec_err = 0;
private int count_p_lost = 0;
private int count_p_fec_recovered = 0;
private int count_p_outgoing = 0;
@Override
public void onWfbNgStatsChanged(WfbNGStats data) {
binding.tvMessage.setVisibility(View.INVISIBLE);
Expand All @@ -267,22 +264,18 @@ public void onWfbNgStatsChanged(WfbNGStats data) {
@Override
public void run() {
if (data.count_p_all > 0) {
int perr = data.count_p_dec_err - count_p_dec_err;
int perr = data.count_p_dec_err;
if (perr > 0) {
binding.tvWFBNGStatus.setText("Waiting for session key.");
} else {
binding.tvWFBNGStatus.setText(String.format("lost=%d\t\trec=%d\t\tok=%d",
data.count_p_lost - count_p_lost,
data.count_p_fec_recovered - count_p_fec_recovered,
data.count_p_outgoing - count_p_outgoing));
data.count_p_lost,
data.count_p_fec_recovered ,
data.count_p_outgoing));
}
} else {
binding.tvWFBNGStatus.setText("No wfb-ng data.");
}
count_p_dec_err = data.count_p_dec_err;
count_p_lost = data.count_p_lost;
count_p_fec_recovered = data.count_p_fec_recovered;
count_p_outgoing = data.count_p_outgoing;
}
});
}
Expand Down
4 changes: 1 addition & 3 deletions app/wfbngrtl8812/src/main/cpp/WfbngLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ int WfbngLink::run(JNIEnv* env, jobject context, jint wifiChannel) {

Logger_t log;
WiFiDriver wifi_driver(log);
//WiFiDriver wifi_driver;
rtlDevice = wifi_driver.CreateRtlDevice(dev_handle);
if (!rtlDevice) {
__android_log_print(ANDROID_LOG_DEBUG, TAG,
Expand Down Expand Up @@ -98,7 +97,6 @@ int WfbngLink::run(JNIEnv* env, jobject context, jint wifiChannel) {
Aggregator video_agg(client_addr, video_client_port, keyPath, epoch, video_channel_id_f);
aggregator = &video_agg;
Aggregator mavlink_agg(client_addr, mavlink_client_port, keyPath, epoch, mavlink_channel_id_f);
aggregator = &mavlink_agg;

auto packetProcessor = [&video_agg, video_channel_id_be8, &mavlink_agg, mavlink_channel_id_be8 ](const Packet &packet) {
RxFrame frame(packet.Data);
Expand Down Expand Up @@ -205,5 +203,5 @@ Java_com_geehe_wfbngrtl8812_WfbNgLink_nativeCallBack(JNIEnv *env, jclass clazz,
return;
}
env->CallVoidMethod(wfbStatChangedI,onStatsChanged,stats);
// aggregator->reset_stats();
aggregator->clear_stats();
}

0 comments on commit 7039e78

Please sign in to comment.