#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <aitmqtt.h>
int
main()
{
mqtt_msg_t *m;
mqtt_subscr_t s[4];
int i;
m = mqtt_msgAlloc(0);
/* conn* */
printf("connect=%d/%d\n", m->msg_len, mqtt_msgCONNECT(m, "MRYN", "aaaaa", NULL, "bbb", NULL, 0, 0, 0));
for (i = 0; i < m->msg_len; i++)
printf("%d\n", ((u_char*) m->msg_base)[i]);
printf("connack=%d/%d\n", m->msg_len, mqtt_msgCONNACK(m, 1));
for (i = 0; i < m->msg_len; i++)
printf("%d\n", ((u_char*) m->msg_base)[i]);
/* pub* */
printf("publish=%d/%d\n", m->msg_len, mqtt_msgPUBLISH(m, "AAA/bbb/CCC/ddd", 7, 0, 2, 0, "OLE!!!", 7));
for (i = 0; i < m->msg_len; i++)
printf("%d\n", ((u_char*) m->msg_base)[i]);
printf("puback=%d/%d\n", m->msg_len, mqtt_msgPUBACK(m, 10));
for (i = 0; i < m->msg_len; i++)
printf("%d\n", ((u_char*) m->msg_base)[i]);
printf("pubrec=%d/%d\n", m->msg_len, mqtt_msgPUBREC(m, 11));
for (i = 0; i < m->msg_len; i++)
printf("%d\n", ((u_char*) m->msg_base)[i]);
printf("pubrel=%d/%d\n", m->msg_len, mqtt_msgPUBREL(m, 12));
for (i = 0; i < m->msg_len; i++)
printf("%d\n", ((u_char*) m->msg_base)[i]);
printf("pubcomp=%d/%d\n", m->msg_len, mqtt_msgPUBCOMP(m, 13));
for (i = 0; i < m->msg_len; i++)
printf("%d\n", ((u_char*) m->msg_base)[i]);
/* sub* */
memset(s, 0, sizeof s);
s[0].sub_sb.sb.l = 3;
s[0].sub_data = "a/b";
s[0].sub_qos = MQTT_QOS_ACK;
s[1].sub_sb.sb.l = 3;
s[1].sub_data = "c/d";
s[1].sub_qos = MQTT_QOS_ONCE;
s[2].sub_sb.sb.l = 7;
s[2].sub_data = "x/y/z/Q";
s[2].sub_qos = MQTT_QOS_EXACTLY;
printf("subscribe=%d/%d\n", m->msg_len, mqtt_msgSUBSCRIBE(m, s, 10, 0, 0));
for (i = 0; i < m->msg_len; i++)
printf("%d\n", ((u_char*) m->msg_base)[i]);
mqtt_msgFree(&m, 42);
return 0;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>