2
2
#include <dlfcn.h>
3
3
#include "json/osd_config.h"
4
4
#include "util/debug.h"
5
+ //#include "../rec/rec_shim.h"
5
6
6
7
#define VTX_MPS_CONFIG_KEY "vtx_msp"
8
+ #define CHANNEL_PUBLIC 8
7
9
8
10
static void * tp1801_gui_lib = NULL ;
9
11
static uint32_t (* setChannelPilotOriginal )(void * this ,unsigned short param_1 , bool param_2 ) = 0 ;
10
12
static uint32_t (* userSettingsGetInstanceOriginal )() = 0 ;
11
13
static uint32_t userSettingsInstance = 0 ;
14
+ static __gs_gui_config * gs_gui_config = 0 ;
12
15
static int8_t currentChannel = -1 ;
13
16
14
- void changeChannel (int8_t channel ) {
15
- if (!get_boolean_config_value (VTX_MPS_CONFIG_KEY )) {
16
- return ;
17
- }
18
-
17
+ void setupManager () {
19
18
//Load SetPilotChannel original
20
19
setChannelPilotOriginal = dlsym (RTLD_NEXT , "_ZN17GlassUserSettings15setPilotChannelEtb" );
21
20
if (setChannelPilotOriginal == NULL ) {
@@ -38,6 +37,21 @@ void changeChannel(int8_t channel) {
38
37
return ;
39
38
}
40
39
40
+ userSettingsInstance = userSettingsGetInstanceOriginal ();
41
+ if (userSettingsInstance == NULL ) {
42
+ printf ("dlsym: error loading user setting instance" );
43
+ return ;
44
+ }
45
+ gs_gui_config = (__gs_gui_config * )* (uint32_t * )((int )userSettingsInstance + 0xe4 );
46
+ }
47
+
48
+ void changeChannel (int8_t channel ) {
49
+ if (!get_boolean_config_value (VTX_MPS_CONFIG_KEY )) {
50
+ return ;
51
+ }
52
+
53
+ setupManager ();
54
+
41
55
if (channel <= 0 || channel > 8 ) {
42
56
printf ("VTX_MANAGER Error:, invalid channel index: %d\n" , channel );
43
57
return ;
@@ -48,9 +62,12 @@ void changeChannel(int8_t channel) {
48
62
}
49
63
currentChannel = channel ;
50
64
51
- // if 8, need to set to public
52
65
DEBUG_PRINT ("VTX_MANAGER: requesting to the goggles to set channel %d\n" , channel );
53
-
54
- int8_t channelIdx = channel - 1 ;
55
- setChannelPilotOriginal (userSettingsGetInstanceOriginal (), channelIdx , true);
66
+
67
+ if (channel == CHANNEL_PUBLIC ){
68
+ gs_gui_config -> gs_modem_set_public_chnl (gs_gui_config -> gs_info );
69
+ } else {
70
+ int8_t channelIdx = channel - 1 ;
71
+ setChannelPilotOriginal (userSettingsGetInstanceOriginal (), channelIdx , true);
72
+ }
56
73
}
0 commit comments