AP_Networking: added address_to_str() for scripting

This commit is contained in:
Andrew Tridgell 2024-01-13 12:20:51 +11:00 committed by Tom Pittenger
parent 9202a33ff4
commit 30546f2903
2 changed files with 10 additions and 0 deletions

View File

@ -442,6 +442,13 @@ int ap_networking_printf(const char *fmt, ...)
return 0;
}
// address to string using a static return buffer
const char *AP_Networking::address_to_str(uint32_t addr)
{
static char buf[16]; // 16 for aaa.bbb.ccc.ddd
return SocketAPM::inet_addr_to_str(addr, buf, sizeof(buf));
}
#ifdef LWIP_PLATFORM_ASSERT
void ap_networking_platform_assert(const char *msg, int line, const char *file)
{

View File

@ -139,6 +139,9 @@ public:
// convert string to ethernet mac address
static bool convert_str_to_macaddr(const char *mac_str, uint8_t addr[6]);
// address to string using a static return buffer for scripting
static const char *address_to_str(uint32_t addr);
// helper functions to convert between 32bit Netmask and counting consecutive bits and back
static uint32_t convert_netmask_bitcount_to_ip(const uint32_t netmask_bitcount);
static uint8_t convert_netmask_ip_to_bitcount(const uint32_t netmask_ip);