Annotation of mqtt/example/cmds.c, revision 1.1.2.7
1.1.2.1 misho 1: #include <stdio.h>
1.1.2.5 misho 2: #include <string.h>
1.1.2.1 misho 3: #include <sys/types.h>
4: #include <aitmqtt.h>
5:
6:
7: int
8: main()
9: {
10: mqtt_msg_t *m;
1.1.2.5 misho 11: mqtt_subscr_t s[4];
1.1.2.1 misho 12: int i;
13:
14: m = mqtt_msgAlloc(0);
15: /* conn* */
16: printf("connect=%d/%d\n", m->msg_len, mqtt_msgCONNECT(m, "MRYN", "aaaaa", NULL, "bbb", NULL, 0, 0, 0));
17: for (i = 0; i < m->msg_len; i++)
18: printf("%d\n", ((u_char*) m->msg_base)[i]);
19: printf("connack=%d/%d\n", m->msg_len, mqtt_msgCONNACK(m, 1));
20: for (i = 0; i < m->msg_len; i++)
21: printf("%d\n", ((u_char*) m->msg_base)[i]);
22:
23: /* pub* */
1.1.2.4 misho 24: printf("publish=%d/%d\n", m->msg_len, mqtt_msgPUBLISH(m, "AAA/bbb/CCC/ddd", 7, 0, 2, 0, "OLE!!!", 7));
1.1.2.1 misho 25: for (i = 0; i < m->msg_len; i++)
26: printf("%d\n", ((u_char*) m->msg_base)[i]);
1.1.2.3 misho 27: printf("puback=%d/%d\n", m->msg_len, mqtt_msgPUBACK(m, 10));
28: for (i = 0; i < m->msg_len; i++)
29: printf("%d\n", ((u_char*) m->msg_base)[i]);
30: printf("pubrec=%d/%d\n", m->msg_len, mqtt_msgPUBREC(m, 11));
31: for (i = 0; i < m->msg_len; i++)
32: printf("%d\n", ((u_char*) m->msg_base)[i]);
33: printf("pubrel=%d/%d\n", m->msg_len, mqtt_msgPUBREL(m, 12));
34: for (i = 0; i < m->msg_len; i++)
35: printf("%d\n", ((u_char*) m->msg_base)[i]);
36: printf("pubcomp=%d/%d\n", m->msg_len, mqtt_msgPUBCOMP(m, 13));
37: for (i = 0; i < m->msg_len; i++)
38: printf("%d\n", ((u_char*) m->msg_base)[i]);
39:
40: /* sub* */
1.1.2.5 misho 41: memset(s, 0, sizeof s);
42: s[0].sub_sb.sb.l = 3;
43: s[0].sub_data = "a/b";
44: s[0].sub_qos = MQTT_QOS_ACK;
45: s[1].sub_sb.sb.l = 3;
46: s[1].sub_data = "c/d";
47: s[1].sub_qos = MQTT_QOS_ONCE;
48: s[2].sub_sb.sb.l = 7;
49: s[2].sub_data = "x/y/z/Q";
50: s[2].sub_qos = MQTT_QOS_EXACTLY;
51: printf("subscribe=%d/%d\n", m->msg_len, mqtt_msgSUBSCRIBE(m, s, 10, 0, 0));
52: for (i = 0; i < m->msg_len; i++)
53: printf("%d\n", ((u_char*) m->msg_base)[i]);
1.1.2.6 misho 54: printf("suback=%d/%d\n", m->msg_len, mqtt_msgSUBACK(m, s, 10));
55: for (i = 0; i < m->msg_len; i++)
56: printf("%d\n", ((u_char*) m->msg_base)[i]);
1.1.2.7 ! misho 57: printf("unsubscribe=%d/%d\n", m->msg_len, mqtt_msgUNSUBSCRIBE(m, s, 10, 0, 1));
! 58: for (i = 0; i < m->msg_len; i++)
! 59: printf("%d\n", ((u_char*) m->msg_base)[i]);
! 60: printf("unsuback=%d/%d\n", m->msg_len, mqtt_msgUNSUBACK(m, 10));
! 61: for (i = 0; i < m->msg_len; i++)
! 62: printf("%d\n", ((u_char*) m->msg_base)[i]);
1.1.2.1 misho 63:
64: mqtt_msgFree(&m, 42);
65: return 0;
66: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>