diff --git a/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_udp.makefile b/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_udp.makefile index bd64e2c4184..7841fe35c0c 100644 --- a/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_udp.makefile +++ b/conf/firmwares/subsystems/rotorcraft/telemetry_transparent_udp.makefile @@ -8,11 +8,14 @@ MODEM_PORT_OUT ?= 4242 MODEM_PORT_IN ?= 4243 MODEM_BROADCAST ?= TRUE +UDP_MODEM_PORT_LOWER=$(shell echo $(MODEM_DEV) | tr A-Z a-z) + + MODEM_CFLAGS = -DUSE_$(MODEM_DEV) -D$(MODEM_DEV)_PORT_OUT=$(MODEM_PORT_OUT) -D$(MODEM_DEV)_PORT_IN=$(MODEM_PORT_IN) MODEM_CFLAGS += -D$(MODEM_DEV)_BROADCAST=$(MODEM_BROADCAST) -D$(MODEM_DEV)_HOST=$(MODEM_HOST) -TELEM_CFLAGS = -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=$(MODEM_DEV) -DPPRZ_UART=$(MODEM_DEV) -TELEM_CFLAGS += -DDOWNLINK_TRANSPORT=PprzTransport -DDATALINK=PPRZ -DDefaultPeriodic='&telemetry_Main' +TELEM_CFLAGS = -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=$(UDP_MODEM_PORT_LOWER) -DPPRZ_UART=$(MODEM_DEV) +TELEM_CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ -DDefaultPeriodic='&telemetry_Main' ap.CFLAGS += $(MODEM_CFLAGS) $(TELEM_CFLAGS) diff --git a/sw/airborne/mcu_periph/udp.c b/sw/airborne/mcu_periph/udp.c index f747cb30547..69b45dfcefd 100644 --- a/sw/airborne/mcu_periph/udp.c +++ b/sw/airborne/mcu_periph/udp.c @@ -32,6 +32,10 @@ void udp_periph_init(struct udp_periph* p, char* host, int port_out, int port_in p->rx_insert_idx = 0; p->rx_extract_idx = 0; p->tx_insert_idx = 0; + p->device.periph = (void *)p; + p->device.check_free_space = (check_free_space_t) udp_check_free_space; + p->device.transmit = (transmit_t) udp_transmit; + p->device.send_message = (send_message_t) udp_send_message; // Arch dependent initialization udp_arch_periph_init(p, host, port_out, port_in, broadcast); diff --git a/sw/airborne/mcu_periph/udp.h b/sw/airborne/mcu_periph/udp.h index 8c874302cbc..b58558a7443 100644 --- a/sw/airborne/mcu_periph/udp.h +++ b/sw/airborne/mcu_periph/udp.h @@ -30,6 +30,7 @@ #include "std.h" #include "mcu_periph/udp_arch.h" +#include "mcu_periph/device.h" #define UDP_RX_BUFFER_SIZE 256 #define UDP_TX_BUFFER_SIZE 256 @@ -44,6 +45,8 @@ struct udp_periph { uint16_t tx_insert_idx; /** UDP network */ void* network; + /** Generic device interface */ + struct device device; }; extern void udp_periph_init(struct udp_periph* p, char* host, int port_out, int port_in, bool_t broadcast);