Lines Matching +full:num +full:- +full:inputs

4  * SPDX-License-Identifier: Apache-2.0
19 SYS_SLIST_FOR_EACH_CONTAINER((sys_slist_t *)&(cli)->inputs->targets, \
22 /* The Maximum BLOB Poll Interval - T_MBPI */
25 #define CLIENT_TIMEOUT_MSEC(cli) (10 * MSEC_PER_SEC * (cli->inputs->timeout_base + 2) + \
26 100 * cli->inputs->ttl)
30 #define SENDING_CHUNKS_IN_PULL_MODE(cli) ((cli)->state == BT_MESH_BLOB_CLI_STATE_BLOCK_SEND && \
31 (cli)->xfer->mode == BT_MESH_BLOB_XFER_MODE_PULL)
32 #define UNICAST_MODE(cli) ((cli)->inputs->group == BT_MESH_ADDR_UNASSIGNED || \
33 (cli)->tx.ctx.force_unicast)
65 int64_t next_timeout_ms = cli->tx.cli_timestamp; in start_retry_timer()
69 if (!target->procedure_complete && in start_retry_timer()
70 target->status == BT_MESH_BLOB_SUCCESS && in start_retry_timer()
71 target->pull->block_report_timestamp < next_timeout_ms) { in start_retry_timer()
72 next_timeout_ms = target->pull->block_report_timestamp; in start_retry_timer()
79 next_timeout_ms -= k_uptime_get(); in start_retry_timer()
86 (void)k_work_reschedule(&cli->tx.retry, next_timeout); in start_retry_timer()
91 k_work_cancel_delayable(&cli->tx.retry); in cli_state_reset()
92 cli->xfer = NULL; in cli_state_reset()
93 cli->state = BT_MESH_BLOB_CLI_STATE_NONE; in cli_state_reset()
94 cli->tx.ctx.is_inited = 0; in cli_state_reset()
95 cli->tx.cli_timestamp = 0ll; in cli_state_reset()
96 cli->tx.sending = 0; in cli_state_reset()
105 if (target->addr == addr) { in target_get()
118 LOG_WRN("Dropping 0x%04x: %u", target->addr, reason); in target_drop()
120 target->status = reason; in target_drop()
121 if (cli->cb && cli->cb->lost_target) { in target_drop()
122 cli->cb->lost_target(cli, target, reason); in target_drop()
132 if (target->status == BT_MESH_BLOB_SUCCESS) { in targets_reset()
133 target->acked = 0U; in targets_reset()
146 if (target->status == BT_MESH_BLOB_SUCCESS) { in targets_active()
159 if (!!target->timedout) { in targets_timedout()
169 if (!cli->io->open) { in io_open()
173 return cli->io->open(cli->io, cli->xfer, BT_MESH_BLOB_READ); in io_open()
178 if (!cli->io->close) { in io_close()
182 cli->io->close(cli->io, cli->xfer); in io_close()
193 } while (++idx < cli->block.chunk_count); in next_missing_chunk()
198 /* Used in Pull mode to collect all missing chunks from each target in cli->block.missing. */
203 memset(cli->block.missing, 0, sizeof(cli->block.missing)); in update_missing_chunks()
206 if (target->procedure_complete || target->timedout) { in update_missing_chunks()
210 for (size_t idx = 0; idx < cli->block.chunk_count; idx++) { in update_missing_chunks()
211 bool missing = blob_chunk_missing_get(cli->block.missing, idx) || in update_missing_chunks()
212 blob_chunk_missing_get(target->pull->missing, idx); in update_missing_chunks()
213 blob_chunk_missing_set(cli->block.missing, idx, missing); in update_missing_chunks()
222 if ((chunk_idx == block->chunk_count - 1) && in chunk_size()
223 (block->size % xfer->chunk_size)) { in chunk_size()
224 return block->size % xfer->chunk_size; in chunk_size()
227 return xfer->chunk_size; in chunk_size()
235 if (buf->len == 0) { in chunk_idx_decode()
236 return -EINVAL; in chunk_idx_decode()
241 /* utf-8 decoding */ in chunk_idx_decode()
242 if ((byte & 0xf0) == 0xe0) { /* 0x800 - 0xffff */ in chunk_idx_decode()
243 if (buf->len < 2) { in chunk_idx_decode()
244 return -EINVAL; in chunk_idx_decode()
250 } else if ((byte & 0xe0) == 0xc0) { /* 0x80 - 0x7ff */ in chunk_idx_decode()
251 if (buf->len < 1) { in chunk_idx_decode()
252 return -EINVAL; in chunk_idx_decode()
257 } else { /* 0x00 - 0x7f */ in chunk_idx_decode()
266 cli->block.number = block_idx; in block_set()
267 cli->block.offset = block_idx * (1UL << cli->xfer->block_size_log); in block_set()
268 cli->block.size = blob_block_size(cli->xfer->size, cli->xfer->block_size_log, in block_set()
270 cli->block.chunk_count = in block_set()
271 DIV_ROUND_UP(cli->block.size, cli->xfer->chunk_size); in block_set()
273 if (cli->xfer->mode == BT_MESH_BLOB_XFER_MODE_PUSH) { in block_set()
274 blob_chunk_missing_set_all(&cli->block); in block_set()
279 memset(cli->block.missing, 0, sizeof(cli->block.missing)); in block_set()
282 memset(target->pull->missing, 0, sizeof(target->pull->missing)); in block_set()
286 LOG_DBG("%u size: %u chunks: %u", block_idx, cli->block.size, in block_set()
287 cli->block.chunk_count); in block_set()
292 cli->state = BT_MESH_BLOB_CLI_STATE_SUSPENDED; in suspend()
294 if (cli->cb && cli->cb->suspended) { in suspend()
295 cli->cb->suspended(cli); in suspend()
301 const struct bt_mesh_blob_xfer *xfer = cli->xfer; in end()
307 if (cli->cb && cli->cb->end) { in end()
308 cli->cb->end(cli, xfer, success); in end()
315 if (!(in->modes & cli->caps.modes)) { in caps_adjust()
319 if ((in->min_block_size_log > cli->caps.max_block_size_log) || in caps_adjust()
320 (in->max_block_size_log < cli->caps.min_block_size_log)) { in caps_adjust()
324 cli->caps.min_block_size_log = in caps_adjust()
325 MAX(cli->caps.min_block_size_log, in->min_block_size_log); in caps_adjust()
326 cli->caps.max_block_size_log = in caps_adjust()
327 MIN(cli->caps.max_block_size_log, in->max_block_size_log); in caps_adjust()
328 cli->caps.max_chunks = MIN(cli->caps.max_chunks, in->max_chunks); in caps_adjust()
329 cli->caps.mtu_size = MIN(cli->caps.mtu_size, in->mtu_size); in caps_adjust()
330 cli->caps.max_chunk_size = MIN(cli->caps.max_chunk_size, in->max_chunk_size); in caps_adjust()
331 cli->caps.modes &= in->modes; in caps_adjust()
332 cli->caps.max_size = MIN(cli->caps.max_size, in->max_size); in caps_adjust()
355 (sys_slist_t *)&cli->inputs->targets, *current, n); in next_target()
359 if ((*current)->acked || (*current)->procedure_complete || in next_target()
360 (*current)->status != BT_MESH_BLOB_SUCCESS || (*current)->timedout || in next_target()
361 (*current)->skip) { in next_target()
366 (k_uptime_get() < (*current)->pull->block_report_timestamp || in next_target()
367 !blob_chunk_missing_get((*current)->pull->missing, cli->chunk_idx))) { in next_target()
369 * the currently transmitted chunk (cli->chunk_idx). in next_target()
385 cli->tx.sending = 1U; in send()
387 cli->tx.ctx.send(cli, cli->tx.target->addr); in send()
389 cli->tx.ctx.send(cli, cli->inputs->group); in send()
395 LOG_DBG("%s", cli->tx.cancelled ? "cancelling" : "continuing"); in broadcast_complete()
397 cli->tx.ctx.is_inited = 0; in broadcast_complete()
398 k_work_cancel_delayable(&cli->tx.retry); in broadcast_complete()
400 if (cli->tx.cancelled) { in broadcast_complete()
403 __ASSERT(cli->tx.ctx.next, "No next callback"); in broadcast_complete()
404 cli->tx.ctx.next(cli); in broadcast_complete()
413 if (!cli->tx.ctx.is_inited || !cli->tx.sending) { in tx_complete()
417 cli->tx.sending = 0U; in tx_complete()
419 if (cli->tx.cancelled) { in tx_complete()
424 if (cli->tx.ctx.send_complete) { in tx_complete()
425 cli->tx.ctx.send_complete(cli, cli->tx.target->addr); in tx_complete()
428 if (UNICAST_MODE(cli) && next_target(cli, &cli->tx.target)) { in tx_complete()
433 if (cli->tx.ctx.acked && cli->tx.pending) { in tx_complete()
447 cli->tx.pending = 0; in drop_remaining_targets()
450 if (!target->acked && !target->timedout && !target->procedure_complete && in drop_remaining_targets()
451 !target->skip) { in drop_remaining_targets()
452 target->timedout = 1U; in drop_remaining_targets()
469 * non-responsive servers by cli_timestamp. By calling broadcast_complete(), client will in retry_timeout()
475 if (k_uptime_get() >= cli->tx.cli_timestamp) { in retry_timeout()
478 if (!cli->tx.ctx.optional) { in retry_timeout()
487 LOG_DBG("%u", cli->tx.retries); in retry_timeout()
489 cli->tx.retries--; in retry_timeout()
490 cli->tx.target = NULL; in retry_timeout()
492 __ASSERT(!cli->tx.sending, "still sending"); in retry_timeout()
493 __ASSERT(cli->tx.ctx.is_inited, "ctx is not initialized"); in retry_timeout()
495 if (!cli->tx.retries) { in retry_timeout()
498 if (!cli->tx.ctx.optional) { in retry_timeout()
506 if (!cli->tx.ctx.acked || !next_target(cli, &cli->tx.target) || cli->tx.cancelled) { in retry_timeout()
517 if (cli->tx.ctx.is_inited || cli->tx.sending) { in blob_cli_broadcast()
522 cli->tx.cancelled = 0U; in blob_cli_broadcast()
523 cli->tx.retries = CONFIG_BT_MESH_BLOB_CLI_BLOCK_RETRIES; in blob_cli_broadcast()
524 cli->tx.ctx = *ctx; in blob_cli_broadcast()
525 cli->tx.ctx.is_inited = 1U; in blob_cli_broadcast()
527 cli->tx.pending = targets_reset(cli); in blob_cli_broadcast()
529 LOG_DBG("%u targets", cli->tx.pending); in blob_cli_broadcast()
531 cli->tx.target = NULL; in blob_cli_broadcast()
532 if (!next_target(cli, &cli->tx.target)) { in blob_cli_broadcast()
543 k_work_schedule(&cli->tx.complete, K_MSEC(cli->tx.ctx.post_send_delay_ms)); in blob_cli_broadcast_tx_complete()
549 if (target->acked) { in blob_cli_broadcast_rsp()
553 LOG_DBG("0x%04x, pending: %d", target->addr, cli->tx.pending); in blob_cli_broadcast_rsp()
555 target->acked = 1U; in blob_cli_broadcast_rsp()
557 if (!--cli->tx.pending && !cli->tx.sending) { in blob_cli_broadcast_rsp()
564 if (!cli->tx.ctx.is_inited) { in blob_cli_broadcast_abort()
568 if ((cli)->state >= BT_MESH_BLOB_CLI_STATE_START) { in blob_cli_broadcast_abort()
586 .app_idx = cli->inputs->app_idx, in tx()
588 .send_ttl = cli->inputs->ttl, in tx()
592 err = bt_mesh_model_send(cli->mod, &ctx, buf, &end_cb, cli); in tx()
614 if (!cli->tx.ctx.is_inited) { in send_end()
637 net_buf_simple_add_u8(&buf, cli->xfer->mode << 6); in xfer_start_tx()
638 net_buf_simple_add_le64(&buf, cli->xfer->id); in xfer_start_tx()
639 net_buf_simple_add_le32(&buf, cli->xfer->size); in xfer_start_tx()
640 net_buf_simple_add_u8(&buf, cli->xfer->block_size_log); in xfer_start_tx()
658 net_buf_simple_add_le64(&buf, cli->xfer->id); in xfer_cancel_tx()
667 net_buf_simple_add_le16(&buf, cli->block.number); in block_start_tx()
668 net_buf_simple_add_le16(&buf, cli->xfer->chunk_size); in block_start_tx()
680 net_buf_simple_add_le16(&buf, cli->chunk_idx); in chunk_tx()
682 chunk.size = chunk_size(cli->xfer, &cli->block, cli->chunk_idx); in chunk_tx()
683 chunk.offset = cli->xfer->chunk_size * cli->chunk_idx; in chunk_tx()
686 err = cli->io->rd(cli->io, cli->xfer, &cli->block, &chunk); in chunk_tx()
687 if (err || cli->state == BT_MESH_BLOB_CLI_STATE_NONE) { in chunk_tx()
709 * .---------------------------------------.
711 * xfer_start -> block_set -> block_start -> chunk_send -> chunk_send_end |
714 * | [more missing chunks?]-----[Yes]-----+
720 * | .---[Push]---' '---[Pull]---. |
725 * | '-----------. .-------------' |
731 * | [block completed?]------[No]------'
736 * '-------------------[No]------------[last block sent?]
795 cli->state = BT_MESH_BLOB_CLI_STATE_CAPS_GET; in caps_get()
804 cli->state = BT_MESH_BLOB_CLI_STATE_NONE; in caps_collected()
809 if (target->status == BT_MESH_BLOB_SUCCESS) { in caps_collected()
816 (1UL << cli->caps.max_block_size_log) > in caps_collected()
817 (cli->caps.max_chunk_size * cli->caps.max_chunks)) { in caps_collected()
818 cli->caps.max_block_size_log--; in caps_collected()
821 if (cli->cb && cli->cb->caps) { in caps_collected()
822 cli->cb->caps(cli, success ? &cli->caps : NULL); in caps_collected()
837 return -EIO; in xfer_start()
840 cli->state = BT_MESH_BLOB_CLI_STATE_START; in xfer_start()
866 LOG_DBG("%u (%u chunks, %u/%u)", cli->block.number, in block_start()
867 cli->block.chunk_count, cli->block.number + 1, cli->block_count); in block_start()
869 cli->chunk_idx = 0; in block_start()
870 cli->state = BT_MESH_BLOB_CLI_STATE_BLOCK_START; in block_start()
875 cli->tx.cli_timestamp = 0ll; in block_start()
878 target->procedure_complete = 0U; in block_start()
880 if (cli->xfer->mode == BT_MESH_BLOB_XFER_MODE_PULL) { in block_start()
881 target->pull->block_report_timestamp = 0ll; in block_start()
885 if (cli->io->block_start) { in block_start()
886 cli->io->block_start(cli->io, cli->xfer, &cli->block); in block_start()
887 if (cli->state == BT_MESH_BLOB_CLI_STATE_NONE) { in block_start()
897 if (cli->xfer->mode != BT_MESH_BLOB_XFER_MODE_PULL) { in chunk_tx_complete()
904 uint16_t chunk_idx = next_missing_chunk(cli, cli->tx.target->pull->missing, in chunk_tx_complete()
905 cli->chunk_idx + 1); in chunk_tx_complete()
906 if (chunk_idx < cli->block.chunk_count) { in chunk_tx_complete()
921 target->pull->block_report_timestamp = timestamp; in chunk_tx_complete()
926 cli->tx.target->pull->block_report_timestamp = timestamp; in chunk_tx_complete()
935 .post_send_delay_ms = cli->chunk_interval_ms, in chunk_send()
938 if (cli->xfer->mode == BT_MESH_BLOB_XFER_MODE_PULL) { in chunk_send()
952 LOG_DBG("%u / %u size: %u", cli->chunk_idx + 1, cli->block.chunk_count, in chunk_send()
953 chunk_size(cli->xfer, &cli->block, cli->chunk_idx)); in chunk_send()
955 cli->state = BT_MESH_BLOB_CLI_STATE_BLOCK_SEND; in chunk_send()
965 if (cli->xfer->mode == BT_MESH_BLOB_XFER_MODE_PUSH) { in chunk_send_end()
966 blob_chunk_missing_set(cli->block.missing, cli->chunk_idx, false); in chunk_send_end()
969 cli->chunk_idx = next_missing_chunk(cli, cli->block.missing, cli->chunk_idx + 1); in chunk_send_end()
970 if (cli->chunk_idx < cli->block.chunk_count) { in chunk_send_end()
975 if (cli->xfer->mode == BT_MESH_BLOB_XFER_MODE_PUSH) { in chunk_send_end()
982 /* The block checking pair(block_check - block_check_end)
993 cli->state = BT_MESH_BLOB_CLI_STATE_BLOCK_CHECK; in block_check()
1008 if (next_missing_chunk(cli, cli->block.missing, 0) >= cli->block.chunk_count) { in block_report_wait()
1014 cli->tx.ctx = ctx; in block_report_wait()
1016 /* Start Client Timeout Timer in Send Data sub-procedure for the first time. */ in block_report_wait()
1017 if (!cli->tx.cli_timestamp) { in block_report_wait()
1018 cli->tx.cli_timestamp = k_uptime_get() + CLIENT_TIMEOUT_MSEC(cli); in block_report_wait()
1038 cli->chunk_idx = next_missing_chunk(cli, cli->block.missing, 0); in block_check_end()
1039 if (cli->chunk_idx < cli->block.chunk_count) { in block_check_end()
1044 LOG_DBG("No more missing chunks for block %u", cli->block.number); in block_check_end()
1046 if (cli->io->block_end) { in block_check_end()
1047 cli->io->block_end(cli->io, cli->xfer, &cli->block); in block_check_end()
1048 if (cli->state == BT_MESH_BLOB_CLI_STATE_NONE) { in block_check_end()
1053 if (cli->block.number == cli->block_count - 1) { in block_check_end()
1057 target->procedure_complete = 0U; in block_check_end()
1064 block_set(cli, cli->block.number + 1); in block_check_end()
1078 cli->state = BT_MESH_BLOB_CLI_STATE_XFER_CHECK; in confirm_transfer()
1087 cli->state = BT_MESH_BLOB_CLI_STATE_NONE; in progress_checked()
1089 if (cli->cb && cli->cb->end) { in progress_checked()
1090 cli->cb->xfer_progress_complete(cli); in progress_checked()
1104 cli->state = BT_MESH_BLOB_CLI_STATE_XFER_PROGRESS_GET; in check_transfer()
1119 cli->state = BT_MESH_BLOB_CLI_STATE_CANCEL; in transfer_cancel()
1127 cli->state == BT_MESH_BLOB_CLI_STATE_XFER_CHECK; in transfer_complete()
1140 if (cli->state != BT_MESH_BLOB_CLI_STATE_BLOCK_START && in rx_block_status()
1141 cli->state != BT_MESH_BLOB_CLI_STATE_BLOCK_SEND && in rx_block_status()
1142 cli->state != BT_MESH_BLOB_CLI_STATE_BLOCK_CHECK) { in rx_block_status()
1143 LOG_WRN("Invalid state %u", cli->state); in rx_block_status()
1147 LOG_DBG("0x%04x: block: %u status: %u", target->addr, block->block.number, block->status); in rx_block_status()
1149 if (block->status != BT_MESH_BLOB_SUCCESS) { in rx_block_status()
1150 target_drop(cli, target, block->status); in rx_block_status()
1155 if (block->block.number != cli->block.number) { in rx_block_status()
1156 LOG_DBG("Invalid block num (expected %u)", cli->block.number); in rx_block_status()
1160 if (block->missing == BT_MESH_BLOB_CHUNKS_MISSING_NONE) { in rx_block_status()
1161 target->procedure_complete = 1U; in rx_block_status()
1163 if (cli->xfer->mode == BT_MESH_BLOB_XFER_MODE_PULL) { in rx_block_status()
1164 memset(target->pull->missing, 0, sizeof(target->pull->missing)); in rx_block_status()
1168 LOG_DBG("Target 0x%04x received all chunks", target->addr); in rx_block_status()
1169 } else if (block->missing == BT_MESH_BLOB_CHUNKS_MISSING_ALL) { in rx_block_status()
1170 blob_chunk_missing_set_all(&cli->block); in rx_block_status()
1171 } else if (cli->xfer->mode == BT_MESH_BLOB_XFER_MODE_PULL) { in rx_block_status()
1172 memcpy(target->pull->missing, block->block.missing, sizeof(block->block.missing)); in rx_block_status()
1174 LOG_DBG("Missing: %s", bt_hex(target->pull->missing, cli->block.chunk_count)); in rx_block_status()
1181 target->pull->block_report_timestamp = 0ll; in rx_block_status()
1183 for (int i = 0; i < ARRAY_SIZE(block->block.missing); ++i) { in rx_block_status()
1184 cli->block.missing[i] |= block->block.missing[i]; in rx_block_status()
1189 if (!cli->tx.sending) { in rx_block_status()
1209 struct bt_mesh_blob_cli *cli = mod->rt->user_data; in handle_xfer_status()
1220 if (buf->len) { in handle_xfer_status()
1224 if (buf->len >= 7) { in handle_xfer_status()
1228 info.missing_blocks = net_buf_simple_pull(buf, buf->len); in handle_xfer_status()
1236 if (cli->state != BT_MESH_BLOB_CLI_STATE_START && in handle_xfer_status()
1237 cli->state != BT_MESH_BLOB_CLI_STATE_XFER_CHECK && in handle_xfer_status()
1238 cli->state != BT_MESH_BLOB_CLI_STATE_CANCEL && in handle_xfer_status()
1239 cli->state != BT_MESH_BLOB_CLI_STATE_XFER_PROGRESS_GET) { in handle_xfer_status()
1240 LOG_WRN("Wrong state: %d", cli->state); in handle_xfer_status()
1241 return -EBUSY; in handle_xfer_status()
1244 target = target_get(cli, ctx->addr); in handle_xfer_status()
1246 return -ENOENT; in handle_xfer_status()
1249 if (cli->state == BT_MESH_BLOB_CLI_STATE_START) { in handle_xfer_status()
1251 } else if (cli->state == BT_MESH_BLOB_CLI_STATE_XFER_CHECK) { in handle_xfer_status()
1253 } else if (cli->state != BT_MESH_BLOB_CLI_STATE_XFER_PROGRESS_GET) { in handle_xfer_status()
1255 } else { /* cli->state == BT_MESH_BLOB_CLI_STATE_XFER_PROGRESS_GET */ in handle_xfer_status()
1257 if (cli->cb && cli->cb->xfer_progress) { in handle_xfer_status()
1258 cli->cb->xfer_progress(cli, target, &info); in handle_xfer_status()
1267 return -EINVAL; in handle_xfer_status()
1269 info.id != cli->xfer->id) { in handle_xfer_status()
1281 struct bt_mesh_blob_cli *cli = mod->rt->user_data; in handle_block_report()
1284 .block.number = cli->block.number, in handle_block_report()
1285 .missing = (buf->len ? BT_MESH_BLOB_CHUNKS_MISSING_ENCODED : in handle_block_report()
1290 if (!cli->xfer) { in handle_block_report()
1291 return -EINVAL; in handle_block_report()
1294 if (cli->xfer->mode == BT_MESH_BLOB_XFER_MODE_PUSH) { in handle_block_report()
1296 return -EINVAL; in handle_block_report()
1301 target = target_get(cli, ctx->addr); in handle_block_report()
1303 return -ENOENT; in handle_block_report()
1306 while (buf->len) { in handle_block_report()
1320 if (next_missing_chunk(cli, target->pull->missing, 0) >= cli->block.chunk_count) { in handle_block_report()
1325 cli->tx.cli_timestamp = k_uptime_get() + CLIENT_TIMEOUT_MSEC(cli); in handle_block_report()
1335 struct bt_mesh_blob_cli *cli = mod->rt->user_data; in handle_block_status()
1343 target = target_get(cli, ctx->addr); in handle_block_status()
1345 return -ENOENT; in handle_block_status()
1354 DIV_ROUND_UP(cli->block.size, chunk_size); in handle_block_status()
1366 if (buf->len > sizeof(status.block.missing)) { in handle_block_status()
1367 return -EINVAL; in handle_block_status()
1370 len = buf->len; in handle_block_status()
1380 if (!buf->len) { in handle_block_status()
1384 while (buf->len) { in handle_block_status()
1388 return -EINVAL; in handle_block_status()
1406 struct bt_mesh_blob_cli *cli = mod->rt->user_data; in handle_info_status()
1411 if (cli->state != BT_MESH_BLOB_CLI_STATE_CAPS_GET) { in handle_info_status()
1412 return -EBUSY; in handle_info_status()
1428 return -EINVAL; in handle_info_status()
1431 LOG_DBG("0x%04x\n\tblock size: %u - %u\n\tchunks: %u\n\tchunk size: %u\n" in handle_info_status()
1433 ctx->addr, caps.min_block_size_log, caps.max_block_size_log, in handle_info_status()
1437 target = target_get(cli, ctx->addr); in handle_info_status()
1439 return -ENOENT; in handle_info_status()
1462 struct bt_mesh_blob_cli *cli = mod->rt->user_data; in blob_cli_init()
1464 cli->mod = mod; in blob_cli_init()
1467 cli->tx.cli_timestamp = 0ll; in blob_cli_init()
1468 k_work_init_delayable(&cli->tx.retry, retry_timeout); in blob_cli_init()
1469 k_work_init_delayable(&cli->tx.complete, tx_complete); in blob_cli_init()
1476 struct bt_mesh_blob_cli *cli = mod->rt->user_data; in blob_cli_reset()
1488 const struct bt_mesh_blob_cli_inputs *inputs) in bt_mesh_blob_cli_caps_get() argument
1491 return -EBUSY; in bt_mesh_blob_cli_caps_get()
1494 cli->inputs = inputs; in bt_mesh_blob_cli_caps_get()
1496 cli->caps.min_block_size_log = 0x06; in bt_mesh_blob_cli_caps_get()
1497 cli->caps.max_block_size_log = 0x20; in bt_mesh_blob_cli_caps_get()
1498 cli->caps.max_chunks = CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX; in bt_mesh_blob_cli_caps_get()
1499 cli->caps.max_chunk_size = BLOB_TX_CHUNK_SIZE; in bt_mesh_blob_cli_caps_get()
1500 cli->caps.max_size = 0xffffffff; in bt_mesh_blob_cli_caps_get()
1501 cli->caps.mtu_size = 0xffff; in bt_mesh_blob_cli_caps_get()
1502 cli->caps.modes = BT_MESH_BLOB_XFER_MODE_ALL; in bt_mesh_blob_cli_caps_get()
1506 return -ENODEV; in bt_mesh_blob_cli_caps_get()
1515 const struct bt_mesh_blob_cli_inputs *inputs, in bt_mesh_blob_cli_send() argument
1521 return -EBUSY; in bt_mesh_blob_cli_send()
1524 if (!(xfer->mode & BT_MESH_BLOB_XFER_MODE_ALL) || xfer->block_size_log < 0x06 || in bt_mesh_blob_cli_send()
1525 xfer->block_size_log > 0x20 || xfer->chunk_size < 8 || in bt_mesh_blob_cli_send()
1526 xfer->chunk_size > BLOB_TX_CHUNK_SIZE) { in bt_mesh_blob_cli_send()
1528 return -EINVAL; in bt_mesh_blob_cli_send()
1531 cli->xfer = xfer; in bt_mesh_blob_cli_send()
1532 cli->inputs = inputs; in bt_mesh_blob_cli_send()
1533 cli->io = io; in bt_mesh_blob_cli_send()
1535 if (cli->xfer->block_size_log == 0x20) { in bt_mesh_blob_cli_send()
1536 cli->block_count = 1; in bt_mesh_blob_cli_send()
1538 cli->block_count = DIV_ROUND_UP(cli->xfer->size, (1U << cli->xfer->block_size_log)); in bt_mesh_blob_cli_send()
1543 if (cli->block.chunk_count > CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX) { in bt_mesh_blob_cli_send()
1545 return -EINVAL; in bt_mesh_blob_cli_send()
1550 return -ENODEV; in bt_mesh_blob_cli_send()
1555 cli->xfer->block_size_log, cli->xfer->chunk_size, in bt_mesh_blob_cli_send()
1556 cli->xfer->size, cli->xfer->mode); in bt_mesh_blob_cli_send()
1563 if (cli->state == BT_MESH_BLOB_CLI_STATE_SUSPENDED) { in bt_mesh_blob_cli_suspend()
1567 if (cli->state != BT_MESH_BLOB_CLI_STATE_BLOCK_START && in bt_mesh_blob_cli_suspend()
1568 cli->state != BT_MESH_BLOB_CLI_STATE_BLOCK_SEND && in bt_mesh_blob_cli_suspend()
1569 cli->state != BT_MESH_BLOB_CLI_STATE_BLOCK_CHECK) { in bt_mesh_blob_cli_suspend()
1570 LOG_WRN("BLOB xfer not started: %d", cli->state); in bt_mesh_blob_cli_suspend()
1571 return -EINVAL; in bt_mesh_blob_cli_suspend()
1574 cli->state = BT_MESH_BLOB_CLI_STATE_SUSPENDED; in bt_mesh_blob_cli_suspend()
1575 (void)k_work_cancel_delayable(&cli->tx.retry); in bt_mesh_blob_cli_suspend()
1576 cli->tx.ctx.is_inited = 0; in bt_mesh_blob_cli_suspend()
1577 cli->tx.sending = 0; in bt_mesh_blob_cli_suspend()
1578 cli->tx.cli_timestamp = 0ll; in bt_mesh_blob_cli_suspend()
1586 if (cli->state != BT_MESH_BLOB_CLI_STATE_SUSPENDED) { in bt_mesh_blob_cli_resume()
1588 return -EINVAL; in bt_mesh_blob_cli_resume()
1593 if (!!target->timedout) { in bt_mesh_blob_cli_resume()
1594 target->status = BT_MESH_BLOB_SUCCESS; in bt_mesh_blob_cli_resume()
1595 target->timedout = 0U; in bt_mesh_blob_cli_resume()
1601 return -ENODEV; in bt_mesh_blob_cli_resume()
1617 if (cli->state == BT_MESH_BLOB_CLI_STATE_CAPS_GET || in bt_mesh_blob_cli_cancel()
1618 cli->state == BT_MESH_BLOB_CLI_STATE_SUSPENDED) { in bt_mesh_blob_cli_cancel()
1623 cli->tx.cancelled = 1U; in bt_mesh_blob_cli_cancel()
1624 cli->state = BT_MESH_BLOB_CLI_STATE_CANCEL; in bt_mesh_blob_cli_cancel()
1628 const struct bt_mesh_blob_cli_inputs *inputs) in bt_mesh_blob_cli_xfer_progress_get() argument
1631 return -EBUSY; in bt_mesh_blob_cli_xfer_progress_get()
1634 cli->inputs = inputs; in bt_mesh_blob_cli_xfer_progress_get()
1643 if (cli->state < BT_MESH_BLOB_CLI_STATE_START) { in bt_mesh_blob_cli_xfer_progress_active_get()
1647 return (100U * cli->block.number) / cli->block_count; in bt_mesh_blob_cli_xfer_progress_active_get()
1652 return cli->state != BT_MESH_BLOB_CLI_STATE_NONE; in bt_mesh_blob_cli_is_busy()
1657 cli->chunk_interval_ms = interval_ms; in bt_mesh_blob_cli_set_chunk_interval_ms()