Ejemplo n.º 1
0
void ICACHE_FLASH_ATTR mqtt_timer(void *arg) {
    MQTT_Client *client = (MQTT_Client *) arg;
    if (client->connState == MQTT_DATA) {
	client->keepAliveTick++;
	if (client->keepAliveTick > (client->mqtt_state.connect_info->keepalive / 2)) {
	    client->connState = MQTT_KEEPALIVE_SEND;
	    system_os_post(MQTT_TASK_PRIO, 0, (os_param_t) client);
	}

    } else if (client->connState == TCP_RECONNECT_REQ) {
	client->reconnectTick++;
	if (client->reconnectTick > MQTT_RECONNECT_TIMEOUT) {
	    client->reconnectTick = 0;
	    client->connState = TCP_RECONNECT;
	    system_os_post(MQTT_TASK_PRIO, 0, (os_param_t) client);
	    if (client->timeoutCb)
		client->timeoutCb((uint32_t *) client);
	}
    }
    if (client->sendTimeout > 0)
	client->sendTimeout--;
}
Ejemplo n.º 2
0
void ICACHE_FLASH_ATTR mqtt_timer(xTimerHandle timer)
{
	MQTT_Client* client = (MQTT_Client*) pvTimerGetTimerID(timer);

	if (client->connState == MQTT_DATA) {
		client->keepAliveTick ++;
		if (client->keepAliveTick > client->mqtt_state.connect_info->keepalive) {
			client->connState = MQTT_KEEPALIVE_SEND;
			xSemaphoreGive(client->mqttTaskSem);
		}

	} else if (client->connState == TCP_RECONNECT_REQ) {
		client->reconnectTick ++;
		if (client->reconnectTick > MQTT_RECONNECT_TIMEOUT) {
			client->reconnectTick = 0;
			client->connState = TCP_RECONNECT;
			xSemaphoreGive(client->mqttTaskSem);
			if (client->timeoutCb)
				client->timeoutCb((uint32_t*)client);
		}
	}
	if (client->sendTimeout > 0)
		client->sendTimeout --;
}