Exemplo n.º 1
0
void umqtt_process(struct umqtt_connection *conn)
{
	uint8_t buf[5];
	unsigned int i = 2;

	while (conn->rxbuff.datalen >= 2) { /* We do have the fixed header */
		umqtt_circ_pop(&conn->rxbuff, buf, 2);
		for (i = 2; buf[i - 1] & 0x80 && i < sizeof(buf); i++)
			umqtt_circ_pop(&conn->rxbuff, &buf[i], 1);

		umqtt_packet_arrived(conn, buf[0],
				umqtt_decode_length(&buf[1]));
	}
}
Exemplo n.º 2
0
static void umqtt_packet_arrived(struct umqtt_connection *conn,
		uint8_t header, int len)
{
	uint8_t data[len];

	umqtt_circ_pop(&conn->rxbuff, data, len);

	switch (umqtt_header_type(header)) {
	case UMQTT_CONNACK:
		if (data[1] == 0x00)
			conn->state = UMQTT_STATE_CONNECTED;
		else
			conn->state = UMQTT_STATE_FAILED;
		break;
	case UMQTT_SUBACK:
		conn->nack_subscribe--;
		break;
	case UMQTT_PINGRESP:
		conn->nack_ping--;
		break;
	case UMQTT_PUBLISH:
		umqtt_handle_publish(conn, data, len);
		break;

	}
}
Exemplo n.º 3
0
static void _mqttclient_transfer_buffer(void) {
    _mqttclient_send_length = umqtt_circ_pop(&uip_conn->appstate.conn->txbuff,
                                                _mqttclient_send_buffer,
                                                sizeof(sharedbuf.mqtt.send_buffer));
    if (_mqttclient_send_length) {
        _is_sending = true;
        _mqttclient_send();
    }
}