Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mqtt.publish from the call back void mqttData(void* response) gives unpredictable result #47

Open
nirajbhatt7 opened this issue Feb 13, 2016 · 0 comments

Comments

@nirajbhatt7
Copy link

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant