ExploreEmbedded / Hornbill-Examples

89 stars 171 forks source link

Publishing message without internet access #21

Closed diogo24m closed 4 years ago

diogo24m commented 4 years ago

My ESP32 says it was able to post 2/3 messages 1/2 seconds after disconnecting my local network from internet.

This is my code:

void loop(){
...
    String json = "{\"id\":"+id+",\"code\":"+str+"}";
    publishAWS(json);
...
}

void publishAWS(String str) {
    Serial.println("Publishing message to AWS...");

    char arr[512];
    str.toCharArray(arr, 512);

    if(hornbill.publish(TOPIC_NAME, arr) == 0){
        Serial.print("Publish Message:");
        Serial.println(arr);
    }else{
        Serial.println("Publish failed");
        runBuzzer(freq_failed);
    }
}

Any thoughts?

Edit: multiple publishers with same id.