29 #define MODULES_DATALINK_C
34 #include "generated/modules.h"
35 #include "generated/settings.h"
37 #include "pprzlink/messages.h"
39 #if defined RADIO_CONTROL && defined RADIO_CONTROL_TYPE_DATALINK
47 #ifdef RADIO_CONTROL_DATALINK_LED
52 bool datalink_enabled =
true;
58 uint8_t sender_id = SenderIdOfPprzMsg(buf);
59 uint8_t msg_id = IdOfPprzMsg(buf);
69 #if PPRZLINK_DEFAULT_VER == 2
71 if (pprzlink_get_msg_class_id(buf) == DL_datalink_CLASS_ID) {
76 #if PPRZLINK_DEFAULT_VER == 2
78 struct pprzlink_msg
msg;
81 msg.sender_id = AC_ID;
82 msg.receiver_id = sender_id;
84 pprzlink_msg_send_PONG(&
msg);
86 pprz_msg_send_PONG(trans,
dev, AC_ID);
92 if (DL_SETTING_ac_id(buf) != AC_ID) {
break; }
93 uint8_t i = DL_SETTING_index(buf);
94 float var = DL_SETTING_value(buf);
96 #if PPRZLINK_DEFAULT_VER == 2
98 struct pprzlink_msg
msg;
101 msg.sender_id = AC_ID;
102 msg.receiver_id = sender_id;
103 msg.component_id = 0;
104 pprzlink_msg_send_DL_VALUE(&
msg, &i, &var);
106 pprz_msg_send_DL_VALUE(trans,
dev, AC_ID, &i, &var);
111 case DL_GET_SETTING : {
112 if (DL_GET_SETTING_ac_id(buf) != AC_ID) {
break; }
113 uint8_t i = DL_GET_SETTING_index(buf);
114 float val = settings_get_value(i);
115 #if PPRZLINK_DEFAULT_VER == 2
117 struct pprzlink_msg
msg;
120 msg.sender_id = AC_ID;
121 msg.receiver_id = sender_id;
122 msg.component_id = 0;
123 pprzlink_msg_send_DL_VALUE(&
msg, &i, &
val);
125 pprz_msg_send_DL_VALUE(trans,
dev, AC_ID, &i, &
val);
130 #ifdef RADIO_CONTROL_TYPE_DATALINK
132 #ifdef RADIO_CONTROL_DATALINK_LED
136 DL_RC_3CH_throttle_mode(buf),
138 DL_RC_3CH_pitch(buf));
141 if (DL_RC_4CH_ac_id(buf) == AC_ID) {
142 #ifdef RADIO_CONTROL_DATALINK_LED
146 DL_RC_4CH_throttle(buf),
148 DL_RC_4CH_pitch(buf),
152 #endif // RADIO_CONTROL_TYPE_DATALINK
155 case DL_GPS_INJECT : {
157 if (DL_GPS_INJECT_ac_id(buf) != AC_ID) {
break; }
161 DL_GPS_INJECT_packet_id(buf),
162 DL_GPS_INJECT_data_length(buf),
163 DL_GPS_INJECT_data(buf)
168 case DL_RTCM_INJECT : {
171 DL_RTCM_INJECT_data_length(buf),
172 DL_RTCM_INJECT_data(buf));
175 #endif // USE_GPS_UBX_RTCM
181 #if PPRZLINK_DEFAULT_VER == 2
189 modules_parse_datalink(msg_id,
dev, trans, buf);
193 WEAK
void firmware_parse_msg(
struct link_device *
dev __attribute__((unused)),
struct transport_tx *trans __attribute__((unused)),
uint8_t *buf __attribute__((unused)))