Lines Matching refs:mqtt
32 if (h->u.mqtt.heap_baggage) {
33 lws_free(h->u.mqtt.heap_baggage);
34 h->u.mqtt.heap_baggage = NULL;
37 if (h->u.mqtt.sub_info.topic) {
38 for (i = 0; i < h->u.mqtt.sub_info.num_topics; i++) {
39 if (h->u.mqtt.sub_info.topic[i].name) {
40 lws_free((void*)h->u.mqtt.sub_info.topic[i].name);
41 h->u.mqtt.sub_info.topic[i].name = NULL;
44 lws_free(h->u.mqtt.sub_info.topic);
45 h->u.mqtt.sub_info.topic = NULL;
47 lws_buflist_destroy_all_segments(&h->u.mqtt.buflist_unacked);
61 if (h->policy->u.mqtt.aws_iot)
66 if (!h->policy->u.mqtt.subscribe || wsi->mqtt->done_subscribe)
76 if (lws_strexp_expand(&exp, h->policy->u.mqtt.subscribe,
77 strlen(h->policy->u.mqtt.subscribe), &used_in,
98 if (lws_strexp_expand(&exp, h->policy->u.mqtt.subscribe,
99 strlen(h->policy->u.mqtt.subscribe), &used_in,
107 h->u.mqtt.sub_top.name = expbuf;
116 h->u.mqtt.sub_top.name);
118 h->u.mqtt.sub_top.qos = h->policy->u.mqtt.qos;
119 memset(&h->u.mqtt.sub_info, 0, sizeof(h->u.mqtt.sub_info));
120 h->u.mqtt.sub_info.num_topics = 1;
121 h->u.mqtt.sub_info.topic = &h->u.mqtt.sub_top;
122 h->u.mqtt.sub_info.topic =
124 h->u.mqtt.sub_info.topic[0].name = lws_strdup(expbuf);
125 h->u.mqtt.sub_info.topic[0].qos = h->policy->u.mqtt.qos;
127 if (lws_mqtt_client_send_subcribe(wsi, &h->u.mqtt.sub_info)) {
130 h->u.mqtt.sub_top.name = NULL;
134 h->u.mqtt.sub_top.name = NULL;
156 if (h->policy->u.mqtt.aws_iot)
215 if (lws_buflist_append_segment(&h->u.mqtt.buflist_unacked,
231 if (h->policy->u.mqtt.birth_message) {
234 if (lws_strexp_expand(&exp, h->policy->u.mqtt.birth_message,
235 strlen(h->policy->u.mqtt.birth_message),
240 wsi->mqtt->inside_birth = 1;
242 used_out, 0, h->policy->u.mqtt.birth_topic,
243 h->policy->u.mqtt.birth_qos,
244 h->policy->u.mqtt.birth_retain, 0,
255 len = lws_buflist_next_segment_len(&h->u.mqtt.buflist_unacked,
258 if (h->u.mqtt.unacked_size <= len)
265 h->u.mqtt.unacked_size -= (uint32_t)len;
268 if (wsi->mqtt->inside_birth) {
270 h->policy->u.mqtt.birth_topic,
271 h->policy->u.mqtt.birth_qos,
272 h->policy->u.mqtt.birth_retain,
277 h->policy->u.mqtt.topic,
278 h->policy->u.mqtt.qos,
279 h->policy->u.mqtt.retain, 1, f);
282 lws_buflist_use_segment(&h->u.mqtt.buflist_unacked, len);
285 lws_buflist_destroy_all_segments(&h->u.mqtt.buflist_unacked);
286 h->u.mqtt.retry_count = h->u.mqtt.send_unacked = 0;
288 if (wsi->mqtt->inside_birth) {
386 for (i = 0; i < h->u.mqtt.shadow_sub.num_topics; i++)
387 lws_free((void *)h->u.mqtt.shadow_sub.topic[i].name);
389 h->u.mqtt.shadow_sub.num_topics = 0;
391 if (h->u.mqtt.shadow_sub.topic) {
392 lws_free(h->u.mqtt.shadow_sub.topic);
393 h->u.mqtt.shadow_sub.topic = NULL;
402 if (h->u.mqtt.shadow_sub.num_topics == 0) {
403 wsi->mqtt->send_shadow_unsubscribe = 0;
404 wsi->mqtt->inside_shadow = 0;
405 wsi->mqtt->done_shadow_subscribe = 0;
410 if (lws_mqtt_client_send_unsubcribe(wsi, &h->u.mqtt.shadow_sub)) {
421 wsi->mqtt->send_shadow_unsubscribe = 0;
435 if (!h->policy->u.mqtt.topic || wsi->mqtt->inside_shadow)
438 if (h->u.mqtt.shadow_sub.num_topics > 0)
441 memset(&h->u.mqtt.shadow_sub, 0, sizeof(lws_mqtt_subscribe_param_t));
442 h->u.mqtt.shadow_sub.topic = lws_malloc(
444 if (!h->u.mqtt.shadow_sub.topic) {
448 h->u.mqtt.shadow_sub.num_topics = suffixes_len;
450 expbuf = expand_metadata(h, h->policy->u.mqtt.topic, suffixes[i],
458 h->u.mqtt.shadow_sub.topic[i].name = expbuf;
459 h->u.mqtt.shadow_sub.topic[i].qos = h->policy->u.mqtt.qos;
461 h->u.mqtt.shadow_sub.packet_id = (uint16_t)(h->txord - 1);
463 if (lws_mqtt_client_send_subcribe(wsi, &h->u.mqtt.shadow_sub)) {
474 wsi->mqtt->inside_shadow = 1;
561 if (h->policy->u.mqtt.birth_topic &&
562 !wsi->mqtt->done_birth) {
566 (w->mqtt->done_birth || w->mqtt->inside_birth)) {
572 wsi->mqtt->done_birth = 1;
578 if (!h->policy->u.mqtt.subscribe ||
579 !h->policy->u.mqtt.subscribe[0]) {
585 wsi->mqtt->done_subscribe = 1;
586 } else if (!h->policy->u.mqtt.clean_start &&
587 wsi->mqtt->session_resumed) {
588 wsi->mqtt->inside_resume_session = 1;
594 wsi->mqtt->done_subscribe = 1;
595 wsi->mqtt->inside_resume_session = 0;
596 } else if (h->policy->u.mqtt.subscribe &&
597 !wsi->mqtt->done_subscribe) {
607 if (h->policy->u.mqtt.birth_topic &&
608 !wsi->mqtt->done_birth) {
627 if (h->policy->u.mqtt.topic)
646 if (wsi->mqtt->inside_shadow) {
655 if (lws_strexp_expand(&exp, h->policy->u.mqtt.subscribe,
656 strlen(h->policy->u.mqtt.subscribe),
680 if (wsi->mqtt->inside_shadow)
687 if (wsi->mqtt->inside_shadow) {
692 for (i = 0; i < h->u.mqtt.shadow_sub.num_topics; i++) {
697 if (strncmp(h->u.mqtt.shadow_sub.topic[i].name,
709 lws_sul_cancel(&wsi->mqtt->sul_shadow_wait);
710 wsi->mqtt->send_shadow_unsubscribe = 1;
720 if (wsi->mqtt->inside_shadow) {
721 wsi->mqtt->done_shadow_subscribe = 1;
730 if (!wsi->mqtt->done_subscribe && !h->policy->u.mqtt.birth_topic) {
736 wsi->mqtt->done_subscribe = 1;
742 if (h->u.mqtt.send_unacked) {
743 lws_buflist_destroy_all_segments(&h->u.mqtt.buflist_unacked);
744 h->u.mqtt.retry_count = h->u.mqtt.send_unacked = 0;
747 if (wsi->mqtt->inside_birth) {
752 wsi->mqtt->inside_birth = 0;
753 wsi->mqtt->done_birth = 1;
767 if (h->u.mqtt.retry_count++ < LWS_MQTT_MAX_PUBLISH_RETRY) {
768 h->u.mqtt.unacked_size =
769 (uint32_t)lws_buflist_total_len(&h->u.mqtt.buflist_unacked);
770 if (h->u.mqtt.unacked_size) {
773 h->u.mqtt.retry_count,
775 h->u.mqtt.send_unacked = 1;
781 lws_buflist_destroy_all_segments(&h->u.mqtt.buflist_unacked);
782 h->u.mqtt.retry_count = h->u.mqtt.send_unacked = 0;
784 if (wsi->mqtt->inside_birth) {
806 if (!wsi->mqtt->done_subscribe && h->policy->u.mqtt.subscribe)
809 if (h->u.mqtt.send_unacked)
812 if (!wsi->mqtt->done_birth && h->policy->u.mqtt.birth_topic)
815 if (h->policy->u.mqtt.aws_iot) {
817 h->policy->u.mqtt.topic) == LMMTR_TOPIC_MATCH) {
818 if (!wsi->mqtt->done_shadow_subscribe)
820 if (wsi->mqtt->send_shadow_unsubscribe)
829 if (wsi->mqtt->done_shadow_subscribe) {
837 if (h->u.mqtt.sub_info.num_topics) {
838 lmsp.num_topics = h->u.mqtt.sub_info.num_topics;
839 lmsp.topic = h->u.mqtt.sub_info.topic;
856 h->policy->u.mqtt.topic,
857 h->policy->u.mqtt.qos,
858 h->policy->u.mqtt.retain, 0, f) != 0) {
870 if (wsi->mqtt->inside_shadow) {
872 wsi->mqtt->inside_shadow = 0;
873 wsi->mqtt->done_shadow_subscribe = 0;
882 if (!wsi->mqtt)
885 if (wsi->mqtt->inside_shadow) {
887 wsi->mqtt->inside_shadow = 0;
888 wsi->mqtt->done_shadow_subscribe = 0;
894 if (wsi->mqtt->inside_unsubscribe) {
902 if (!wsi->mqtt)
905 if (wsi->mqtt->inside_shadow) {
908 wsi->mqtt->send_shadow_unsubscribe = 1;
921 "lws-secstream-mqtt",
952 h->policy->u.mqtt.will_topic,
953 h->policy->u.mqtt.will_message,
954 h->policy->u.mqtt.subscribe,
955 h->policy->u.mqtt.topic,
956 h->policy->u.mqtt.birth_topic,
957 h->policy->u.mqtt.birth_message
1030 ct->ccp.keep_alive = h->policy->u.mqtt.keep_alive;
1031 ct->ccp.clean_start = (h->policy->u.mqtt.clean_start & 1u);
1032 ct->ccp.will_param.qos = h->policy->u.mqtt.will_qos;
1033 ct->ccp.will_param.retain = h->policy->u.mqtt.will_retain;
1034 ct->ccp.birth_param.qos = h->policy->u.mqtt.birth_qos;
1035 ct->ccp.birth_param.retain = h->policy->u.mqtt.birth_retain;
1036 ct->ccp.aws_iot = h->policy->u.mqtt.aws_iot;
1037 h->u.mqtt.topic_qos.qos = h->policy->u.mqtt.qos;
1045 * Notice these allocations at h->u.mqtt.heap_baggage belong to the
1075 h->u.mqtt.heap_baggage = lws_malloc(tot, __func__);
1076 if (!h->u.mqtt.heap_baggage)
1084 p = h->u.mqtt.heap_baggage;
1107 h->u.mqtt.subscribe_to = ps[SSCMM_STRSUB_SUBSCRIBE];
1108 h->u.mqtt.subscribe_to_len = olen[SSCMM_STRSUB_SUBSCRIBE];
1109 h->u.mqtt.topic_qos.name = ps[SSCMM_STRSUB_TOPIC];
1116 i->alpn = "x-amzn-mqtt-ca";
1126 "x-amzn-mqtt-ca", //"mqtt/3.1.1",