Lines Matching full:pub

715 	if (!mod->pub) {  in bt_mesh_model_pub_period_get()
719 switch (mod->pub->period >> 6) { in bt_mesh_model_pub_period_get()
722 period = (mod->pub->period & BIT_MASK(6)) * 100U; in bt_mesh_model_pub_period_get()
726 period = (mod->pub->period & BIT_MASK(6)) * MSEC_PER_SEC; in bt_mesh_model_pub_period_get()
730 period = (mod->pub->period & BIT_MASK(6)) * 10U * MSEC_PER_SEC; in bt_mesh_model_pub_period_get()
734 period = (mod->pub->period & BIT_MASK(6)) * 600U * MSEC_PER_SEC; in bt_mesh_model_pub_period_get()
740 if (mod->pub->fast_period) { in bt_mesh_model_pub_period_get()
745 return MAX(period >> mod->pub->period_div, 100); in bt_mesh_model_pub_period_get()
753 struct bt_mesh_model_pub *pub = mod->pub; in next_period() local
757 elapsed = k_uptime_get_32() - pub->period_start; in next_period()
760 if (mod->pub->count) { in next_period()
764 period = BT_MESH_PUB_TRANSMIT_INT(mod->pub->retransmit); in next_period()
765 period *= BT_MESH_PUB_MSG_NUM(mod->pub); in next_period()
770 if (!!pub->delayable) { in next_period()
778 return BT_MESH_PUB_TRANSMIT_INT(mod->pub->retransmit); in next_period()
792 if (!!pub->delayable) { in next_period()
817 k_work_schedule(&mod->pub->timer, K_MSEC(delay)); in publish_sent()
838 struct bt_mesh_model_pub *pub = mod->pub; in publish_transmit() local
839 struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_PUB(pub); in publish_transmit()
843 .friend_cred = pub->cred, in publish_transmit()
846 net_buf_simple_add_mem(&sdu, pub->msg->data, pub->msg->len); in publish_transmit()
851 static int pub_period_start(struct bt_mesh_model_pub *pub) in pub_period_start() argument
855 pub->count = BT_MESH_PUB_TRANSMIT_COUNT(pub->retransmit); in pub_period_start()
857 if (!pub->update) { in pub_period_start()
861 err = pub->update(pub->mod); in pub_period_start()
863 pub->period_start = k_uptime_get_32(); in pub_period_start()
868 pub->count = 0; in pub_period_start()
869 publish_sent(err, (void *)pub->mod); in pub_period_start()
889 static int pub_delay_schedule(struct bt_mesh_model_pub *pub, int delay) in pub_delay_schedule() argument
899 err = k_work_reschedule(&pub->timer, K_MSEC(random)); in pub_delay_schedule()
912 struct bt_mesh_model_pub *pub = CONTAINER_OF(dwork, in mod_publish() local
917 if (pub->addr == BT_MESH_ADDR_UNASSIGNED || in mod_publish()
927 if (pub->count) { in mod_publish()
928 pub->count--; in mod_publish()
930 if (pub->retr_update && pub->update && in mod_publish()
931 bt_mesh_model_pub_is_retransmission(pub->mod)) { in mod_publish()
932 err = pub->update(pub->mod); in mod_publish()
934 publish_sent(err, (void *)pub->mod); in mod_publish()
940 err = pub_period_start(pub); in mod_publish()
946 if (!!pub->delayable && !pub_delay_schedule(pub, RANDOM_DELAY_SHORT)) { in mod_publish()
948 pub->count++; in mod_publish()
953 err = publish_transmit(pub->mod); in mod_publish()
956 publish_sent(err, (void *)pub->mod); in mod_publish()
1027 if (mod->pub) { in mod_init()
1028 mod->pub->mod = mod; in mod_init()
1029 k_work_init_delayable(&mod->pub->timer, mod_publish); in mod_init()
1618 struct bt_mesh_model_pub *pub = model->pub; in bt_mesh_model_publish() local
1620 if (!pub) { in bt_mesh_model_publish()
1626 if (pub->addr == BT_MESH_ADDR_UNASSIGNED) { in bt_mesh_model_publish()
1630 if (!pub->msg || !pub->msg->len) { in bt_mesh_model_publish()
1635 if (pub->msg->len + BT_MESH_MIC_SHORT > BT_MESH_TX_SDU_MAX) { in bt_mesh_model_publish()
1640 if (pub->count) { in bt_mesh_model_publish()
1645 pub->count = BT_MESH_PUB_MSG_TOTAL(pub); in bt_mesh_model_publish()
1646 pub->period_start = k_uptime_get_32(); in bt_mesh_model_publish()
1648 LOG_DBG("Publish Retransmit Count %u Interval %ums", pub->count, in bt_mesh_model_publish()
1649 BT_MESH_PUB_TRANSMIT_INT(pub->retransmit)); in bt_mesh_model_publish()
1659 if (!!pub->delayable && !pub_delay_schedule(pub, RANDOM_DELAY_LONG)) { in bt_mesh_model_publish()
1663 k_work_reschedule(&pub->timer, K_NO_WAIT); in bt_mesh_model_publish()
1953 struct mod_pub_val pub; in mod_set_pub() local
1956 if (!mod->pub) { in mod_set_pub()
1962 mod->pub->addr = BT_MESH_ADDR_UNASSIGNED; in mod_set_pub()
1963 mod->pub->key = 0U; in mod_set_pub()
1964 mod->pub->cred = 0U; in mod_set_pub()
1965 mod->pub->ttl = 0U; in mod_set_pub()
1966 mod->pub->period = 0U; in mod_set_pub()
1967 mod->pub->retransmit = 0U; in mod_set_pub()
1968 mod->pub->count = 0U; in mod_set_pub()
1969 mod->pub->uuid = NULL; in mod_set_pub()
1979 err = bt_mesh_settings_set(read_cb, cb_arg, &pub, sizeof(pub)); in mod_set_pub()
1981 LOG_ERR("Failed to set \'model-pub\'"); in mod_set_pub()
1985 if (BT_MESH_ADDR_IS_VIRTUAL(pub.base.addr)) { in mod_set_pub()
1986 mod->pub->uuid = bt_mesh_va_get_uuid_by_idx(pub.uuidx); in mod_set_pub()
1989 mod->pub->addr = pub.base.addr; in mod_set_pub()
1990 mod->pub->key = pub.base.key; in mod_set_pub()
1991 mod->pub->cred = pub.base.cred; in mod_set_pub()
1992 mod->pub->ttl = pub.base.ttl; in mod_set_pub()
1993 mod->pub->period = pub.base.period; in mod_set_pub()
1994 mod->pub->retransmit = pub.base.retransmit; in mod_set_pub()
1995 mod->pub->period_div = pub.base.period_div; in mod_set_pub()
1996 mod->pub->count = 0U; in mod_set_pub()
1998 LOG_DBG("Restored model publication, dst 0x%04x app_idx 0x%03x", pub.base.addr, in mod_set_pub()
1999 pub.base.key); in mod_set_pub()
2069 } else if (!strncmp(next, "pub", 3)) { in mod_set()
2213 struct mod_pub_val pub = {0}; in store_pending_mod_pub() local
2217 encode_mod_path(mod, vnd, "pub", path, sizeof(path)); in store_pending_mod_pub()
2219 if (!mod->pub || mod->pub->addr == BT_MESH_ADDR_UNASSIGNED) { in store_pending_mod_pub()
2222 pub.base.addr = mod->pub->addr; in store_pending_mod_pub()
2223 pub.base.key = mod->pub->key; in store_pending_mod_pub()
2224 pub.base.ttl = mod->pub->ttl; in store_pending_mod_pub()
2225 pub.base.retransmit = mod->pub->retransmit; in store_pending_mod_pub()
2226 pub.base.period = mod->pub->period; in store_pending_mod_pub()
2227 pub.base.period_div = mod->pub->period_div; in store_pending_mod_pub()
2228 pub.base.cred = mod->pub->cred; in store_pending_mod_pub()
2230 if (BT_MESH_ADDR_IS_VIRTUAL(mod->pub->addr)) { in store_pending_mod_pub()
2231 (void)bt_mesh_va_get_idx_by_uuid(mod->pub->uuid, &pub.uuidx); in store_pending_mod_pub()
2234 err = settings_save_one(path, &pub, sizeof(pub)); in store_pending_mod_pub()
2629 if (mod->pub && mod->pub->update && in commit_mod()
2630 mod->pub->addr != BT_MESH_ADDR_UNASSIGNED) { in commit_mod()
2645 random = !!mod->pub->delayable ? pub_delay_get(RANDOM_DELAY_LONG) : 0; in commit_mod()
2648 k_work_schedule(&mod->pub->timer, K_MSEC(ms + random)); in commit_mod()