Hi, can someone explain me why this code fails to compile?
edit: I'm using ARDUINO IDE, AVRISP mkll for generic ESP8266 module
void loop() {
if (checkConnection()) {
// Connected to WiFi and MQTT Server
WiFiClient client = server.available(); // Listen for incoming clients
if (client) { // If a new client connects,
String data = ""; // make a String to hold incoming data from the client
bool isMessage = false;
char* buffer[HTTP_BUFFER_LENGTH]; // make a buffer to hold incoming data from the client
int length = 0; // length of message
long unsigned time_ = millis();
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then decide what to do
if (c == '{') { // could be the initial char of a JSON
isMessage = true;
}
if (isMessage == true) { // if we are reading a message save it
if (length < HTTP_BUFFER_LENGTH) {
buffer[length] = c; // save current char
length++; // go on
buffer[length] = '\0'; // append null char
}
}
if (c == '}') { // the end, parse it and close connection
client.println("HTTP/1.1 200 OK");
delay(2);
client.stop();
Serial.println(data); // display result
}
if ((long unsigned)millis() - time_ > MAX_HTTP_TIME) { //max time reached
client.stop();
}
}
}
}
}
if (Serial.available()) {
serial_read(); // To read data from serial and publish in MQTT topic
}
client_mqtt.loop(); // To send data stored in MQTT Buffer
}
It says
invalid conversion from 'char' to 'char*' [-fpermissive]
buffer[length] = c; // save current char
^
I can't understand what I'm doing wrong. If you could give me some documentation to read and explain me the problem that would be the best.
EDIT: Now it seems to be ok. I've added the operator & before c. So it looks like this.
buffer[length] = &c; // save current char
Can someone explain me what I just did? It would be really important to me to understand this thoroughly.
Furthermore I've another question: why I can't write something like this:
char string1[16] = "xxx.xxx.xxx.xxx";
char new_string[16];
new_string = string1;
the compiler gives me this error: exit status 1, invalid array assignment. So what would be the correct way to handle this?