Generic messages
Command result
Command results are messages sent by an interface to the host to indicate the
result of a requested operation. The whad::generic::CommandResult
class provides an easy way to create such messages:
/* Create and send a command result message indicating an error. */
whad::generic::CommandResult result(whad::generic::ResultCode::ResultError);
whad::send(result);
Verbose messages
Verbose messages contain text that will be sent to the host and that will be
displayed when verbose mode is enabled by the user. These messages can be
created using the whad::generic::Verbose class:
/* Create and send a verbose message. */
whad::generic::Verbose verb_msg("This is some information for the user.");
whad::send(verb_msg);
Debug messages
Debug messages are not intended to be displayed to the user and will only be
showed when debug mode is enabled on host-side. These messages can be created
through the whad::generic::Debug function:
/* Create and send a debug message. */
whad::generic::Debug debug_msg(1, "This is some information for the user.");
whad::send(verb_msg);
Generic API reference
-
namespace generic
Enums
-
enum ResultCode
Command result code.
Values:
-
enumerator ResultSuccess
Request succeeded.
-
enumerator ResultError
An error occurred.
-
enumerator ResultParameterError
Invalid parameter.
-
enumerator ResultDisconnected
Device has disconnected.
-
enumerator ResultWrongMode
Invalid current mode.
-
enumerator ResultUnsupportedDomain
Unsupported domain.
-
enumerator ResultBusy
Interface is busy and cannot process request.
-
enumerator ResultSuccess
-
class CommandResult : public whad::generic::GenericMsg
- #include <cmdresult.hpp>
The CommandResult class represents a result returned by a firmware and contains a code indicating a specific status. This code is used to report success, errors but also some notifications.
Subclassed by whad::generic::Busy, whad::generic::Disconnected, whad::generic::Error, whad::generic::ParameterError, whad::generic::Success, whad::generic::UnsupportedDomain, whad::generic::WrongMode
Public Functions
-
CommandResult(ResultCode result)
Build a generic commmand result message.
- Parameters:
resultCode – [in] Command result code.
-
CommandResult(NanoPbMsg message)
Build a generic commmand result message.
- Parameters:
message – [in] Underlying NanoPb message.
-
ResultCode getResultCode()
Return the result code.
- Return values:
Result – code
-
CommandResult(ResultCode result)
-
class Success : public whad::generic::CommandResult
- #include <cmdresult.hpp>
Specialized classes
The following classes are helpers to create various result commands based on the CommandResult class. There is no specific data processing except setting the correct error code into the parent CommandResult object.
Success command result.
Public Functions
-
Success(void)
Create a success command result object.
-
Success(void)
-
class Error : public whad::generic::CommandResult
- #include <cmdresult.hpp>
Error command result.
Public Functions
-
Error(void)
Create an error command result object.
-
Error(void)
-
class ParameterError : public whad::generic::CommandResult
- #include <cmdresult.hpp>
Parameter error command result.
Public Functions
-
ParameterError(void)
Create an parameter error command result object.
-
ParameterError(void)
-
class Disconnected : public whad::generic::CommandResult
- #include <cmdresult.hpp>
Disconnected command result.
Public Functions
-
Disconnected(void)
Create an disconnected command result object.
-
Disconnected(void)
-
class WrongMode : public whad::generic::CommandResult
- #include <cmdresult.hpp>
Wrong mode command result.
Public Functions
-
WrongMode(void)
Create a wrong mode error command result object.
-
WrongMode(void)
-
class UnsupportedDomain : public whad::generic::CommandResult
- #include <cmdresult.hpp>
Unsupported domain command result.
Public Functions
-
UnsupportedDomain(void)
Create an unsupported domain error command result object.
-
UnsupportedDomain(void)
-
class Busy : public whad::generic::CommandResult
- #include <cmdresult.hpp>
Busy command result.
Public Functions
-
Busy(void)
Create a busy command result object.
-
Busy(void)
-
class Debug : public whad::generic::GenericMsg
- #include <debug.hpp>
-
class GenericMsg : public whad::NanoPbMsg
- #include <generic.hpp>
Default generic message class.
Subclassed by whad::generic::CommandResult, whad::generic::Debug, whad::generic::Progress, whad::generic::Verbose
Public Functions
-
GenericMsg()
Discovery message base class.
-
GenericMsg(NanoPbMsg pMessage)
Discovery message base class.
- Parameters:
pMessage – [in] NanoPbMsg object containing a discovery domain message
-
~GenericMsg()
Discovery message base class destructor.
-
MessageType getType(void)
Identify the underlying discovery message.
This method can be used when parsing incoming Discovery domain message to identify the type of message it contains and process it later.
- Returns:
Discovery message type.
-
GenericMsg()
-
class Progress : public whad::generic::GenericMsg
- #include <progress.hpp>
-
class Verbose : public whad::generic::GenericMsg
- #include <verbose.hpp>
Public Functions
-
Verbose(std::string message)
Build a generic verbose message.
- Parameters:
message – Message string to pass to the host.
-
Verbose(std::string message)
-
enum ResultCode