Skip to content

Commit badd82a

Browse files
committed
something
1 parent b1c169e commit badd82a

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

app/src/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,11 @@ static void triggering_run(void *o)
454454
}
455455

456456
if (msg.type == CLOUD_SHADOW_RESPONSE) {
457-
/* Missing: Parse the interval received in the shadow response,
458-
* write to state object and schedule new interval
459-
*/
457+
458+
/* Search through the msg.response.buffer and find the value of the interval */
459+
/* If the interval is different from the current interval, update the interval */
460+
/* and reschedule the trigger_work, Use the nrf cloud codec? */
461+
460462

461463
int err = k_work_reschedule(&trigger_work,
462464
K_SECONDS(state_object->interval_sec));

app/src/modules/cloud/cloud_module.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,22 @@ static void shadow_get(bool delta_only)
491491
return;
492492
}
493493

494-
/* No further processing of shadow is implemented */
494+
/* Send event CLOUD_SHADOW_RESPONSE with the buffer */
495+
struct cloud_msg msg = {
496+
.type = CLOUD_SHADOW_RESPONSE,
497+
};
498+
499+
__BUILD_ASSERT(sizeof(msg.response.buffer) >= sizeof(recv_buf),
500+
"Buffer size must be large enough to hold the received data");
501+
502+
memcpy(msg.response.buffer, recv_buf, recv_buf_len);
503+
msg.response.buffer_len = recv_buf_len;
504+
505+
err = zbus_chan_pub(&CLOUD_CHAN, &msg, K_SECONDS(1));
506+
if (err) {
507+
LOG_ERR("zbus_chan_pub, error: %d", err);
508+
SEND_FATAL_ERROR();
509+
}
495510
}
496511

497512
static void state_connected_ready_entry(void *o)

app/src/modules/cloud/cloud_module.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum cloud_msg_type {
4343
struct cloud_msg {
4444
enum cloud_msg_type type;
4545
struct cloud_payload payload;
46+
struct cloud_shadow_response response;
4647
};
4748

4849
#define MSG_TO_CLOUD_MSG(_msg) (*(const struct cloud_msg *)_msg)

0 commit comments

Comments
 (0)