From ee30733e247676ce7424938db79d6a91ff4d2750 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 2 Nov 2018 00:12:44 +0000 Subject: [PATCH] Fixup bad revert of 500 --- src/PubSubClient.cpp | 13 ++++++++----- tests/src/connect_spec.cpp | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/PubSubClient.cpp b/src/PubSubClient.cpp index 997bfb4..022f90e 100755 --- a/src/PubSubClient.cpp +++ b/src/PubSubClient.cpp @@ -102,15 +102,15 @@ PubSubClient::PubSubClient(const char* domain, uint16_t port, MQTT_CALLBACK_SIGN } boolean PubSubClient::connect(const char *id) { - return connect(id,NULL,NULL,0,0,0,0); + return connect(id,NULL,NULL,0,0,0,0,1); } boolean PubSubClient::connect(const char *id, const char *user, const char *pass) { - return connect(id,user,pass,0,0,0,0); + return connect(id,user,pass,0,0,0,0,1); } boolean PubSubClient::connect(const char *id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage) { - return connect(id,NULL,NULL,willTopic,willQos,willRetain,willMessage); + return connect(id,NULL,NULL,willTopic,willQos,willRetain,willMessage,1); } boolean PubSubClient::connect(const char *id, const char *user, const char *pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage) { @@ -145,9 +145,12 @@ boolean PubSubClient::connect(const char *id, const char *user, const char *pass uint8_t v; if (willTopic) { - v = 0x06|(willQos<<3)|(willRetain<<5); + v = 0x04|(willQos<<3)|(willRetain<<5); } else { - v = 0x02; + v = 0x00; + } + if (cleanSession) { + v = v|0x02; } if(user != NULL) { diff --git a/tests/src/connect_spec.cpp b/tests/src/connect_spec.cpp index 202b2b9..e27a1f5 100644 --- a/tests/src/connect_spec.cpp +++ b/tests/src/connect_spec.cpp @@ -283,20 +283,20 @@ int test_connect_disconnect_connect() { int main() { SUITE("Connect"); - test_connect_non_clean_session(); - // test_connect_fails_no_network(); - // test_connect_fails_on_no_response(); - // - // test_connect_properly_formatted(); - // test_connect_accepts_username_password(); - // test_connect_fails_on_bad_rc(); - // test_connect_properly_formatted_hostname(); - // - // test_connect_accepts_username_no_password(); - // test_connect_ignores_password_no_username(); - // test_connect_with_will(); - // test_connect_with_will_username_password(); - // test_connect_disconnect_connect(); + test_connect_fails_no_network(); + test_connect_fails_on_no_response(); + + test_connect_properly_formatted(); + test_connect_non_clean_session(); + test_connect_accepts_username_password(); + test_connect_fails_on_bad_rc(); + test_connect_properly_formatted_hostname(); + + test_connect_accepts_username_no_password(); + test_connect_ignores_password_no_username(); + test_connect_with_will(); + test_connect_with_will_username_password(); + test_connect_disconnect_connect(); FINISH }