--- mqtt/src/Attic/sub.c 2011/11/21 15:27:26 1.1.2.3 +++ mqtt/src/Attic/sub.c 2011/11/21 16:28:05 1.1.2.4 @@ -8,7 +8,6 @@ mqtt_msgSUBSCRIBE(mqtt_msg_t * __restrict buf, const c u_char Dup, u_char QOS) { int siz = 0; -#if 0 struct mqtthdr *hdr; mqtthdr_var_t *topic; mqtt_v_t *mid; @@ -33,24 +32,23 @@ mqtt_msgSUBSCRIBE(mqtt_msg_t * __restrict buf, const c /* 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->var_sb.val = htons(strlen(csTopic)); memcpy(topic->var_data, csTopic, ntohs(topic->var_sb.val)); siz += MQTTHDR_VAR_SIZEOF(topic); - mid = (mqtt_v_t*) (buf->msg_base + siz); - mid->val = htons(msgID); - siz += sizeof(mqtt_v_t); - /* fixed header */ - hdr->mqtt_msg.type = MQTT_TYPE_PUBLISH; + hdr->mqtt_msg.type = MQTT_TYPE_SUBSCRIBE; hdr->mqtt_msg.qos = QOS; 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)); mqtt_msgRealloc(buf, siz); -#endif return siz; }