Skip to content

Commit b926e82

Browse files
committed
Option to enable/disable STBC/LDPC
1 parent 1c07124 commit b926e82

File tree

4 files changed

+73
-5
lines changed

4 files changed

+73
-5
lines changed

app/src/main/java/com/openipc/pixelpilot/VideoActivity.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,35 @@ private void setupAdaptiveLinkSubMenu(PopupMenu popup) {
735735
return true;
736736
});
737737

738+
// LDPC option
739+
boolean ldpcEnabled = prefs.getBoolean("custom_ldpc_enabled", true);
740+
MenuItem ldpcEnable = adaptiveMenu.add("LDPC");
741+
ldpcEnable.setCheckable(true);
742+
ldpcEnable.setChecked(ldpcEnabled);
743+
ldpcEnable.setOnMenuItemClickListener(item -> {
744+
boolean newState = !item.isChecked();
745+
item.setChecked(newState);
746+
SharedPreferences.Editor editor = getSharedPreferences("general", MODE_PRIVATE).edit();
747+
editor.putBoolean("custom_ldpc_enabled", newState);
748+
editor.apply();
749+
wfbLink.nativeSetUseLdpc(newState ? 1 : 0);
750+
return true;
751+
});
752+
753+
// STBC option
754+
boolean stbcEnabled = prefs.getBoolean("custom_stbc_enabled", true);
755+
MenuItem stbcEnable = adaptiveMenu.add("STBC");
756+
stbcEnable.setCheckable(true);
757+
stbcEnable.setChecked(stbcEnabled);
758+
stbcEnable.setOnMenuItemClickListener(item -> {
759+
boolean newState = !item.isChecked();
760+
item.setChecked(newState);
761+
SharedPreferences.Editor editor = getSharedPreferences("general", MODE_PRIVATE).edit();
762+
editor.putBoolean("custom_stbc_enabled", newState);
763+
editor.apply();
764+
wfbLink.nativeSetUseStbc(newState ? 1 : 0);
765+
return true;
766+
});
738767

739768
// --- FEC Thresholds menu (single dialog for all 5 settings) ---
740769
adaptiveMenu.add("FEC thresholds...").setOnMenuItemClickListener(item -> {
@@ -794,6 +823,14 @@ void initDefaultOptions(){
794823
wfbLink.nativeSetTxPower(adaptiveTxPower);
795824
boolean fecEnabled = prefs.getBoolean("custom_fec_enabled", true);
796825
wfbLink.nativeSetUseFec(fecEnabled ? 1 : 0);
826+
827+
// LDPC and STBC default options
828+
boolean ldpcEnabled = prefs.getBoolean("custom_ldpc_enabled", true);
829+
wfbLink.nativeSetUseLdpc(ldpcEnabled ? 1 : 0);
830+
831+
boolean stbcEnabled = prefs.getBoolean("custom_stbc_enabled", true);
832+
wfbLink.nativeSetUseStbc(stbcEnabled ? 1 : 0);
833+
797834
setFecThresholdsFromPrefs();
798835
}
799836

app/wfbngrtl8812/src/main/cpp/WfbngLink.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ int WfbngLink::run(JNIEnv *env, jobject context, jint wifiChannel, jint bw, jint
204204
args->udp_port = 8001;
205205
args->link_id = link_id;
206206
args->keypair = keyPath;
207-
args->stbc = true;
208-
args->ldpc = true;
207+
args->stbc = stbc_enabled;
208+
args->ldpc = ldpc_enabled;
209209
args->mcs_index = 0;
210210
args->vht_mode = false;
211211
args->short_gi = false;
@@ -570,8 +570,24 @@ extern "C" JNIEXPORT void JNICALL Java_com_openipc_wfbngrtl8812_WfbNgLink_native
570570
link->fec.setEnabled(use);
571571
}
572572

573-
extern "C" JNIEXPORT void JNICALL
574-
Java_com_openipc_wfbngrtl8812_WfbNgLink_nativeSetFecThresholds(JNIEnv *env, jclass clazz, jlong nativeInstance, jint lostTo5, jint recTo4, jint recTo3, jint recTo2, jint recTo1) {
573+
extern "C" JNIEXPORT void JNICALL Java_com_openipc_wfbngrtl8812_WfbNgLink_nativeSetUseLdpc(JNIEnv *env,
574+
jclass clazz,
575+
jlong wfbngLinkN,
576+
jint use) {
577+
WfbngLink *link = native(wfbngLinkN);
578+
link->ldpc_enabled = (use != 0);
579+
}
580+
581+
extern "C" JNIEXPORT void JNICALL Java_com_openipc_wfbngrtl8812_WfbNgLink_nativeSetUseStbc(JNIEnv *env,
582+
jclass clazz,
583+
jlong wfbngLinkN,
584+
jint use) {
585+
WfbngLink *link = native(wfbngLinkN);
586+
link->stbc_enabled = (use != 0);
587+
}
588+
589+
extern "C" JNIEXPORT void JNICALL Java_com_openipc_wfbngrtl8812_WfbNgLink_nativeSetFecThresholds(
590+
JNIEnv *env, jclass clazz, jlong nativeInstance, jint lostTo5, jint recTo4, jint recTo3, jint recTo2, jint recTo1) {
575591
WfbngLink *link = reinterpret_cast<WfbngLink *>(nativeInstance);
576592
if (!link) return;
577593
link->fec_lost_to_5 = lostTo5;

app/wfbngrtl8812/src/main/cpp/WfbngLink.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ class WfbngLink {
4949
bool adaptive_link_enabled;
5050
bool adaptive_link_should_stop{false};
5151
int adaptive_tx_power;
52-
std::map<int, std::unique_ptr<Rtl8812aDevice>> rtl_devices;
52+
53+
// Runtime configurable PHY parameters
54+
bool ldpc_enabled{true};
55+
bool stbc_enabled{true};
56+
57+
std::map<int, std::shared_ptr<Rtl8812aDevice>> rtl_devices;
5358
std::unique_ptr<std::thread> link_quality_thread{nullptr};
5459
bool should_clear_stats{false};
5560
FecChangeController fec;

app/wfbngrtl8812/src/main/java/com/openipc/wfbngrtl8812/WfbNgLink.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public void setFecThresholds(int lostTo5, int recTo4, int recTo3, int recTo2, in
4747
public static native void nativeSetAdaptiveLinkEnabled(long nativeInstance, boolean enabled);
4848
public static native void nativeSetTxPower(long nativeInstance, int power);
4949
public static native void nativeSetUseFec(long nativeInstance, int use);
50+
public static native void nativeSetUseLdpc(long nativeInstance, int use);
51+
public static native void nativeSetUseStbc(long nativeInstance, int use);
5052

5153
public WfbNgLink(final AppCompatActivity parent) {
5254
this.context = parent;
@@ -82,6 +84,14 @@ public void nativeSetUseFec(int use) {
8284
nativeSetUseFec(nativeWfbngLink, use);
8385
}
8486

87+
public void nativeSetUseLdpc(int use) {
88+
nativeSetUseLdpc(nativeWfbngLink, use);
89+
}
90+
91+
public void nativeSetUseStbc(int use) {
92+
nativeSetUseStbc(nativeWfbngLink, use);
93+
}
94+
8595
public synchronized void start(int wifiChannel, int bandWidth, UsbDevice usbDevice) {
8696
Log.d(TAG, "wfb-ng monitoring on " + usbDevice.getDeviceName() + " using wifi channel " + wifiChannel);
8797
UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);

0 commit comments

Comments
 (0)