diff options
author | Jean-François Milants <jf@codingfield.com> | 2021-03-07 08:44:14 +0100 |
---|---|---|
committer | Jean-François Milants <jf@codingfield.com> | 2021-03-07 08:44:14 +0100 |
commit | 9f67e6f6525bd4071609ff9edd6ce132d7ca1464 (patch) | |
tree | 65b2dc22bb257c6dd4fc8be77762173b564c340c /src/libs/mynewt-nimble/nimble/drivers/native | |
parent | 740b3d7b58dd92a6a6f99620a090ae4f05c03299 (diff) | |
parent | ada942535718d48eec37cca4f50d678e7201dc67 (diff) |
Merge branch 'develop' into recovery-firmware
# Conflicts:
# src/CMakeLists.txt
# src/displayapp/DisplayApp.h
# src/systemtask/SystemTask.cpp
# src/systemtask/SystemTask.h
Diffstat (limited to 'src/libs/mynewt-nimble/nimble/drivers/native')
-rw-r--r-- | src/libs/mynewt-nimble/nimble/drivers/native/src/ble_hw.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/libs/mynewt-nimble/nimble/drivers/native/src/ble_hw.c b/src/libs/mynewt-nimble/nimble/drivers/native/src/ble_hw.c index 5eb1eb95..8aa29d32 100644 --- a/src/libs/mynewt-nimble/nimble/drivers/native/src/ble_hw.c +++ b/src/libs/mynewt-nimble/nimble/drivers/native/src/ble_hw.c @@ -20,6 +20,8 @@ #include <stdint.h> #include <assert.h> #include <string.h> +#include <stdlib.h> +#include <stdbool.h> #include "syscfg/syscfg.h" #include "os/os.h" #include "nimble/ble.h" @@ -32,6 +34,9 @@ /* We use this to keep track of which entries are set to valid addresses */ static uint8_t g_ble_hw_whitelist_mask; +static ble_rng_isr_cb_t rng_cb; +static bool rng_started; + /* Returns public device address or -1 if not present */ int ble_hw_get_public_addr(ble_addr_t *addr) @@ -143,7 +148,8 @@ ble_hw_encrypt_block(struct ble_encryption_block *ecb) int ble_hw_rng_init(ble_rng_isr_cb_t cb, int bias) { - return -1; + rng_cb = cb; + return 0; } /** @@ -154,7 +160,15 @@ ble_hw_rng_init(ble_rng_isr_cb_t cb, int bias) int ble_hw_rng_start(void) { - return -1; + rng_started = true; + + if (rng_cb) { + while (rng_started) { + rng_cb(rand()); + } + } + + return 0; } /** @@ -165,7 +179,8 @@ ble_hw_rng_start(void) int ble_hw_rng_stop(void) { - return -1; + rng_started = false; + return 0; } /** @@ -176,7 +191,7 @@ ble_hw_rng_stop(void) uint8_t ble_hw_rng_read(void) { - return 0; + return rand(); } #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) |