Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : 7 : This program is distributed in the hope that it will be useful, 8 : but WITHOUT ANY WARRANTY; without even the implied warranty of 9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 : GNU General Public License for more details. 11 : 12 : You should have received a copy of the GNU General Public License 13 : along with this program. If not, see <http://www.gnu.org/licenses/>. 14 : 15 : DJI FPV MSP telemetry library backend 16 : 17 : The DJI Air Unit polls the FC for the following MSP messages at around 4Hz. 18 : Note: messages are polled in ascending hex id order. 19 : 20 : Hex|Dec|Name 21 : --------------------------- 22 : 03 03 MSP_FC_VERSION 23 : 0a 10 MSP_NAME 24 : 54 84 MSP_OSD_CONFIG 25 : 5c 92 MSP_FILTER_CONFIG 26 : 5e 94 MSP_PID_ADVANCED 27 : 65 101 MSP_STATUS 28 : 69 105 MSP_RC 29 : 6a 106 MSP_RAW_GPS 30 : 6b 107 MSP_COMP_GPS 31 : 6c 108 MSP_ATTITUDE 32 : 6d 109 MSP_ALTITUDE 33 : 6e 110 MSP_ANALOG 34 : 6f 111 MSP_RC_TUNING 35 : 70 112 MSP_PID 36 : 82 130 MSP_BATTERY_STATE 37 : 86 134 MSP_ESC_SENSOR_DATA 38 : 96 150 MSP_STATUS_EX 39 : f7 247 MSP_RTC 40 : */ 41 : 42 : #pragma once 43 : 44 : #include "AP_MSP_Telem_Backend.h" 45 : 46 : #if HAL_MSP_ENABLED 47 : 48 : class AP_MSP_Telem_DJI : public AP_MSP_Telem_Backend 49 : { 50 : using AP_MSP_Telem_Backend::AP_MSP_Telem_Backend; 51 : public: 52 : bool init_uart() override; 53 : // implementation specific helpers 54 : bool is_scheduler_enabled() const override; 55 0 : AP_SerialManager::SerialProtocol get_serial_protocol() const override { return AP_SerialManager::SerialProtocol::SerialProtocol_DJI_FPV; }; 56 : uint32_t get_osd_flight_mode_bitmask(void) override; 57 : void hide_osd_items(void) override; 58 : 59 : bool get_rssi(float &rssi) const override; 60 : void update_home_pos(home_state_t &home_state) override; 61 : void update_battery_state(battery_state_t &_battery_state) override; 62 : void update_gps_state(gps_state_t &gps_state) override; 63 : void update_airspeed(airspeed_state_t &airspeed_state) override; 64 : void update_flight_mode_str(char *flight_mode_str, uint8_t size, bool wind_enabled) override; 65 : 66 : MSP::MSPCommandResult msp_process_out_fc_variant(MSP::sbuf_t *dst) override; 67 : MSP::MSPCommandResult msp_process_out_esc_sensor_data(MSP::sbuf_t *dst) override; 68 : 69 : enum : uint8_t { 70 : DJI_FLAG_ARM = 0, 71 : DJI_FLAG_STAB, 72 : DJI_FLAG_HOR, 73 : DJI_FLAG_HEAD, 74 : DJI_FLAG_FS, 75 : DJI_FLAG_RESC, 76 : }; 77 : }; 78 : 79 : #endif //HAL_MSP_ENABLED