Got a project going on an ESP32.
I'm using several libraries. They all need to know the IP address of a remote server. NOT the machine's local IP address, the IP address of another machine.
Most of them want IP addresses in the form of a byte array, and they seem to be happy with Arduino's weird, non-standard, practically undocumented IPAddress class.
But there's always that one guy.
EspMQTTClient requires that the MQTT Broker's IP address be input as a const char * of the format "192.168.1.1"
. And for the life of me I can't figure or find out how to convert an IPAddress object or a byte array into a const char *.
I can convert it into a String object via the following shenanigan:
String serverAddressString = String(
String(serverAddress[0]) + '.' +
String(serverAddress[1]) + '.' +
String(serverAddress[2]) + '.' +
String(serverAddress[3]));
But even from here I can't get the damn thing converted to a form that his Royal High And Mightiness EspMQTTClient will accept. From the EspMQTTClient Github, for reference:
EspMQTTClient(
const char* wifiSsid,
const char* wifiPassword,
const char* mqttServerIp,
const char* mqttUsername, // Omit this parameter to disable MQTT authentification
const char* mqttPassword, // Omit this parameter to disable MQTT authentification
const char* mqttClientName = "ESP8266",
const short mqttServerPort = 1883);
How do I get this done?