version 1.1.2.16, 2011/12/06 12:36:45
|
version 1.2, 2012/01/27 15:05:38
|
Line 11 main()
|
Line 11 main()
|
mqtt_msg_t *m; |
mqtt_msg_t *m; |
mqtt_subscr_t s[4], *ss; |
mqtt_subscr_t s[4], *ss; |
mqtthdr_connflgs_t flg; |
mqtthdr_connflgs_t flg; |
|
mqtthdr_connack_t cack; |
u_short ka, msgID; |
u_short ka, msgID; |
int i, len; |
int i, len; |
char cid[BUFSIZ], user[BUFSIZ], pass[BUFSIZ], topic[BUFSIZ], message[BUFSIZ]; | char cid[BUFSIZ], user[BUFSIZ], pass[BUFSIZ], topic[BUFSIZ], message[BUFSIZ], *t, *msg; |
struct mqtthdr *hdr; |
struct mqtthdr *hdr; |
u_char *qoses; |
u_char *qoses; |
|
|
m = mqtt_msgAlloc(0); |
m = mqtt_msgAlloc(0); |
/* conn* */ |
/* conn* */ |
printf("connect=%d/%d\n", m->msg_len, mqtt_msgCONNECT(m, "MRYN", "aaaaa", NULL, "bbb", NULL, 0, 0, 0)); | printf("connect=%d/%d\n", m->msg_len, mqtt_msgCONNECT(m, "MRYN", 0, "aaaaa", NULL, "bbb", NULL, 0, 0, 0)); |
for (i = 0; i < m->msg_len; i++) |
for (i = 0; i < m->msg_len; i++) |
printf("%d\n", ((u_char*) m->msg_base)[i]); |
printf("%d\n", ((u_char*) m->msg_base)[i]); |
flg = mqtt_readCONNECT(m, &ka, cid, sizeof cid, user, sizeof user, pass, sizeof pass, | t = msg = NULL; |
topic, sizeof topic, message, sizeof message); | cack = mqtt_readCONNECT(m, &ka, cid, sizeof cid, user, sizeof user, pass, sizeof pass, &t, &msg); |
printf("read connect flags:: clean=%d will=%d qos=%d retain=%d pass=%d user=%d\n", | flg.flags = cack.reserved; |
| printf("read connect %d flags:: clean=%d will=%d qos=%d retain=%d pass=%d user=%d\n", cack.retcode, |
flg.clean_sess, flg.will_flg, flg.will_qos, flg.will_retain, flg.password, flg.username); |
flg.clean_sess, flg.will_flg, flg.will_qos, flg.will_retain, flg.password, flg.username); |
if (flg.reserved) { |
if (flg.reserved) { |
printf("Error:: mqtt_readCONNECT() #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
printf("Error:: mqtt_readCONNECT() #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
return 1; |
return 1; |
} |
} |
printf("++> KA=%d sec, ConnID=%s User=%s Pass=%s Will_Topic=%s Will_Message=%s\n", ka, |
printf("++> KA=%d sec, ConnID=%s User=%s Pass=%s Will_Topic=%s Will_Message=%s\n", ka, |
cid, user, pass, topic, message); | cid, user, pass, t, msg); |
| if (t) |
| free(t); |
| if (msg) |
| free(msg); |
printf("connack=%d/%d\n", m->msg_len, mqtt_msgCONNACK(m, 1)); |
printf("connack=%d/%d\n", m->msg_len, mqtt_msgCONNACK(m, 1)); |
for (i = 0; i < m->msg_len; i++) |
for (i = 0; i < m->msg_len; i++) |
printf("%d\n", ((u_char*) m->msg_base)[i]); |
printf("%d\n", ((u_char*) m->msg_base)[i]); |