From e1385573b1cff2d73977c579346e455eca21a1ba Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 3 Nov 2018 09:49:56 +1100 Subject: [PATCH] AP_RCProtocol: return protocol name string --- libraries/AP_RCProtocol/AP_RCProtocol.cpp | 25 +++++++++++++++++++++++ libraries/AP_RCProtocol/AP_RCProtocol.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/libraries/AP_RCProtocol/AP_RCProtocol.cpp b/libraries/AP_RCProtocol/AP_RCProtocol.cpp index 76d67acb51..d8a5ecf340 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol.cpp +++ b/libraries/AP_RCProtocol/AP_RCProtocol.cpp @@ -153,3 +153,28 @@ void AP_RCProtocol::start_bind(void) } } } + +/* + return protocol name + */ +const char *AP_RCProtocol::protocol_name(void) const +{ + switch (_detected_protocol) { + case PPM: + return "PPM"; + case SBUS: + case SBUS_NI: + return "SBUS"; + case DSM: + return "DSM"; + case SUMD: + return "SUMD"; + case SRXL: + return "SRXL"; + case ST24: + return "ST24"; + case NONE: + break; + } + return nullptr; +} diff --git a/libraries/AP_RCProtocol/AP_RCProtocol.h b/libraries/AP_RCProtocol/AP_RCProtocol.h index 30ad53424e..8b8ad989ff 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol.h +++ b/libraries/AP_RCProtocol/AP_RCProtocol.h @@ -64,6 +64,9 @@ public: bool new_input(); void start_bind(void); + // return protocol name as a string + const char *protocol_name(void) const; + // access to singleton static AP_RCProtocol *get_instance(void) { return instance;