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

Fix MQTT_Status_strerror to return correct error on NeedMoreBytes error #255

Merged
merged 9 commits into from
Jun 26, 2023
4 changes: 4 additions & 0 deletions source/core_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3373,6 +3373,10 @@ const char * MQTT_Status_strerror( MQTTStatus_t status )
str = "MQTTKeepAliveTimeout";
break;

case MQTTNeedMoreBytes:
str = "MQTTNeedMoreBytes";
break;

default:
str = "Invalid MQTT Status code";
break;
Expand Down
6 changes: 5 additions & 1 deletion test/unit-test/core_mqtt_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -5842,7 +5842,11 @@ void test_MQTT_Status_strerror( void )
str = MQTT_Status_strerror( status );
TEST_ASSERT_EQUAL_STRING( "MQTTKeepAliveTimeout", str );

status = MQTTKeepAliveTimeout + 1;
status = MQTTNeedMoreBytes;
str = MQTT_Status_strerror( status );
TEST_ASSERT_EQUAL_STRING( "MQTTNeedMoreBytes", str );

status = MQTTNeedMoreBytes + 1;
str = MQTT_Status_strerror( status );
TEST_ASSERT_EQUAL_STRING( "Invalid MQTT Status code", str );
}
Expand Down