GCS_MAVLink: give banner on param download with ftp

thanks to Peter for noticing
This commit is contained in:
Andrew Tridgell 2020-05-03 10:55:56 +10:00
parent 259cb0aafd
commit 87c2858bde
2 changed files with 16 additions and 1 deletions

View File

@ -740,6 +740,7 @@ private:
FTP_FILE_MODE mode; // work around AP_Filesystem not supporting file modes FTP_FILE_MODE mode; // work around AP_Filesystem not supporting file modes
int16_t current_session; int16_t current_session;
uint32_t last_send_ms; uint32_t last_send_ms;
uint8_t need_banner_send_mask;
}; };
static struct ftp_state ftp; static struct ftp_state ftp;

View File

@ -85,7 +85,16 @@ void GCS_MAVLINK::handle_file_transfer_protocol(const mavlink_message_t &msg) {
} }
} }
void GCS_MAVLINK::send_ftp_replies(void) { void GCS_MAVLINK::send_ftp_replies(void)
{
/*
provide same banner we would give with old param download
*/
if (ftp.need_banner_send_mask & (1U<<chan)) {
ftp.need_banner_send_mask &= ~(1U<<chan);
send_banner();
}
if (ftp.replies == nullptr || ftp.replies->empty()) { if (ftp.replies == nullptr || ftp.replies->empty()) {
return; return;
} }
@ -273,6 +282,11 @@ void GCS_MAVLINK::ftp_worker(void) {
reply.opcode = FTP_OP::Ack; reply.opcode = FTP_OP::Ack;
reply.size = sizeof(uint32_t); reply.size = sizeof(uint32_t);
*((int32_t *)reply.data) = (int32_t)file_size; *((int32_t *)reply.data) = (int32_t)file_size;
// provide compatibility with old protocol banner download
if (strncmp((const char *)request.data, "@PARAM/param.pck", 16) == 0) {
ftp.need_banner_send_mask |= 1U<<reply.chan;
}
break; break;
} }
case FTP_OP::ReadFile: case FTP_OP::ReadFile: