Lines Matching full:pub

157 static void mqtt_sn_publish_destroy(struct mqtt_sn_client *client, struct mqtt_sn_publish *pub)  in mqtt_sn_publish_destroy()  argument
159 sys_slist_find_and_remove(&client->publish, &pub->next); in mqtt_sn_publish_destroy()
160 k_mem_slab_free(&publishes, (void *)pub); in mqtt_sn_publish_destroy()
165 struct mqtt_sn_publish *pub; in mqtt_sn_publish_destroy_all() local
169 pub = SYS_SLIST_CONTAINER(next, pub, next); in mqtt_sn_publish_destroy_all()
170 k_mem_slab_free(&publishes, (void *)pub); in mqtt_sn_publish_destroy_all()
176 struct mqtt_sn_publish *pub; in mqtt_sn_publish_create() local
178 if (k_mem_slab_alloc(&publishes, (void **)&pub, K_NO_WAIT)) { in mqtt_sn_publish_create()
179 LOG_ERR("Can't create PUB: no free slot"); in mqtt_sn_publish_create()
183 memset(pub, 0, sizeof(*pub)); in mqtt_sn_publish_create()
186 if (data->size > sizeof(pub->pubdata)) { in mqtt_sn_publish_create()
187 LOG_ERR("Can't create PUB: Too much data (%zu)", data->size); in mqtt_sn_publish_create()
191 memcpy(pub->pubdata, data->data, data->size); in mqtt_sn_publish_create()
192 pub->datalen = data->size; in mqtt_sn_publish_create()
195 mqtt_sn_con_init(&pub->con); in mqtt_sn_publish_create()
197 return pub; in mqtt_sn_publish_create()
203 struct mqtt_sn_publish *pub; in mqtt_sn_publish_find_msg_id() local
205 SYS_SLIST_FOR_EACH_CONTAINER(&client->publish, pub, next) { in mqtt_sn_publish_find_msg_id()
206 if (pub->con.msg_id == msg_id) { in mqtt_sn_publish_find_msg_id()
207 return pub; in mqtt_sn_publish_find_msg_id()
217 struct mqtt_sn_publish *pub; in mqtt_sn_publish_find_topic() local
219 SYS_SLIST_FOR_EACH_CONTAINER(&client->publish, pub, next) { in mqtt_sn_publish_find_topic()
220 if (pub->topic == topic) { in mqtt_sn_publish_find_topic()
221 return pub; in mqtt_sn_publish_find_topic()
288 struct mqtt_sn_publish *pub; in mqtt_sn_topic_destroy() local
291 while ((pub = mqtt_sn_publish_find_topic(client, topic)) != NULL) { in mqtt_sn_topic_destroy()
292 LOG_WRN("Destroying publish msg_id %d", pub->con.msg_id); in mqtt_sn_topic_destroy()
293 mqtt_sn_publish_destroy(client, pub); in mqtt_sn_topic_destroy()
302 struct mqtt_sn_publish *pub; in mqtt_sn_topic_destroy_all() local
308 while ((pub = mqtt_sn_publish_find_topic(client, topic)) != NULL) { in mqtt_sn_topic_destroy_all()
309 LOG_WRN("Destroying publish msg_id %d", pub->con.msg_id); in mqtt_sn_topic_destroy_all()
310 mqtt_sn_publish_destroy(client, pub); in mqtt_sn_topic_destroy_all()
501 static void mqtt_sn_do_publish(struct mqtt_sn_client *client, struct mqtt_sn_publish *pub, bool dup) in mqtt_sn_do_publish() argument
505 if (!client || !pub) { in mqtt_sn_do_publish()
514 LOG_INF("Publishing to topic ID %d", pub->topic->topic_id); in mqtt_sn_do_publish()
516 p.params.publish.data.data = pub->pubdata; in mqtt_sn_do_publish()
517 p.params.publish.data.size = pub->datalen; in mqtt_sn_do_publish()
518 p.params.publish.msg_id = pub->con.msg_id; in mqtt_sn_do_publish()
519 p.params.publish.retain = pub->retain; in mqtt_sn_do_publish()
520 p.params.publish.topic_id = pub->topic->topic_id; in mqtt_sn_do_publish()
521 p.params.publish.topic_type = pub->topic->type; in mqtt_sn_do_publish()
522 p.params.publish.qos = pub->qos; in mqtt_sn_do_publish()
584 struct mqtt_sn_publish *pub, *pubs; in process_pubs() local
589 SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&client->publish, pub, pubs, next) { in process_pubs()
590 LOG_HEXDUMP_DBG(pub->topic->name, pub->topic->namelen, in process_pubs()
592 LOG_HEXDUMP_DBG(pub->pubdata, pub->datalen, "Processing publish data"); in process_pubs()
594 if (pub->con.last_attempt == 0) { in process_pubs()
598 next_attempt = pub->con.last_attempt + T_RETRY_MSEC; in process_pubs()
603 switch (pub->topic->state) { in process_pubs()
611 if (!pub->con.retries--) { in process_pubs()
612 LOG_WRN("PUB ran out of retries, disconnecting"); in process_pubs()
616 mqtt_sn_do_publish(client, pub, dup); in process_pubs()
617 if (pub->qos == MQTT_SN_QOS_0 || pub->qos == MQTT_SN_QOS_M1) { in process_pubs()
619 mqtt_sn_publish_destroy(client, pub); in process_pubs()
623 pub->con.last_attempt = now; in process_pubs()
1062 struct mqtt_sn_publish *pub; in mqtt_sn_publish() local
1092 pub = mqtt_sn_publish_create(data); in mqtt_sn_publish()
1093 if (!pub) { in mqtt_sn_publish()
1098 pub->qos = qos; in mqtt_sn_publish()
1099 pub->retain = retain; in mqtt_sn_publish()
1100 pub->topic = topic; in mqtt_sn_publish()
1102 sys_slist_append(&client->publish, &pub->next); in mqtt_sn_publish()
1310 struct mqtt_sn_publish *pub = mqtt_sn_publish_find_msg_id(client, p->msg_id); in handle_puback() local
1312 if (!pub) { in handle_puback()
1317 mqtt_sn_publish_destroy(client, pub); in handle_puback()
1323 struct mqtt_sn_publish *pub = mqtt_sn_publish_find_msg_id(client, p->msg_id); in handle_pubrec() local
1325 if (!pub) { in handle_pubrec()
1330 pub->con.last_attempt = k_uptime_get(); in handle_pubrec()
1331 pub->con.retries = N_RETRY; in handle_pubrec()
1349 struct mqtt_sn_publish *pub = mqtt_sn_publish_find_msg_id(client, p->msg_id); in handle_pubcomp() local
1351 if (!pub) { in handle_pubcomp()
1356 mqtt_sn_publish_destroy(client, pub); in handle_pubcomp()