Skip to content

Commit 03fbe8f

Browse files
author
Jesus Lopez Garcia
committed
Channel-on-goggles-via-data-packet
1 parent 5ad376f commit 03fbe8f

File tree

9 files changed

+13
-24
lines changed

9 files changed

+13
-24
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
type = scripted
22
command = modmanager enable diy_glasses displayport_osd_shim
3-
stop-command = modmanager disable diy_glasses displayport_osd_shim
3+
stop-command = modmanager disable diy_glasses displayport_osd_shim
4+
logfile = /blackbox/msp-osd.log

jni/Android.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ LOCAL_SRC_FILES := \
2323
json/parson.c \
2424
lz4/lz4.c \
2525
msp/msp_displayport.c \
26-
msp/msp_vtx.c \
2726
msp/msp.c \
2827
net/network.c \
2928
osd_dji_overlay_udp.c \
@@ -44,7 +43,6 @@ LOCAL_SRC_FILES:= \
4443
msp_displayport_mux.c \
4544
msp/msp.c \
4645
msp/msp_displayport.c \
47-
msp/msp_vtx.c \
4846
net/network.c \
4947
net/serial.c \
5048
util/fs_util.c \

jni/msp/msp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
// https://github.com/betaflight/betaflight/blob/master/src/main/msp/msp_protocol.h#L201C1-L202C50
2121
#define MSP_CMD_VTX_CONFIG 88 // out from FC
22-
#define MSP_CMD_SET_VTX_CONFIG 89 // in message to FC (To setup config or to ask for it?)
2322

2423
typedef enum {
2524
MSP_ERR_NONE,
@@ -62,4 +61,4 @@ typedef struct msp_state_s {
6261

6362
uint16_t msp_data_from_msg(uint8_t message_buffer[], msp_msg_t *msg);
6463
msp_error_e construct_msp_command(uint8_t message_buffer[], uint8_t command, uint8_t payload[], uint8_t size, msp_direction_e direction);
65-
msp_error_e msp_process_data(msp_state_t *msp_state, uint8_t dat);
64+
msp_error_e msp_process_data(msp_state_t *msp_state, uint8_t dat);

jni/msp/msp_displayport.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "msp.h"
22
#include "msp_displayport.h"
3-
#include "msp_vtx.h"
43

54
static void process_draw_string(displayport_vtable_t *display_driver, uint8_t *payload) {
65
if(!display_driver || !display_driver->draw_character) return;
@@ -53,11 +52,6 @@ int displayport_process_message(displayport_vtable_t *display_driver, msp_msg_t
5352
if (msg->direction != MSP_INBOUND) {
5453
return 1;
5554
}
56-
if(msg->cmd == MSP_CMD_VTX_CONFIG) {
57-
//INFO: HERE IF VTX_CONFIG
58-
process_vtx_message(msg);
59-
return 1;
60-
}
6155
if (msg->cmd != MSP_CMD_DISPLAYPORT) {
6256
return 1;
6357
}

jni/msp/msp_vtx.c

Lines changed: 0 additions & 5 deletions
This file was deleted.

jni/msp/msp_vtx.h

Lines changed: 0 additions & 4 deletions
This file was deleted.

jni/msp_displayport_mux.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ static uint8_t serial_passthrough = 1;
7474
static uint8_t compress = 0;
7575
static uint8_t no_btfl_hd = 0;
7676

77+
uint16_t fc_vtx_channel = -1;
78+
7779
static void sig_handler(int _)
7880
{
7981
quit = 1;
@@ -219,8 +221,8 @@ static void rx_msp_callback(msp_msg_t *msp_message)
219221
case MSP_CMD_VTX_CONFIG: {
220222
printf("Received VTX CONFIG message...\n");
221223
printf("data: %d %d %d \n", msp_message->payload[0], msp_message->payload[1], msp_message->payload[2]);
222-
//INFO: Write the message to the socket
223-
// write(socket_fd, &msp_message, sizeof(msp_message));
224+
//TODO: Damage control accessing to index 2 if not exists
225+
fc_vtx_channel = msp_message->payload[2];
224226
}
225227
default: {
226228
uint16_t size = msp_data_from_msg(message_buffer, msp_message);
@@ -266,8 +268,9 @@ static void send_data_packet(int data_socket_fd, dji_shm_state_t *dji_shm) {
266268
data.version_specifier = 0xFFFF;
267269
data.tx_temperature = get_int_from_fs(CPU_TEMP_PATH);
268270
data.tx_voltage = get_int_from_fs(AU_VOLTAGE_PATH);
271+
data.fc_vtx_channel = fc_vtx_channel;
269272
memcpy(data.fc_variant, current_fc_identifier, sizeof(current_fc_identifier));
270-
DEBUG_PRINT("got voltage %f V temp %d C variant %.4s\n", (float)(data.tx_voltage / 64.0f), data.tx_temperature, data.fc_variant);
273+
DEBUG_PRINT("got voltage %f V temp %d C variant %.4s and channel %d\n", (float)(data.tx_voltage / 64.0f), data.tx_temperature, data.fc_variant, data.fc_vtx_channel);
271274
//INFO: Write the message to the socket
272275
write(data_socket_fd, &data, sizeof(data));
273276
}

jni/net/data_protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ typedef struct packet_data_s {
44
uint16_t tx_temperature;
55
uint16_t version_specifier; // Used to be bitrate! Danger! 0xFFFF means V2 (no bitrate) for now.
66
uint16_t tx_voltage;
7+
uint16_t fc_vtx_channel;
78
char fc_variant[4];
89
} __attribute__((packed)) packet_data_t;
910

jni/osd_dji_overlay_udp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ static void check_is_au_overlay_enabled()
485485

486486
static void process_data_packet(uint8_t *buf, int len, dji_shm_state_t *radio_shm) {
487487
packet_data_t *packet = (packet_data_t *)buf;
488-
DEBUG_PRINT("got data %04X version spec %d C %f V variant %.4s\n", packet->version_specifier, packet->tx_temperature, packet->tx_voltage / 64.0f, packet->fc_variant);
488+
DEBUG_PRINT("got data %04X version spec %d C %f V variant %.4s and vtx channel %d\n", packet->version_specifier, packet->tx_temperature, packet->tx_voltage / 64.0f, packet->fc_variant, packet->fc_vtx_channel);
489489
char str[8];
490490
clear_overlay();
491491
if(au_overlay_enabled) {
@@ -494,6 +494,8 @@ static void process_data_packet(uint8_t *buf, int len, dji_shm_state_t *radio_sh
494494
snprintf(str, 8, "A %2.1fV", packet->tx_voltage / 64.0f);
495495
display_print_string(overlay_display_info.char_width - 7, overlay_display_info.char_height - 7, str, 7);
496496
}
497+
// TODO: Call channel change HERE!!!!!
498+
// changeChannel(packet->fc_vtx_channel);
497499
if(len > 6) {
498500
DEBUG_PRINT("Got new packet with variant %.4s\n", packet->fc_variant);
499501
// should have FC type

0 commit comments

Comments
 (0)