Code : Tout sélectionner
char* msg_veille_date=".";
char* msg_etat=".";
char* msg_etat_date=".";
void callback(char* topic, byte* payload, unsigned int length) {
DPRINT("Message arrived [");
DPRINT(topic);
DPRINT("] ");
String messageTemp;
for (int i = 0; i < length; i++) {
DPRINT((char)payload[i]);
messageTemp += (char)payload[i];
}
DPRINTLN();
DynamicJsonDocument doc(128);
DeserializationError error = deserializeJson(doc, payload, length);
if (error) {
DPRINTLN(error.f_str());
return;
}
// If a message is received on the topic
if (String(topic) == mqtt_action) {
const char* msg_action = doc["value"].as<const char *>();
const char* msg_action_date = doc["update"].as<const char *>();
DPRINT("Action lu : ");DPRINT(msg_action);DPRINT(" ");DPRINTLN(msg_action_date);
}
if (String(topic) == mqtt_etat) {
const char* msg_etat = doc["value"].as<const char *>();
const char* msg_etat_date = doc["update"].as<const char *>();
DPRINT("Status lu : ");DPRINT(msg_etat);DPRINT(" ");DPRINTLN(msg_etat_date);
}
}
void setup(void) {
for(int i=0;i<10; i++)
{
client.loop(); //Ensure we've sent & received everything
delay(200);
}
DPRINTLN(msg_action);
DPRINTLN(msg_etat);
}
je dois surement passer le pointeur mais je n'arrive pas à faire la copie, besoin d'un peu d'aide !