version 1.1.2.3, 2011/11/21 15:27:26
|
version 1.1.2.4, 2011/11/21 16:28:05
|
Line 8 mqtt_msgSUBSCRIBE(mqtt_msg_t * __restrict buf, const c
|
Line 8 mqtt_msgSUBSCRIBE(mqtt_msg_t * __restrict buf, const c
|
u_char Dup, u_char QOS) |
u_char Dup, u_char QOS) |
{ |
{ |
int siz = 0; |
int siz = 0; |
#if 0 |
|
struct mqtthdr *hdr; |
struct mqtthdr *hdr; |
mqtthdr_var_t *topic; |
mqtthdr_var_t *topic; |
mqtt_v_t *mid; |
mqtt_v_t *mid; |
Line 33 mqtt_msgSUBSCRIBE(mqtt_msg_t * __restrict buf, const c
|
Line 32 mqtt_msgSUBSCRIBE(mqtt_msg_t * __restrict buf, const c
|
|
|
/* variable header */ |
/* variable header */ |
|
|
|
mid = (mqtt_v_t*) (buf->msg_base + siz); |
|
mid->val = htons(msgID); |
|
siz += sizeof(mqtt_v_t); |
|
|
topic = (mqtthdr_var_t*) (buf->msg_base + siz); |
topic = (mqtthdr_var_t*) (buf->msg_base + siz); |
topic->var_sb.val = htons(strlen(csTopic)); |
topic->var_sb.val = htons(strlen(csTopic)); |
memcpy(topic->var_data, csTopic, ntohs(topic->var_sb.val)); |
memcpy(topic->var_data, csTopic, ntohs(topic->var_sb.val)); |
siz += MQTTHDR_VAR_SIZEOF(topic); |
siz += MQTTHDR_VAR_SIZEOF(topic); |
|
|
mid = (mqtt_v_t*) (buf->msg_base + siz); |
|
mid->val = htons(msgID); |
|
siz += sizeof(mqtt_v_t); |
|
|
|
/* fixed header */ |
/* fixed header */ |
|
|
hdr->mqtt_msg.type = MQTT_TYPE_PUBLISH; | hdr->mqtt_msg.type = MQTT_TYPE_SUBSCRIBE; |
hdr->mqtt_msg.qos = QOS; |
hdr->mqtt_msg.qos = QOS; |
hdr->mqtt_msg.dup = Dup ? 1 : 0; |
hdr->mqtt_msg.dup = Dup ? 1 : 0; |
hdr->mqtt_msg.retain = Retain ? 1 : 0; | hdr->mqtt_msg.retain = 0; |
*hdr->mqtt_len = mqtt_encodeLen(siz - sizeof(struct mqtthdr)); |
*hdr->mqtt_len = mqtt_encodeLen(siz - sizeof(struct mqtthdr)); |
|
|
mqtt_msgRealloc(buf, siz); |
mqtt_msgRealloc(buf, siz); |
#endif |
|
return siz; |
return siz; |
} |
} |