Skip to content

Commit

Permalink
Adding public channel selection - COMMIT FAILING
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesus Lopez Garcia committed Sep 24, 2023
1 parent f295a42 commit 5158e10
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions jni/util/vtx_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
#include <dlfcn.h>
#include "json/osd_config.h"
#include "util/debug.h"
//#include "../rec/rec_shim.h"

#define VTX_MPS_CONFIG_KEY "vtx_msp"
#define CHANNEL_PUBLIC 8

static void *tp1801_gui_lib = NULL;
static uint32_t (* setChannelPilotOriginal)(void *this,unsigned short param_1, bool param_2) = 0;
static uint32_t (* userSettingsGetInstanceOriginal)() = 0;
static uint32_t userSettingsInstance = 0;
static __gs_gui_config *gs_gui_config = 0;
static int8_t currentChannel = -1;

void changeChannel(int8_t channel) {
if(!get_boolean_config_value(VTX_MPS_CONFIG_KEY)) {
return;
}

void setupManager() {
//Load SetPilotChannel original
setChannelPilotOriginal = dlsym (RTLD_NEXT, "_ZN17GlassUserSettings15setPilotChannelEtb");
if (setChannelPilotOriginal == NULL) {
Expand All @@ -38,6 +37,21 @@ void changeChannel(int8_t channel) {
return;
}

userSettingsInstance = userSettingsGetInstanceOriginal();
if(userSettingsInstance == NULL) {
printf("dlsym: error loading user setting instance");
return;
}
gs_gui_config = (__gs_gui_config *)*(uint32_t *)((int)userSettingsInstance + 0xe4);
}

void changeChannel(int8_t channel) {
if(!get_boolean_config_value(VTX_MPS_CONFIG_KEY)) {
return;
}

setupManager();

if (channel <= 0 || channel > 8) {
printf("VTX_MANAGER Error:, invalid channel index: %d\n", channel);
return;
Expand All @@ -48,9 +62,12 @@ void changeChannel(int8_t channel) {
}
currentChannel = channel;

// if 8, need to set to public
DEBUG_PRINT("VTX_MANAGER: requesting to the goggles to set channel %d\n", channel);

int8_t channelIdx = channel - 1;
setChannelPilotOriginal(userSettingsGetInstanceOriginal(), channelIdx, true);

if(channel == CHANNEL_PUBLIC){
gs_gui_config->gs_modem_set_public_chnl(gs_gui_config->gs_info);
} else {
int8_t channelIdx = channel - 1;
setChannelPilotOriginal(userSettingsGetInstanceOriginal(), channelIdx, true);
}
}

0 comments on commit 5158e10

Please sign in to comment.