version 1.1.2.6, 2011/11/22 13:00:33
|
version 1.1.2.10, 2011/12/05 14:11:47
|
Line 9 main()
|
Line 9 main()
|
{ |
{ |
mqtt_msg_t *m; |
mqtt_msg_t *m; |
mqtt_subscr_t s[4]; |
mqtt_subscr_t s[4]; |
|
mqtthdr_connflgs_t flg; |
|
u_short ka; |
int i; |
int i; |
|
char cid[BUFSIZ], user[BUFSIZ], pass[BUFSIZ], topic[BUFSIZ], message[BUFSIZ]; |
|
|
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", "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, |
|
topic, sizeof topic, message, sizeof message); |
|
printf("read connect flags:: clean=%d will=%d qos=%d retain=%d pass=%d user=%d\n", |
|
flg.clean_sess, flg.will_flg, flg.will_qos, flg.will_retain, flg.password, flg.username); |
|
if (flg.reserved) { |
|
printf("Error:: mqtt_readCONNECT() #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
|
return 1; |
|
} |
|
printf("++> KA=%d sec, ConnID=%s User=%s Pass=%s Will_Topic=%s Will_Message=%s\n", ka, |
|
cid, user, pass, topic, message); |
|
getchar(); |
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]); |
Line 39 main()
|
Line 53 main()
|
|
|
/* sub* */ |
/* sub* */ |
memset(s, 0, sizeof s); |
memset(s, 0, sizeof s); |
s[0].sub_sb.sb.l = 3; | s[0].sub_topic._size = 3; |
s[0].sub_data = "a/b"; | s[0].sub_topic._base = "a/b"; |
s[0].sub_qos = MQTT_QOS_ACK; | s[0].sub_ret = MQTT_QOS_ACK; |
s[1].sub_sb.sb.l = 3; | s[1].sub_topic._size = 3; |
s[1].sub_data = "c/d"; | s[1].sub_topic._base = "c/d"; |
s[1].sub_qos = MQTT_QOS_ONCE; | s[1].sub_ret = MQTT_QOS_ONCE; |
s[2].sub_sb.sb.l = 7; | s[2].sub_topic._size = 7; |
s[2].sub_data = "x/y/z/Q"; | s[2].sub_topic._base = "x/y/z/Q"; |
s[2].sub_qos = MQTT_QOS_EXACTLY; | s[2].sub_ret = MQTT_QOS_EXACTLY; |
printf("subscribe=%d/%d\n", m->msg_len, mqtt_msgSUBSCRIBE(m, s, 10, 0, 0)); |
printf("subscribe=%d/%d\n", m->msg_len, mqtt_msgSUBSCRIBE(m, s, 10, 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]); |
printf("suback=%d/%d\n", m->msg_len, mqtt_msgSUBACK(m, s, 10)); |
printf("suback=%d/%d\n", m->msg_len, mqtt_msgSUBACK(m, s, 10)); |
|
for (i = 0; i < m->msg_len; i++) |
|
printf("%d\n", ((u_char*) m->msg_base)[i]); |
|
printf("unsubscribe=%d/%d\n", m->msg_len, mqtt_msgUNSUBSCRIBE(m, s, 10, 0, 1)); |
|
for (i = 0; i < m->msg_len; i++) |
|
printf("%d\n", ((u_char*) m->msg_base)[i]); |
|
printf("unsuback=%d/%d\n", m->msg_len, mqtt_msgUNSUBACK(m, 10)); |
|
for (i = 0; i < m->msg_len; i++) |
|
printf("%d\n", ((u_char*) m->msg_base)[i]); |
|
|
|
/* ping* */ |
|
printf("pingreq=%d/%d\n", m->msg_len, mqtt_msgPINGREQ(m)); |
|
for (i = 0; i < m->msg_len; i++) |
|
printf("%d\n", ((u_char*) m->msg_base)[i]); |
|
printf("pingresp=%d/%d\n", m->msg_len, mqtt_msgPINGRESP(m)); |
|
for (i = 0; i < m->msg_len; i++) |
|
printf("%d\n", ((u_char*) m->msg_base)[i]); |
|
|
|
printf("disconnect=%d/%d\n", m->msg_len, mqtt_msgDISCONNECT(m)); |
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]); |
|
|