From eb07178236a40d51949f4e7e26ca7d9e34976ec9 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 27 Jan 2017 15:41:59 +0200 Subject: [PATCH] Bluetooth: samples: Use Kconfig DEVICE_NAME variable when possible Instead of using a hard-coded string, make the sample use the Kconfig variable for the device name. Change-Id: Ib09f594e1cba221f9064318572bd90d38bd2733a Signed-off-by: Johan Hedberg --- samples/bluetooth/beacon/prj.conf | 1 + samples/bluetooth/beacon/prj_nble.conf | 1 + samples/bluetooth/beacon/src/main.c | 2 +- samples/bluetooth/eddystone/prj.conf | 1 + samples/bluetooth/eddystone/prj_nble.conf | 1 + samples/bluetooth/eddystone/src/main.c | 2 +- samples/bluetooth/gatt/ipss.c | 2 +- samples/bluetooth/ipsp/prj.conf | 1 + samples/bluetooth/peripheral/prj.conf | 1 + samples/bluetooth/peripheral/prj_nble.conf | 1 + samples/bluetooth/peripheral/src/main.c | 2 +- samples/bluetooth/peripheral_csc/prj.conf | 1 + samples/bluetooth/peripheral_csc/prj_nble.conf | 1 + samples/bluetooth/peripheral_csc/src/main.c | 2 +- samples/bluetooth/peripheral_dis/prj.conf | 1 + samples/bluetooth/peripheral_dis/src/main.c | 2 +- samples/bluetooth/peripheral_esp/prj.conf | 1 + samples/bluetooth/peripheral_esp/prj_nble.conf | 1 + samples/bluetooth/peripheral_esp/src/main.c | 2 +- samples/bluetooth/peripheral_hids/prj.conf | 1 + samples/bluetooth/peripheral_hids/prj_nble.conf | 1 + samples/bluetooth/peripheral_hids/src/main.c | 2 +- samples/bluetooth/peripheral_hr/prj.conf | 1 + samples/bluetooth/peripheral_hr/prj_nble.conf | 1 + samples/bluetooth/peripheral_hr/src/main.c | 2 +- samples/bluetooth/peripheral_sc_only/prj.conf | 1 + samples/bluetooth/peripheral_sc_only/src/main.c | 2 +- tests/bluetooth/shell/prj_nble.conf | 1 + tests/bluetooth/shell/src/main.c | 2 +- 29 files changed, 29 insertions(+), 11 deletions(-) diff --git a/samples/bluetooth/beacon/prj.conf b/samples/bluetooth/beacon/prj.conf index 86d640fbc87..4421133cdd1 100644 --- a/samples/bluetooth/beacon/prj.conf +++ b/samples/bluetooth/beacon/prj.conf @@ -1,2 +1,3 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_DEBUG_LOG=y +CONFIG_BLUETOOTH_DEVICE_NAME="Test beacon" diff --git a/samples/bluetooth/beacon/prj_nble.conf b/samples/bluetooth/beacon/prj_nble.conf index fa1c977c6e0..c564ced5861 100644 --- a/samples/bluetooth/beacon/prj_nble.conf +++ b/samples/bluetooth/beacon/prj_nble.conf @@ -2,3 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_CUSTOM=y CONFIG_NBLE=y CONFIG_BLUETOOTH_DEBUG_LOG=y +CONFIG_BLUETOOTH_DEVICE_NAME="Test beacon" diff --git a/samples/bluetooth/beacon/src/main.c b/samples/bluetooth/beacon/src/main.c index c122ad2f327..dfdd4e19c53 100644 --- a/samples/bluetooth/beacon/src/main.c +++ b/samples/bluetooth/beacon/src/main.c @@ -14,7 +14,7 @@ #include #include -#define DEVICE_NAME "Test beacon" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) /* diff --git a/samples/bluetooth/eddystone/prj.conf b/samples/bluetooth/eddystone/prj.conf index 4b7e9da2dff..093dc5fe5a7 100644 --- a/samples/bluetooth/eddystone/prj.conf +++ b/samples/bluetooth/eddystone/prj.conf @@ -2,3 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y +CONFIG_BLUETOOTH_DEVICE_NAME="Zephyr Eddystone" diff --git a/samples/bluetooth/eddystone/prj_nble.conf b/samples/bluetooth/eddystone/prj_nble.conf index fa1c977c6e0..a2e5c11cd35 100644 --- a/samples/bluetooth/eddystone/prj_nble.conf +++ b/samples/bluetooth/eddystone/prj_nble.conf @@ -2,3 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_CUSTOM=y CONFIG_NBLE=y CONFIG_BLUETOOTH_DEBUG_LOG=y +CONFIG_BLUETOOTH_DEVICE_NAME="Zephyr Eddystone" diff --git a/samples/bluetooth/eddystone/src/main.c b/samples/bluetooth/eddystone/src/main.c index 96d3ab7bf2b..de846469c76 100644 --- a/samples/bluetooth/eddystone/src/main.c +++ b/samples/bluetooth/eddystone/src/main.c @@ -21,7 +21,7 @@ #include #include -#define DEVICE_NAME "Zephyr Eddystone" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define NUMBER_OF_SLOTS 1 #define EDS_VERSION 0x00 diff --git a/samples/bluetooth/gatt/ipss.c b/samples/bluetooth/gatt/ipss.c index d2460802aef..9299d88da12 100644 --- a/samples/bluetooth/gatt/ipss.c +++ b/samples/bluetooth/gatt/ipss.c @@ -22,7 +22,7 @@ #include #include -#define DEVICE_NAME "Test IPSP node" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define UNKNOWN_APPEARANCE 0x0000 diff --git a/samples/bluetooth/ipsp/prj.conf b/samples/bluetooth/ipsp/prj.conf index c69c7026a36..e0ab82257d9 100644 --- a/samples/bluetooth/ipsp/prj.conf +++ b/samples/bluetooth/ipsp/prj.conf @@ -3,6 +3,7 @@ CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL=y +CONFIG_BLUETOOTH_DEVICE_NAME="Test IPSP node" CONFIG_NETWORKING=y CONFIG_NET_IPV6=y CONFIG_NET_IPV4=n diff --git a/samples/bluetooth/peripheral/prj.conf b/samples/bluetooth/peripheral/prj.conf index cf2033f46b7..ccb9c82cefd 100644 --- a/samples/bluetooth/peripheral/prj.conf +++ b/samples/bluetooth/peripheral/prj.conf @@ -6,3 +6,4 @@ CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_ATT_PREPARE_COUNT=2 CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y CONFIG_BLUETOOTH_PRIVACY=y +CONFIG_BLUETOOTH_DEVICE_NAME="Test peripheral" diff --git a/samples/bluetooth/peripheral/prj_nble.conf b/samples/bluetooth/peripheral/prj_nble.conf index 08982e79197..a1dd29d5efc 100644 --- a/samples/bluetooth/peripheral/prj_nble.conf +++ b/samples/bluetooth/peripheral/prj_nble.conf @@ -3,3 +3,4 @@ CONFIG_BLUETOOTH_CUSTOM=y CONFIG_NBLE=y CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_ATT_PREPARE_COUNT=2 +CONFIG_BLUETOOTH_DEVICE_NAME="Test peripheral" diff --git a/samples/bluetooth/peripheral/src/main.c b/samples/bluetooth/peripheral/src/main.c index 4b1f86e755b..019505b63a1 100644 --- a/samples/bluetooth/peripheral/src/main.c +++ b/samples/bluetooth/peripheral/src/main.c @@ -26,7 +26,7 @@ #include #include -#define DEVICE_NAME "Test peripheral" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define HEART_RATE_APPEARANCE 0x0341 diff --git a/samples/bluetooth/peripheral_csc/prj.conf b/samples/bluetooth/peripheral_csc/prj.conf index 765e4152542..0430a4fa5de 100644 --- a/samples/bluetooth/peripheral_csc/prj.conf +++ b/samples/bluetooth/peripheral_csc/prj.conf @@ -3,3 +3,4 @@ CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y +CONFIG_BLUETOOTH_DEVICE_NAME="CSC peripheral" diff --git a/samples/bluetooth/peripheral_csc/prj_nble.conf b/samples/bluetooth/peripheral_csc/prj_nble.conf index 33a4bce42ed..3459bb8df85 100644 --- a/samples/bluetooth/peripheral_csc/prj_nble.conf +++ b/samples/bluetooth/peripheral_csc/prj_nble.conf @@ -4,3 +4,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_CUSTOM=y CONFIG_NBLE=y CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEVICE_NAME="CSC peripheral" diff --git a/samples/bluetooth/peripheral_csc/src/main.c b/samples/bluetooth/peripheral_csc/src/main.c index 35e12c5d676..45ccc6045ff 100644 --- a/samples/bluetooth/peripheral_csc/src/main.c +++ b/samples/bluetooth/peripheral_csc/src/main.c @@ -25,7 +25,7 @@ #include #include -#define DEVICE_NAME "CSC peripheral" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define CSC_APPEARANCE 0x0485 #define CSC_SUPPORTED_LOCATIONS { CSC_LOC_OTHER, \ diff --git a/samples/bluetooth/peripheral_dis/prj.conf b/samples/bluetooth/peripheral_dis/prj.conf index a5e5b3bf58f..e3eb9f37224 100644 --- a/samples/bluetooth/peripheral_dis/prj.conf +++ b/samples/bluetooth/peripheral_dis/prj.conf @@ -1,3 +1,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y +CONFIG_BLUETOOTH_DEVICE_NAME="DIS peripheral" diff --git a/samples/bluetooth/peripheral_dis/src/main.c b/samples/bluetooth/peripheral_dis/src/main.c index 5b6bfe95bc4..9cafd06211e 100644 --- a/samples/bluetooth/peripheral_dis/src/main.c +++ b/samples/bluetooth/peripheral_dis/src/main.c @@ -23,7 +23,7 @@ #include #include -#define DEVICE_NAME "DIS peripheral" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define APPEARANCE 0x0000 diff --git a/samples/bluetooth/peripheral_esp/prj.conf b/samples/bluetooth/peripheral_esp/prj.conf index 169fb9c042c..90bd669b696 100644 --- a/samples/bluetooth/peripheral_esp/prj.conf +++ b/samples/bluetooth/peripheral_esp/prj.conf @@ -3,3 +3,4 @@ CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y CONFIG_BLUETOOTH_SMP=y CONFIG_TINYCRYPT=y +CONFIG_BLUETOOTH_DEVICE_NAME="ESP peripheral" diff --git a/samples/bluetooth/peripheral_esp/prj_nble.conf b/samples/bluetooth/peripheral_esp/prj_nble.conf index fa1c977c6e0..d1df4580a9a 100644 --- a/samples/bluetooth/peripheral_esp/prj_nble.conf +++ b/samples/bluetooth/peripheral_esp/prj_nble.conf @@ -2,3 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_CUSTOM=y CONFIG_NBLE=y CONFIG_BLUETOOTH_DEBUG_LOG=y +CONFIG_BLUETOOTH_DEVICE_NAME="ESP peripheral" diff --git a/samples/bluetooth/peripheral_esp/src/main.c b/samples/bluetooth/peripheral_esp/src/main.c index 1d52b3a3403..4893182d7de 100644 --- a/samples/bluetooth/peripheral_esp/src/main.c +++ b/samples/bluetooth/peripheral_esp/src/main.c @@ -25,7 +25,7 @@ #include #include -#define DEVICE_NAME "ESP peripheral" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define SENSOR_1_NAME "Temperature Sensor 1" #define SENSOR_2_NAME "Temperature Sensor 2" diff --git a/samples/bluetooth/peripheral_hids/prj.conf b/samples/bluetooth/peripheral_hids/prj.conf index a0075b07176..aa6f4b2ad0b 100644 --- a/samples/bluetooth/peripheral_hids/prj.conf +++ b/samples/bluetooth/peripheral_hids/prj.conf @@ -3,3 +3,4 @@ CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y +CONFIG_BLUETOOTH_DEVICE_NAME="Test HoG mouse" diff --git a/samples/bluetooth/peripheral_hids/prj_nble.conf b/samples/bluetooth/peripheral_hids/prj_nble.conf index fa1c977c6e0..7aaa8acbcf7 100644 --- a/samples/bluetooth/peripheral_hids/prj_nble.conf +++ b/samples/bluetooth/peripheral_hids/prj_nble.conf @@ -2,3 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_CUSTOM=y CONFIG_NBLE=y CONFIG_BLUETOOTH_DEBUG_LOG=y +CONFIG_BLUETOOTH_DEVICE_NAME="Test HoG mouse" diff --git a/samples/bluetooth/peripheral_hids/src/main.c b/samples/bluetooth/peripheral_hids/src/main.c index 21955075bea..015c584291f 100644 --- a/samples/bluetooth/peripheral_hids/src/main.c +++ b/samples/bluetooth/peripheral_hids/src/main.c @@ -25,7 +25,7 @@ #include #include -#define DEVICE_NAME "Test HoG mouse" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define HOG_APPEARANCE 0x03c2 diff --git a/samples/bluetooth/peripheral_hr/prj.conf b/samples/bluetooth/peripheral_hr/prj.conf index a0075b07176..99664fb1f69 100644 --- a/samples/bluetooth/peripheral_hr/prj.conf +++ b/samples/bluetooth/peripheral_hr/prj.conf @@ -3,3 +3,4 @@ CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y +CONFIG_BLUETOOTH_DEVICE_NAME="Zephyr Heartrate Sensor" diff --git a/samples/bluetooth/peripheral_hr/prj_nble.conf b/samples/bluetooth/peripheral_hr/prj_nble.conf index fa1c977c6e0..cb30e41520d 100644 --- a/samples/bluetooth/peripheral_hr/prj_nble.conf +++ b/samples/bluetooth/peripheral_hr/prj_nble.conf @@ -2,3 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_CUSTOM=y CONFIG_NBLE=y CONFIG_BLUETOOTH_DEBUG_LOG=y +CONFIG_BLUETOOTH_DEVICE_NAME="Zephyr Heartrate Sensor" diff --git a/samples/bluetooth/peripheral_hr/src/main.c b/samples/bluetooth/peripheral_hr/src/main.c index e23744b4c45..f003b202983 100644 --- a/samples/bluetooth/peripheral_hr/src/main.c +++ b/samples/bluetooth/peripheral_hr/src/main.c @@ -25,7 +25,7 @@ #include #include -#define DEVICE_NAME "Zephyr Heartrate Sensor" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define HEART_RATE_APPEARANCE 0x0341 diff --git a/samples/bluetooth/peripheral_sc_only/prj.conf b/samples/bluetooth/peripheral_sc_only/prj.conf index 8e866b56e73..03c24d0d229 100644 --- a/samples/bluetooth/peripheral_sc_only/prj.conf +++ b/samples/bluetooth/peripheral_sc_only/prj.conf @@ -4,3 +4,4 @@ CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_SMP_SC_ONLY=y CONFIG_BLUETOOTH_TINYCRYPT_ECC=y CONFIG_BLUETOOTH_MAX_PAIRED=2 +CONFIG_BLUETOOTH_DEVICE_NAME="SC only peripheral" diff --git a/samples/bluetooth/peripheral_sc_only/src/main.c b/samples/bluetooth/peripheral_sc_only/src/main.c index 0e7c250d89d..f1e172a5335 100644 --- a/samples/bluetooth/peripheral_sc_only/src/main.c +++ b/samples/bluetooth/peripheral_sc_only/src/main.c @@ -22,7 +22,7 @@ #include -#define DEVICE_NAME "SC only peripheral" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define APPEARANCE 0x0000 diff --git a/tests/bluetooth/shell/prj_nble.conf b/tests/bluetooth/shell/prj_nble.conf index 4d4a56c5572..5ea9350ab9f 100644 --- a/tests/bluetooth/shell/prj_nble.conf +++ b/tests/bluetooth/shell/prj_nble.conf @@ -6,3 +6,4 @@ CONFIG_CONSOLE_HANDLER=y CONFIG_CONSOLE_SHELL=y CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_ATT_PREPARE_COUNT=2 +CONFIG_BLUETOOTH_DEVICE_NAME="test shell" diff --git a/tests/bluetooth/shell/src/main.c b/tests/bluetooth/shell/src/main.c index be8e60c5d9a..21e5cc8b3de 100644 --- a/tests/bluetooth/shell/src/main.c +++ b/tests/bluetooth/shell/src/main.c @@ -34,7 +34,7 @@ #include #include -#define DEVICE_NAME "test shell" +#define DEVICE_NAME CONFIG_BLUETOOTH_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define CREDITS 10 #define DATA_MTU (23 * CREDITS)