AP_RCProtocol: expose protocol name mapping

This commit is contained in:
Andrew Tridgell 2018-11-05 16:44:00 +11:00
parent ae18fd1cef
commit a8e6a09903
2 changed files with 19 additions and 2 deletions

View File

@ -198,9 +198,9 @@ void AP_RCProtocol::start_bind(void)
/*
return protocol name
*/
const char *AP_RCProtocol::protocol_name(void) const
const char *AP_RCProtocol::protocol_name_from_protocol(rcprotocol_t protocol)
{
switch (_detected_protocol) {
switch (protocol) {
case PPM:
return "PPM";
case SBUS:
@ -219,3 +219,11 @@ const char *AP_RCProtocol::protocol_name(void) const
}
return nullptr;
}
/*
return protocol name
*/
const char *AP_RCProtocol::protocol_name(void) const
{
return protocol_name_from_protocol(_detected_protocol);
}

View File

@ -29,6 +29,7 @@ public:
instance = this;
}
~AP_RCProtocol();
enum rcprotocol_t {
PPM = 0,
SBUS,
@ -66,9 +67,17 @@ public:
bool new_input();
void start_bind(void);
// return protocol name as a string
static const char *protocol_name_from_protocol(rcprotocol_t protocol);
// return protocol name as a string
const char *protocol_name(void) const;
// return protocol name as a string
enum rcprotocol_t protocol_detected(void) const {
return _detected_protocol;
}
// access to singleton
static AP_RCProtocol *get_instance(void) {
return instance;