Open nirajbhatt7 opened 8 years ago
Usually the following code hangs. Has anyone done this successfully? it is a stripped out code so there might be some mistake but presenting here for understanding.
void mqttData(void* response) { RESPONSE res(response); String topic = res.popString(); String data = res.popString(); //Serial.println(topic + "::" + data); parseData(data); } void parseData(String payload) { //Parse the payload and prepare a response String topicString = "/ResponseTopic"; char topic[topicString.length() + 1]; topicString.toCharArray(topic, topicString.length() + 1); char char_array[payload.length() + 1]; payload.toCharArray(char_array, payload.length() + 1); const char * c = topicString.c_str(); mqtt.publish(c, char_array); }
Usually the following code hangs. Has anyone done this successfully? it is a stripped out code so there might be some mistake but presenting here for understanding.