Skip to content

Commit fee52be

Browse files
author
Jesus Lopez Garcia
committed
Added control over the channel
1 parent 03fbe8f commit fee52be

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

jni/osd_dji_overlay_udp.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "rec/rec.h"
3535
#include "rec/rec_pb.h"
3636

37+
#include "util/vtx_managment.c"
38+
3739
#define MSP_PORT 7654
3840
#define DATA_PORT 7655
3941
#define COMPRESSED_DATA_PORT 7656
@@ -495,7 +497,7 @@ static void process_data_packet(uint8_t *buf, int len, dji_shm_state_t *radio_sh
495497
display_print_string(overlay_display_info.char_width - 7, overlay_display_info.char_height - 7, str, 7);
496498
}
497499
// TODO: Call channel change HERE!!!!!
498-
// changeChannel(packet->fc_vtx_channel);
500+
changeChannel(packet->fc_vtx_channel);
499501
if(len > 6) {
500502
DEBUG_PRINT("Got new packet with variant %.4s\n", packet->fc_variant);
501503
// should have FC type

jni/util/vtx_managment.c

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <stdlib.h>
2+
// #include <stdbool.h>
3+
// #include <unistd.h>
4+
#include <dlfcn.h>
5+
// #include <string.h>
6+
7+
8+
9+
static void *tp1801_gui_lib = NULL;
10+
static uint32_t (* setChannelPilotOriginal)(void *this,unsigned short param_1, bool param_2) = 0;
11+
static uint32_t (* userSettingsGetInstanceOriginal)() = 0;
12+
static uint32_t userSettingsInstance = 0;
13+
14+
void changeChannel(uint16_t channelIdx) {
15+
//Load SetPilotChannel original
16+
setChannelPilotOriginal = dlsym (RTLD_NEXT, "_ZN17GlassUserSettings15setPilotChannelEtb");
17+
if (setChannelPilotOriginal == NULL) {
18+
if(!tp1801_gui_lib){
19+
tp1801_gui_lib = dlopen("/system/lib/libtp1801_gui.so", 1);
20+
}
21+
setChannelPilotOriginal = dlsym (tp1801_gui_lib, "_ZN17GlassUserSettings15setPilotChannelEtb");
22+
if (setChannelPilotOriginal == NULL)
23+
{
24+
printf("dlsym: %s\n", dlerror());
25+
return;
26+
}
27+
}
28+
29+
//Load UserSettingGetInstance original
30+
userSettingsGetInstanceOriginal = dlsym (tp1801_gui_lib, "_ZN17GlassUserSettings11getInstanceEv");
31+
if (userSettingsGetInstanceOriginal == NULL)
32+
{
33+
printf("dlsym: %s\n", dlerror());
34+
return;
35+
}
36+
37+
//Get the intance from the previous method
38+
if(!userSettingsInstance) userSettingsInstance = userSettingsGetInstanceOriginal();
39+
if(!userSettingsInstance) {
40+
printf("dlsym: %s\n", dlerror());
41+
return;
42+
}
43+
44+
//Do stuff
45+
//setChannelPilotOriginal(userSettingsInstance, channelIdx, 1); //Can I pass the instance directly or need to be a function pointer?
46+
setChannelPilotOriginal(userSettingsGetInstanceOriginal(), channelIdx, true);
47+
}

0 commit comments

Comments
 (0)