summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2016-02-10 12:53:38 +0200
committerAnas Nashif <anas.nashif@intel.com>2016-02-10 19:13:01 -0500
commit36522ee71b98e09af1ea42d81a82e69bb4e2a49d (patch)
tree0a5cc18caa120159ba874423f50e5c3f70b21067 /samples
parent971af2b2495089e7f26166513c7a2d0cd74364c1 (diff)
Bluetooth: peripheral: Make heart rate simulation more predictable
sys_rand32_get appears to get stuck with same number for a while so instead just increment the heart rate by 1 until 160 and then return it back to 90. Change-Id: I2aea870c68539271a1bb6190a958a7e2d1914dc3 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Diffstat (limited to 'samples')
-rw-r--r--samples/bluetooth/peripheral/prj.conf1
-rw-r--r--samples/bluetooth/peripheral/prj_nble.conf1
-rw-r--r--samples/bluetooth/peripheral/src/main.c8
-rw-r--r--samples/bluetooth/peripheral_hr/prj.conf1
-rw-r--r--samples/bluetooth/peripheral_hr/prj_nble.conf1
-rw-r--r--samples/bluetooth/peripheral_hr/src/main.c8
6 files changed, 14 insertions, 6 deletions
diff --git a/samples/bluetooth/peripheral/prj.conf b/samples/bluetooth/peripheral/prj.conf
index 0cc037fbd..98d6d2ff0 100644
--- a/samples/bluetooth/peripheral/prj.conf
+++ b/samples/bluetooth/peripheral/prj.conf
@@ -1,4 +1,3 @@
-CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_LE=y
CONFIG_BLUETOOTH_DEBUG=y
diff --git a/samples/bluetooth/peripheral/prj_nble.conf b/samples/bluetooth/peripheral/prj_nble.conf
index ef0af4e30..ba9f2e8b1 100644
--- a/samples/bluetooth/peripheral/prj_nble.conf
+++ b/samples/bluetooth/peripheral/prj_nble.conf
@@ -1,4 +1,3 @@
-CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NBLE=y
CONFIG_ARC_INIT=n
CONFIG_BLUETOOTH_DEBUG=y
diff --git a/samples/bluetooth/peripheral/src/main.c b/samples/bluetooth/peripheral/src/main.c
index 21c5e5630..b13b7ad15 100644
--- a/samples/bluetooth/peripheral/src/main.c
+++ b/samples/bluetooth/peripheral/src/main.c
@@ -73,6 +73,7 @@ static int read_blsc(struct bt_conn *conn, const struct bt_gatt_attr *attr,
static struct bt_gatt_ccc_cfg blvl_ccc_cfg[CONFIG_BLUETOOTH_MAX_PAIRED] = {};
static uint8_t simulate_blvl = 0;
static uint8_t battery = 100;
+static uint8_t heartrate = 90;
static void blvl_ccc_cfg_changed(uint16_t value)
{
@@ -504,8 +505,13 @@ void main(void)
/* Heartrate measurements simulation */
if (simulate_hrm) {
+ heartrate++;
+ if (heartrate == 160) {
+ heartrate = 90;
+ }
+
hrm[0] = 0x06; /* uint8, sensor contact */
- hrm[1] = 90 + (sys_rand32_get() % 20);
+ hrm[1] = heartrate;
bt_gatt_notify(NULL, &hrs_attrs[2], &hrm, sizeof(hrm));
}
diff --git a/samples/bluetooth/peripheral_hr/prj.conf b/samples/bluetooth/peripheral_hr/prj.conf
index 8fef00b1d..9d1fa5d42 100644
--- a/samples/bluetooth/peripheral_hr/prj.conf
+++ b/samples/bluetooth/peripheral_hr/prj.conf
@@ -1,4 +1,3 @@
-CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_LE=y
CONFIG_BLUETOOTH_DEBUG=y
diff --git a/samples/bluetooth/peripheral_hr/prj_nble.conf b/samples/bluetooth/peripheral_hr/prj_nble.conf
index ef0af4e30..ba9f2e8b1 100644
--- a/samples/bluetooth/peripheral_hr/prj_nble.conf
+++ b/samples/bluetooth/peripheral_hr/prj_nble.conf
@@ -1,4 +1,3 @@
-CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NBLE=y
CONFIG_ARC_INIT=n
CONFIG_BLUETOOTH_DEBUG=y
diff --git a/samples/bluetooth/peripheral_hr/src/main.c b/samples/bluetooth/peripheral_hr/src/main.c
index f310ffdd9..040408e50 100644
--- a/samples/bluetooth/peripheral_hr/src/main.c
+++ b/samples/bluetooth/peripheral_hr/src/main.c
@@ -75,6 +75,7 @@ static int read_blsc(struct bt_conn *conn, const struct bt_gatt_attr *attr,
static struct bt_gatt_ccc_cfg blvl_ccc_cfg[CONFIG_BLUETOOTH_MAX_PAIRED] = {};
static uint8_t simulate_blvl;
static uint8_t battery = 100;
+static uint8_t heartrate = 90;
static void blvl_ccc_cfg_changed(uint16_t value)
{
@@ -262,8 +263,13 @@ void main(void)
/* Heartrate measurements simulation */
if (simulate_hrm) {
+ heartrate++;
+ if (heartrate == 160) {
+ heartrate = 90;
+ }
+
hrm[0] = 0x06; /* uint8, sensor contact */
- hrm[1] = 90 + (sys_rand32_get() % 20);
+ hrm[1] = heartrate;
bt_gatt_notify(default_conn, &hrs_attrs[2],
&hrm, sizeof(hrm));