From 587fe52cb6a33d4a252c16cc4e3bf82fc390cf62 Mon Sep 17 00:00:00 2001 From: Tom Pittenger Date: Sun, 12 Nov 2023 17:41:10 -0800 Subject: [PATCH] AP_Networking: add get_str() accessor to IP address parms --- libraries/AP_Networking/AP_Networking_address.cpp | 5 +++++ libraries/AP_Networking/AP_Networking_address.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/libraries/AP_Networking/AP_Networking_address.cpp b/libraries/AP_Networking/AP_Networking_address.cpp index 622e6f919a667..5cadbbe6f7a14 100644 --- a/libraries/AP_Networking/AP_Networking_address.cpp +++ b/libraries/AP_Networking/AP_Networking_address.cpp @@ -68,4 +68,9 @@ void AP_Networking_IPV4::set_default_uint32(uint32_t v) } } +const char* AP_Networking_IPV4::get_str() const +{ + return AP_Networking::convert_ip_to_str(get_uint32()); +} + #endif // AP_NETWORKING_ENABLED diff --git a/libraries/AP_Networking/AP_Networking_address.h b/libraries/AP_Networking/AP_Networking_address.h index f607d02facb48..a4a3b6f8b29a8 100644 --- a/libraries/AP_Networking/AP_Networking_address.h +++ b/libraries/AP_Networking/AP_Networking_address.h @@ -1,5 +1,7 @@ #pragma once +#include + /* class for an IPV4 address as a parameter */ @@ -15,6 +17,9 @@ class AP_Networking_IPV4 // set address from a uint32_t void set_uint32(uint32_t addr); + // return address as a null-terminated string + const char* get_str() const; + // set default address from a uint32 void set_default_uint32(uint32_t addr);