File:  [ELWIX - Embedded LightWeight unIX -] / mqtt / example / Attic / cmds.c
Revision 1.1.2.4: download - view: text, annotated - select for diffs - revision graph
Mon Nov 21 15:27:26 2011 UTC (12 years, 8 months ago) by misho
Branches: mqtt1_0
add payload to publish

    1: #include <stdio.h>
    2: #include <sys/types.h>
    3: #include <aitmqtt.h>
    4: 
    5: 
    6: int
    7: main()
    8: {
    9: 	mqtt_msg_t *m;
   10: 	int i;
   11: 
   12: 	m = mqtt_msgAlloc(0);
   13: 	/* conn* */
   14: 	printf("connect=%d/%d\n", m->msg_len, mqtt_msgCONNECT(m, "MRYN", "aaaaa", NULL, "bbb", NULL, 0, 0, 0));
   15: 	for (i = 0; i < m->msg_len; i++)
   16: 		printf("%d\n", ((u_char*) m->msg_base)[i]);
   17: 	printf("connack=%d/%d\n", m->msg_len, mqtt_msgCONNACK(m, 1));
   18: 	for (i = 0; i < m->msg_len; i++)
   19: 		printf("%d\n", ((u_char*) m->msg_base)[i]);
   20: 
   21: 	/* pub* */
   22: 	printf("publish=%d/%d\n", m->msg_len, mqtt_msgPUBLISH(m, "AAA/bbb/CCC/ddd", 7, 0, 2, 0, "OLE!!!", 7));
   23: 	for (i = 0; i < m->msg_len; i++)
   24: 		printf("%d\n", ((u_char*) m->msg_base)[i]);
   25: 	printf("puback=%d/%d\n", m->msg_len, mqtt_msgPUBACK(m, 10));
   26: 	for (i = 0; i < m->msg_len; i++)
   27: 		printf("%d\n", ((u_char*) m->msg_base)[i]);
   28: 	printf("pubrec=%d/%d\n", m->msg_len, mqtt_msgPUBREC(m, 11));
   29: 	for (i = 0; i < m->msg_len; i++)
   30: 		printf("%d\n", ((u_char*) m->msg_base)[i]);
   31: 	printf("pubrel=%d/%d\n", m->msg_len, mqtt_msgPUBREL(m, 12));
   32: 	for (i = 0; i < m->msg_len; i++)
   33: 		printf("%d\n", ((u_char*) m->msg_base)[i]);
   34: 	printf("pubcomp=%d/%d\n", m->msg_len, mqtt_msgPUBCOMP(m, 13));
   35: 	for (i = 0; i < m->msg_len; i++)
   36: 		printf("%d\n", ((u_char*) m->msg_base)[i]);
   37: 
   38: 	/* sub* */
   39: 
   40: 	mqtt_msgFree(&m, 42);
   41: 	return 0;
   42: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>