QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MockLinkFTP Class Reference

Mock implementation of Mavlink FTP server. More...

#include <MockLinkFTP.h>

+ Inheritance diagram for MockLinkFTP:
+ Collaboration diagram for MockLinkFTP:

Public Types

enum  ErrorMode_t {
  errModeNone , errModeNoResponse , errModeNakResponse , errModeNoSecondResponse ,
  errModeNoSecondResponseAllowRetry , errModeNakSecondResponse , errModeBadSequence
}
 By calling setErrorMode with one of these modes you can cause the server to simulate an error. More...
 

Signals

void terminateCommandReceived ()
 You can connect to this signal to be notified when the server receives a Terminate command.
 
void resetCommandReceived ()
 You can connect to this signal to be notified when the server receives a Reset command.
 

Public Member Functions

 MockLinkFTP (uint8_t systemIdServer, uint8_t componentIdServer, MockLink *mockLink)
 
 ~MockLinkFTP ()
 
void setFileList (const QStringList &fileList)
 
void mavlinkMessageReceived (const mavlink_message_t &message)
 Called to handle an FTP message.
 
void enableRandomDrops (bool enable)
 
void enableBinParamFile (bool enable)
 
QStringList uploadedFiles () const
 Returns the list of remote paths which have been uploaded in this session.
 
QByteArray uploadedFileContents (const QString &remotePath) const
 Returns the contents of an uploaded file. Empty if the path is unknown.
 
void clearUploadedFiles ()
 Clears the stored uploaded file contents.
 
void setErrorMode (ErrorMode_t errMode)
 Sets the error mode for command responses. This allows you to simulate various server errors.
 

Static Public Attributes

static constexpr const ErrorMode_t rgFailureModes []
 
static constexpr const size_t cFailureModes = std::size(MockLinkFTP::rgFailureModes)
 The number of ErrorModes in the rgFailureModes array.
 
static constexpr const char * sizeFilenamePrefix = "mocklink-size-"
 

Detailed Description

Mock implementation of Mavlink FTP server.

Definition at line 17 of file MockLinkFTP.h.

Member Enumeration Documentation

◆ ErrorMode_t

By calling setErrorMode with one of these modes you can cause the server to simulate an error.

Enumerator
errModeNone 

No error, respond correctly.

errModeNoResponse 

No response to any request, client should eventually time out with no Ack.

errModeNakResponse 

Nak all requests.

errModeNoSecondResponse 

No response to subsequent request to initial command.

errModeNoSecondResponseAllowRetry 

No response to subsequent request to initial command, error will be cleared after this so retry will succeed.

errModeNakSecondResponse 

Nak subsequent request to initial command.

errModeBadSequence 

Return response with bad sequence number.

Definition at line 45 of file MockLinkFTP.h.

Constructor & Destructor Documentation

◆ MockLinkFTP()

MockLinkFTP::MockLinkFTP ( uint8_t  systemIdServer,
uint8_t  componentIdServer,
MockLink mockLink 
)

Definition at line 10 of file MockLinkFTP.cc.

◆ ~MockLinkFTP()

MockLinkFTP::~MockLinkFTP ( )

Definition at line 19 of file MockLinkFTP.cc.

Member Function Documentation

◆ clearUploadedFiles()

void MockLinkFTP::clearUploadedFiles ( )
inline

Clears the stored uploaded file contents.

Definition at line 42 of file MockLinkFTP.h.

◆ enableBinParamFile()

void MockLinkFTP::enableBinParamFile ( bool  enable)
inline

Definition at line 33 of file MockLinkFTP.h.

◆ enableRandomDrops()

void MockLinkFTP::enableRandomDrops ( bool  enable)
inline

Definition at line 32 of file MockLinkFTP.h.

◆ mavlinkMessageReceived()

◆ resetCommandReceived

void MockLinkFTP::resetCommandReceived ( )
signal

You can connect to this signal to be notified when the server receives a Reset command.

◆ setErrorMode()

void MockLinkFTP::setErrorMode ( ErrorMode_t  errMode)
inline

Sets the error mode for command responses. This allows you to simulate various server errors.

Definition at line 56 of file MockLinkFTP.h.

◆ setFileList()

void MockLinkFTP::setFileList ( const QStringList &  fileList)
inline

Sets the list of files returned by the List command. Prepend names with F or D to indicate (F)ile or (D)irectory.

Definition at line 27 of file MockLinkFTP.h.

◆ terminateCommandReceived

void MockLinkFTP::terminateCommandReceived ( )
signal

You can connect to this signal to be notified when the server receives a Terminate command.

◆ uploadedFileContents()

QByteArray MockLinkFTP::uploadedFileContents ( const QString &  remotePath) const
inline

Returns the contents of an uploaded file. Empty if the path is unknown.

Definition at line 39 of file MockLinkFTP.h.

◆ uploadedFiles()

QStringList MockLinkFTP::uploadedFiles ( ) const
inline

Returns the list of remote paths which have been uploaded in this session.

Definition at line 36 of file MockLinkFTP.h.

Member Data Documentation

◆ cFailureModes

constexpr const size_t MockLinkFTP::cFailureModes = std::size(MockLinkFTP::rgFailureModes)
staticconstexpr

The number of ErrorModes in the rgFailureModes array.

Definition at line 70 of file MockLinkFTP.h.

◆ rgFailureModes

constexpr const ErrorMode_t MockLinkFTP::rgFailureModes[]
staticconstexpr
Initial value:
= {
}
@ errModeBadSequence
Return response with bad sequence number.
Definition MockLinkFTP.h:52
@ errModeNakSecondResponse
Nak subsequent request to initial command.
Definition MockLinkFTP.h:51
@ errModeNoResponse
No response to any request, client should eventually time out with no Ack.
Definition MockLinkFTP.h:47
@ errModeNoSecondResponse
No response to subsequent request to initial command.
Definition MockLinkFTP.h:49
@ errModeNakResponse
Nak all requests.
Definition MockLinkFTP.h:48

Array of failure modes you can cycle through for testing. By looping through this array you can avoid hardcoding the specific error modes in your unit test. This way when new error modes are added your unit test code may not need to be modified.

Definition at line 61 of file MockLinkFTP.h.

◆ sizeFilenamePrefix

constexpr const char* MockLinkFTP::sizeFilenamePrefix = "mocklink-size-"
staticconstexpr

Definition at line 72 of file MockLinkFTP.h.


The documentation for this class was generated from the following files: