Lines Matching refs:timer

34 static int sendPacket(MQTTClient* c, int length, Timer* timer)  in sendPacket()  argument
39 while (sent < length && !TimerIsExpired(timer)) in sendPacket()
41 rc = c->ipstack->mqttwrite(c->ipstack, &c->buf[sent], length, TimerLeftMS(timer)); in sendPacket()
111 static int readPacket(MQTTClient* c, Timer* timer) in readPacket() argument
118 int rc = c->ipstack->mqttread(c->ipstack, c->readbuf, 1, TimerLeftMS(timer)); in readPacket()
124 decodePacket(c, &rem_len, TimerLeftMS(timer)); in readPacket()
134 …rc = c->ipstack->mqttread(c->ipstack, c->readbuf + len, rem_len, TimerLeftMS(timer)) != rem_len)) { in readPacket()
225 Timer timer; in keepalive() local
226 TimerInit(&timer); in keepalive()
227 TimerCountdownMS(&timer, 1000); in keepalive()
229 if (len > 0 && (rc = sendPacket(c, len, &timer)) == SUCCESS) // send the ping packet in keepalive()
257 int cycle(MQTTClient* c, Timer* timer) in cycle() argument
262 int packet_type = readPacket(c, timer); /* read the socket, see what work is due */ in cycle()
297 rc = sendPacket(c, len, timer); in cycle()
313 else if ((rc = sendPacket(c, len, timer)) != SUCCESS) // send the PUBREL packet in cycle()
344 Timer timer; in MQTTYield() local
346 TimerInit(&timer); in MQTTYield()
347 TimerCountdownMS(&timer, timeout_ms); in MQTTYield()
351 if (cycle(c, &timer) < 0) in MQTTYield()
356 } while (!TimerIsExpired(&timer)); in MQTTYield()
368 Timer timer; in MQTTRun() local
371 TimerInit(&timer); in MQTTRun()
378 TimerCountdownMS(&timer, 500); /* Don't wait too long if no traffic is incoming */ in MQTTRun()
379 cycle(c, &timer); in MQTTRun()
395 int waitfor(MQTTClient* c, int packet_type, Timer* timer) in waitfor() argument
401 if (TimerIsExpired(timer)) in waitfor()
403 rc = cycle(c, timer); in waitfor()
521 Timer timer; in MQTTSubscribeWithResults() local
532 TimerInit(&timer); in MQTTSubscribeWithResults()
533 TimerCountdownMS(&timer, c->command_timeout_ms); in MQTTSubscribeWithResults()
538 if ((rc = sendPacket(c, len, &timer)) != SUCCESS) // send the subscribe packet in MQTTSubscribeWithResults()
541 if (waitfor(c, SUBACK, &timer) == SUBACK) // wait for suback in MQTTSubscribeWithResults()
576 Timer timer; in MQTTUnsubscribe() local
587 TimerInit(&timer); in MQTTUnsubscribe()
588 TimerCountdownMS(&timer, c->command_timeout_ms); in MQTTUnsubscribe()
592 if ((rc = sendPacket(c, len, &timer)) != SUCCESS) // send the subscribe packet in MQTTUnsubscribe()
595 if (waitfor(c, UNSUBACK, &timer) == UNSUBACK) in MQTTUnsubscribe()
620 Timer timer; in MQTTPublish() local
631 TimerInit(&timer); in MQTTPublish()
632 TimerCountdownMS(&timer, c->command_timeout_ms); in MQTTPublish()
641 if ((rc = sendPacket(c, len, &timer)) != SUCCESS) // send the subscribe packet in MQTTPublish()
646 if (waitfor(c, PUBACK, &timer) == PUBACK) in MQTTPublish()
658 if (waitfor(c, PUBCOMP, &timer) == PUBCOMP) in MQTTPublish()
682 Timer timer; // we might wait for incomplete incoming publishes to complete in MQTTDisconnect() local
688 TimerInit(&timer); in MQTTDisconnect()
689 TimerCountdownMS(&timer, c->command_timeout_ms); in MQTTDisconnect()
693 rc = sendPacket(c, len, &timer); // send the disconnect packet in MQTTDisconnect()