Add qos1 receive test
This commit is contained in:
parent
aab2dcdf1a
commit
3930b15158
@ -51,6 +51,7 @@ private:
|
|||||||
uint8_t readByte();
|
uint8_t readByte();
|
||||||
boolean write(uint8_t header, uint8_t* buf, uint16_t length);
|
boolean write(uint8_t header, uint8_t* buf, uint16_t length);
|
||||||
uint16_t writeString(char* string, uint8_t* buf, uint16_t pos);
|
uint16_t writeString(char* string, uint8_t* buf, uint16_t pos);
|
||||||
|
boolean puback(uint16_t msgId);
|
||||||
uint8_t *ip;
|
uint8_t *ip;
|
||||||
char* domain;
|
char* domain;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
@ -73,7 +74,6 @@ public:
|
|||||||
boolean subscribe(char *);
|
boolean subscribe(char *);
|
||||||
boolean subscribe(char *, uint8_t qos);
|
boolean subscribe(char *, uint8_t qos);
|
||||||
boolean unsubscribe(char *);
|
boolean unsubscribe(char *);
|
||||||
boolean puback(uint16_t msgId);
|
|
||||||
boolean loop();
|
boolean loop();
|
||||||
boolean connected();
|
boolean connected();
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@ int test_receive_callback() {
|
|||||||
shimClient.respond(publish,16);
|
shimClient.respond(publish,16);
|
||||||
|
|
||||||
rc = client.loop();
|
rc = client.loop();
|
||||||
|
|
||||||
IS_TRUE(rc);
|
IS_TRUE(rc);
|
||||||
|
|
||||||
IS_TRUE(callback_called);
|
IS_TRUE(callback_called);
|
||||||
@ -132,12 +132,47 @@ int test_receive_oversized_message() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int test_receive_qos1() {
|
||||||
|
IT("receives a qos1 message");
|
||||||
|
reset_callback();
|
||||||
|
|
||||||
|
ShimClient shimClient;
|
||||||
|
shimClient.setAllowConnect(true);
|
||||||
|
|
||||||
|
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||||
|
shimClient.respond(connack,4);
|
||||||
|
|
||||||
|
PubSubClient client(server, 1883, callback, shimClient);
|
||||||
|
int rc = client.connect((char*)"client_test1");
|
||||||
|
IS_TRUE(rc);
|
||||||
|
|
||||||
|
byte publish[] = {0x32,0x10,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x12,0x34,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||||
|
shimClient.respond(publish,18);
|
||||||
|
|
||||||
|
byte puback[] = {0x40,0x2,0x12,0x34};
|
||||||
|
shimClient.expect(puback,4);
|
||||||
|
|
||||||
|
rc = client.loop();
|
||||||
|
|
||||||
|
IS_TRUE(rc);
|
||||||
|
|
||||||
|
IS_TRUE(callback_called);
|
||||||
|
IS_TRUE(strcmp(lastTopic,"topic")==0);
|
||||||
|
IS_TRUE(memcmp(lastPayload,"payload",7)==0);
|
||||||
|
IS_TRUE(lastLength == 7);
|
||||||
|
|
||||||
|
IS_FALSE(shimClient.error());
|
||||||
|
|
||||||
|
END_IT
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test_receive_callback();
|
test_receive_callback();
|
||||||
test_receive_stream();
|
test_receive_stream();
|
||||||
test_receive_max_sized_message();
|
test_receive_max_sized_message();
|
||||||
test_receive_oversized_message();
|
test_receive_oversized_message();
|
||||||
|
test_receive_qos1();
|
||||||
|
|
||||||
FINISH
|
FINISH
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user