Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for the nRF RPC entropy sample #12064

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/nrf_rpc/entropy_nrf53/cpuapp/src/entropy_ser.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ static void entropy_get_result_handler(const struct nrf_rpc_group *group,
}

memcpy(buf, zst.value, zst.len);
length = zst.len;

nrf_rpc_cbor_decoding_done(group, ctx);

Expand Down
29 changes: 12 additions & 17 deletions samples/nrf_rpc/entropy_nrf53/cpuapp/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@

static uint8_t buffer[BUFFER_LENGTH];

static void result_callback(int result, uint8_t *buffer, size_t length)
static void entropy_print(const uint8_t *buffer, size_t length)
{
size_t i;
for (size_t i = 0; i < length; i++) {
printk(" 0x%02x", buffer[i]);
}

printk("\n");
}

static void result_callback(int result, uint8_t *buffer, size_t length)
{
if (result) {
printk("Entropy remote get failed: %d\n", result);
return;
}

for (i = 0; i < length; i++) {
printk(" 0x%02x", buffer[i]);
}

printk("\n");
entropy_print(buffer, length);
}

int main(void)
Expand All @@ -53,11 +56,7 @@ int main(void)
continue;
}

for (int i = 0; i < BUFFER_LENGTH; i++) {
printk(" 0x%02x", buffer[i]);
}

printk("\n");
entropy_print(buffer, ARRAY_SIZE(buffer));

k_sleep(K_MSEC(2000));

Expand All @@ -67,11 +66,7 @@ int main(void)
continue;
}

for (int i = 0; i < BUFFER_LENGTH; i++) {
printk(" 0x%02x", buffer[i]);
}

printk("\n");
entropy_print(buffer, ARRAY_SIZE(buffer));

k_sleep(K_MSEC(2000));

Expand Down
12 changes: 12 additions & 0 deletions samples/nrf_rpc/entropy_nrf53/cpunet/src/entropy_ser.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ NRF_RPC_GROUP_DEFINE(entropy_group, "nrf_sample_entropy", &entropy_group_tr, NUL

static const struct device *entropy = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy));

static void entropy_print(const uint8_t *buffer, size_t length)
{
for (size_t i = 0; i < length; i++) {
printk(" 0x%02x", buffer[i]);
}

printk("\n");
}

static void rsp_error_code_send(const struct nrf_rpc_group *group, int err_code)
{
struct nrf_rpc_cbor_ctx ctx;
Expand Down Expand Up @@ -117,6 +126,9 @@ static void entropy_get_handler(const struct nrf_rpc_group *group, struct nrf_rp
}

err = entropy_get_entropy(entropy, buf, length);
if (!err) {
entropy_print(buf, length);
}

switch (type) {
case CALL_TYPE_STANDARD:
Expand Down
Loading