ExploreEmbedded / Hornbill-Examples

89 stars 169 forks source link

how can I monitor the AWS connection status in AWS_IOT library? #4

Open JasonWolfson opened 7 years ago

JasonWolfson commented 7 years ago

Hi, I would like to monitor AWS connection status. Could you please tell me whether I can do it with AWS_IoT library?

Thanks, Anusha

muneebmalik78 commented 5 years ago

Hi, I did this by editing two files in the Library named as AWS_IOT.cpp and AWS_IOT.h Just Add this Piece of code in AWS_IOT.cpp

bool AWS_IOT::isConnected()
{
    bool connectAck = false;

    connectAck = aws_iot_mqtt_is_client_connected(&client);

    return connectAck;
}

and Add the definition of this function in AWS_IOT.h as below

bool isConnected();

You can use the awsObj.isConnected() to get the current status of Connection.

Luisiado commented 5 years ago

Hi, I did this by editing two files in the Library named as AWS_IOT.cpp and AWS_IOT.h Just Add this Piece of code in AWS_IOT.cpp

bool AWS_IOT::isConnected()
{
    bool connectAck = false;

    connectAck = aws_iot_mqtt_is_client_connected(&client);

    return connectAck;
}

and Add the definition of this function in AWS_IOT.h as below

bool isConnected();

You can use the awsObj.isConnected() to get the current status of Connection.

When you call to the function aws_iot_mqtt_is_client_connected(&client); check the last saved state in the class AWS_IoT_Client but doesnt check or update the real state of connection, right?