d
Diff: MQTTClient.h
- Revision:
- 60:f1a42823e381
- Parent:
- 57:3513ee54ebb4
--- a/MQTTClient.h Thu Nov 02 12:12:41 2017 +0000 +++ b/MQTTClient.h Sun Mar 20 19:25:46 2022 +0000 @@ -108,7 +108,7 @@ * @param Network a network class which supports send, receive * @param Timer a timer class with the methods: */ -template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE = 100, int MAX_MESSAGE_HANDLERS = 5> +template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE = 100, int MAX_MESSAGE_HANDLERS = 11> class Client { @@ -428,10 +428,14 @@ goto exit; } rc = ipstack.read(&c, 1, timeout); + //printf("decode: %d\r\n",rc); if (rc != 1) goto exit; *value += (c & 127) * multiplier; multiplier *= 128; + //printf("c: %d\r\n",c); + //printf("value: %d\r\n",value); + //printf("multiplier: %d\r\n",multiplier); } while ((c & 128) != 0); exit: return len; @@ -454,6 +458,8 @@ /* 1. read the header byte. This has the packet type in it */ rc = ipstack.read(readbuf, 1, timer.left_ms()); + //printf("read: %d\r\n",rc); + //printf("%c\r\n",readbuf[0]); if (rc != 1) goto exit; @@ -564,7 +570,14 @@ timer.countdown_ms(timeout_ms); while (!timer.expired()) { - if (cycle(timer) < 0) + //printf("while...\r\n"); + int ans=cycle(timer); + if (ans == -3004) + { + rc = -3004; + break; + } + else if (ans < 0) { rc = FAILURE; break; @@ -582,15 +595,22 @@ int len = 0, rc = SUCCESS; + int packet_type = readPacket(timer); // read the socket, see what work is due + //printf("packet_type: %d\r\n",packet_type); switch (packet_type) { default: // no more data to read, unrecoverable. Or read packet fails due to unexpected network error rc = packet_type; + //printf("default\r\n"); goto exit; case 0: // timed out reading packet + //printf("timeout\r\n"); + break; + case -3001: // timed out reading packet + //printf("timeout\r\n"); break; case CONNACK: case PUBACK: