From 5148ecb7f2c052bfb429d4060fbdf0f6bae7a4f9 Mon Sep 17 00:00:00 2001 From: Abhishek Sansanwal Date: Fri, 1 Feb 2019 09:12:36 +0530 Subject: [PATCH] Providing build option to disable BLE server Build option DISABLE_BLE_SERVER is added so that BLE server can be disabled when running in CLIENT_SERVER mode. Just provide DISABLE_BLE_SERVER = 1 option to disable it. https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/394 (cherry picked from ea611133c372df685cb58842dd6d7c06276d0aeb) Change-Id: I7552f378406e92b6c847cd73debfd31336d074a5 Signed-off-by: agrkush Signed-off-by: Kush Agrawal Signed-off-by: Abhishek Sansanwal --- build_common/SConscript | 4 ++++ packaging/iotivity.spec | 2 ++ resource/csdk/connectivity/SConscript | 8 ++++++++ resource/csdk/connectivity/build/SConscript | 1 + resource/csdk/connectivity/build/tizen/scons/SConscript | 4 ++++ resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c | 6 +++++- resource/csdk/stack/samples/tizen/SimpleClientServer/SConscript | 1 + resource/csdk/stack/samples/tizen/build/SConscript | 3 ++- resource/csdk/stack/samples/tizen/build/gbsbuild.sh | 5 ++++- resource/csdk/stack/samples/tizen/build/packaging/com.oic.ri.spec | 2 ++ resource/csdk/stack/samples/tizen/build/scons/SConscript | 7 +++++++ tools/tizen/iotivity-vd-tv-es-tizen30.spec | 2 ++ tools/tizen/iotivity-vd-tv-tizen30.spec | 2 ++ tools/tizen/iotivity.spec | 2 ++ 14 files changed, 46 insertions(+), 3 deletions(-) diff --git a/build_common/SConscript b/build_common/SConscript index 4a9a350..8612220 100644 --- a/build_common/SConscript +++ b/build_common/SConscript @@ -102,6 +102,7 @@ help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/broker', 'OFF', [ help_vars.Add(BoolVariable('WITH_CLOUD', 'Build including AccountManager class and Cloud Client sample', False)) help_vars.Add(ListVariable('RD_MODE', 'Resource Directory build mode', 'CLIENT', ['CLIENT', 'SERVER'])) help_vars.Add(BoolVariable('DISABLE_PRESENCE', 'Disable Presence Feature', False)) +help_vars.Add(BoolVariable('DISABLE_BLE_SERVER', 'Disable BLE server', False)) help_vars.Add(BoolVariable('SIMULATOR', 'Build with simulator module', False)) @@ -362,6 +363,9 @@ if env.get('DISABLE_TCP_SERVER'): if env.get('DISABLE_PRESENCE') == False: env.AppendUnique(CPPDEFINES = ['WITH_PRESENCE']) +if env.get('DISABLE_BLE_SERVER'): + defines.append('-DDISABLE_BLE_SERVER=1') + libs = [] if env.get('SECURED') == '1': defines.append('-D__WITH_DTLS__=1') diff --git a/packaging/iotivity.spec b/packaging/iotivity.spec index f5b7f60..764c963 100755 --- a/packaging/iotivity.spec +++ b/packaging/iotivity.spec @@ -86,6 +86,7 @@ Source1002: %{name}-test.manifest %{!?BLE_CUSTOM_ADV: %define BLE_CUSTOM_ADV False} %{!?BLE_DIVISION: %define BLE_DIVISION VD} %{!?BLE_TIZEN_30: %define BLE_TIZEN_30 True} +%{!?DISABLE_BLE_SERVER: %define DISABLE_BLE_SERVER 0} %{!?MULTIPLE_OWNER: %define MULTIPLE_OWNER 1} BuildRequires: expat-devel @@ -183,6 +184,7 @@ scons %{JOB} --prefix=%{_prefix} \ BLE_CUSTOM_ADV=%{BLE_CUSTOM_ADV} \ BLE_DIVISION=%{BLE_DIVISION} \ BLE_TIZEN_30=%{BLE_TIZEN_30} \ + DISABLE_BLE_SERVER=%{DISABLE_BLE_SERVER} \ MULTIPLE_OWNER=%{MULTIPLE_OWNER} \ #eol diff --git a/resource/csdk/connectivity/SConscript b/resource/csdk/connectivity/SConscript index a38cdbc..d5ebfe2 100644 --- a/resource/csdk/connectivity/SConscript +++ b/resource/csdk/connectivity/SConscript @@ -10,6 +10,7 @@ build_sample = env.get('BUILD_SAMPLE') with_ra = env.get('WITH_RA') with_tcp = env.get('WITH_TCP') disable_tcp_server = env.get('DISABLE_TCP_SERVER') +disable_ble_server = env.get('DISABLE_BLE_SERVER') with_mq = env.get('WITH_MQ') ble_custom_adv = env.get('BLE_CUSTOM_ADV') @@ -33,6 +34,9 @@ if 'ALL' in transport: env.AppendUnique(CPPDEFINES = ['TCP_ADAPTER']) if disable_tcp_server == True: env.AppendUnique(CPPDEFINES = ['DISABLE_TCP_SERVER']) + if disable_ble_server == True: + if target_os in ['tizen']: + env.AppendUnique(CPPDEFINES = ['DISABLE_BLE_SERVER']) if target_os in ['linux']: env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','NO_EDR_ADAPTER','LE_ADAPTER']) elif target_os == 'tizen': @@ -65,6 +69,10 @@ else: print "BLE Custom advertisement supported" else: print "BLE Custom advertisement not supported" + if disable_ble_server == True: + if target_os in ['tizen']: + env.AppendUnique(CPPDEFINES = ['DISABLE_BLE_SERVER']) + print "BLE Server Disabled" else: env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER']) diff --git a/resource/csdk/connectivity/build/SConscript b/resource/csdk/connectivity/build/SConscript index 6aaa3c0..05be021 100644 --- a/resource/csdk/connectivity/build/SConscript +++ b/resource/csdk/connectivity/build/SConscript @@ -67,6 +67,7 @@ help_vars.Add(EnumVariable('ROUTING', 'Enable routing', 'EP', allowed_values=('G help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF'))) help_vars.Add(BoolVariable('WITH_TCP', 'Enable TCP', False)) help_vars.Add(BoolVariable('DISABLE_TCP_SERVER', 'Disable TCP server', False)) +help_vars.Add(BoolVariable('DISABLE_BLE_SERVER', 'Disable BLE server', False)) help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/subscriber/broker', 'OFF', ['OFF', 'SUB', 'PUB', 'BROKER'])) help_vars.AddVariables(('DEVICE_NAME', 'Network display name for device', 'OIC-DEVICE', None, None),) diff --git a/resource/csdk/connectivity/build/tizen/scons/SConscript b/resource/csdk/connectivity/build/tizen/scons/SConscript index 6b6d55b..1042e31 100644 --- a/resource/csdk/connectivity/build/tizen/scons/SConscript +++ b/resource/csdk/connectivity/build/tizen/scons/SConscript @@ -10,6 +10,7 @@ target_os = env.get('TARGET_OS') transport = env.get('TARGET_TRANSPORT') with_tcp = env.get('WITH_TCP') disable_tcp_server = env.get('DISABLE_TCP_SERVER') +disable_ble_server = env.get('DISABLE_BLE_SERVER') print "Given Transport is %s" % transport @@ -57,6 +58,9 @@ else: env.AppendUnique(CPPDEFINES = ['DISABLE_TCP_SERVER']) print "TCP server is disabled" + if disable_ble_server == True: + env.AppendUnique(CPPDEFINES = ['DISABLE_BLE_SERVER']) + print "BLE server is disabled" env.SConscript(['../con/lib/libcoap-4.1.1/SConscript']) env.SConscript(['../con/SConscript']) diff --git a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c index f9d000b..78e4c12 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c @@ -2379,6 +2379,7 @@ static CAResult_t CALEAdapterClientSendData(const CAEndpoint_t *remoteEndpoint, static CAResult_t CALEAdapterGattServerStart() { OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "%s", __func__); + CAResult_t result = CA_STATUS_FAILED; if (caglobals.bleFlags & CA_LE_SERVER_DISABLE) { @@ -2387,7 +2388,10 @@ static CAResult_t CALEAdapterGattServerStart() return CA_STATUS_OK; } - CAResult_t result = CAStartLEGattServer(); +#ifndef DISABLE_BLE_SERVER + OIC_LOG_V(INFO, CALEADAPTER_TAG, "Starting LE GATT Server"); + result = CAStartLEGattServer(); +#endif #ifndef SINGLE_THREAD /* diff --git a/resource/csdk/stack/samples/tizen/SimpleClientServer/SConscript b/resource/csdk/stack/samples/tizen/SimpleClientServer/SConscript index 704e44f..a3f9fa7 100644 --- a/resource/csdk/stack/samples/tizen/SimpleClientServer/SConscript +++ b/resource/csdk/stack/samples/tizen/SimpleClientServer/SConscript @@ -60,6 +60,7 @@ help_vars.Add(BoolVariable('WITH_PROXY', 'CoAP-HTTP Proxy', False)) # set to 'no help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/subscriber/broker', 'OFF', ['OFF', 'SUB', 'PUB', 'BROKER'])) help_vars.Add(BoolVariable('WITH_TCP', 'Build with TCP', False)) help_vars.Add(BoolVariable('DISABLE_TCP_SERVER', 'Disable TCP server', False)) +help_vars.Add(BoolVariable('DISABLE_BLE_SERVER', 'Disable BLE server', True)) ###################################################################### # Platform(build target) specific options: SDK/NDK & toolchain diff --git a/resource/csdk/stack/samples/tizen/build/SConscript b/resource/csdk/stack/samples/tizen/build/SConscript index a2f27fa..225d617 100644 --- a/resource/csdk/stack/samples/tizen/build/SConscript +++ b/resource/csdk/stack/samples/tizen/build/SConscript @@ -16,6 +16,7 @@ routing = env.get('ROUTING') with_proxy = env.get('WITH_PROXY') with_tcp = env.get('WITH_TCP') with_mq = env.get('WITH_MQ') +disable_ble_server = env.get('DISABLE_BLE_SERVER') with_upstream_libcoap = env.get('WITH_UPSTREAM_LIBCOAP') if with_upstream_libcoap == '1': @@ -52,7 +53,7 @@ if (('BLE' in transport) or ('ALL' in transport)): gbs_command_prefix += "gbsprofile=tizen_4_0_unified_armv7l " if target_os == 'tizen': - command = gbs_command_prefix + "./resource/csdk/stack/samples/tizen/build/gbsbuild.sh %s %s %s %s %s %s %s %s %s" % (transport, secured, buildsample, release_mode, logging, routing, with_tcp, with_proxy, with_mq) + command = gbs_command_prefix + "./resource/csdk/stack/samples/tizen/build/gbsbuild.sh %s %s %s %s %s %s %s %s %s %s" % (transport, secured, buildsample, release_mode, logging, routing, with_tcp, with_proxy, with_mq, disable_ble_server) print "Created Command is %s" % command gbs_script = env.Command('gbs_build', None, command) AlwaysBuild ('gbs_script') diff --git a/resource/csdk/stack/samples/tizen/build/gbsbuild.sh b/resource/csdk/stack/samples/tizen/build/gbsbuild.sh index 8d761f0..141b8d8 100755 --- a/resource/csdk/stack/samples/tizen/build/gbsbuild.sh +++ b/resource/csdk/stack/samples/tizen/build/gbsbuild.sh @@ -36,6 +36,9 @@ export WITH_PROXY=$8 echo $9 export WITH_MQ=$9 +echo $10 +export DISABLE_BLE_SERVER=$10 + echo $TARGET_TRANSPORT echo $BUILD_SAMPLE echo $WITH_MQ @@ -110,7 +113,7 @@ nproc=$(expr 1 + $(expr `nproc --ignore=1` / 2 ) ) gbscommand_prefix=${gbscommand_prefix}" --define '_smp_mflags -j${nproc}'" echo "Calling core gbs build command" -gbscommand=${gbscommand_prefix}" -B ~/GBS-ROOT-RI-OIC --include-all --repository ./ --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --define 'ROUTING $6' --define 'WITH_TCP $7' --define 'WITH_PROXY $8' --define 'WITH_MQ $9'" +gbscommand=${gbscommand_prefix}" -B ~/GBS-ROOT-RI-OIC --include-all --repository ./ --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --define 'ROUTING $6' --define 'WITH_TCP $7' --define 'WITH_PROXY $8' --define 'WITH_MQ $9' --define 'DISABLE_BLE_SERVER $10'" echo $gbscommand if eval $gbscommand; then echo "Core build is successful" diff --git a/resource/csdk/stack/samples/tizen/build/packaging/com.oic.ri.spec b/resource/csdk/stack/samples/tizen/build/packaging/com.oic.ri.spec index 9f1cec9..dd16d6a 100644 --- a/resource/csdk/stack/samples/tizen/build/packaging/com.oic.ri.spec +++ b/resource/csdk/stack/samples/tizen/build/packaging/com.oic.ri.spec @@ -31,6 +31,7 @@ Source0: http://mirrors.kernel.org/%{name}/%{version}/%{name}-%{version}.tar.gz %{!?WITH_MQ: %define WITH_MQ OFF} %{!?WITH_PROXY: %define WITH_PROXY 0} %{!?WITH_TCP: %define WITH_TCP 0} +%{!?DISABLE_BLE_SERVER: %define DISABLE_BLE_SERVER 0} BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ttrace) @@ -62,6 +63,7 @@ scons %{JOB} --prefix=%{_prefix} \ VERBOSE=%{VERBOSE} \ WITH_MQ=%{WITH_MQ} \ WITH_PROXY=%{WITH_PROXY} \ + DISABLE_BLE_SERVER=%{DISABLE_BLE_SERVER} \ WITH_TCP=%{WITH_TCP} \ #eol diff --git a/resource/csdk/stack/samples/tizen/build/scons/SConscript b/resource/csdk/stack/samples/tizen/build/scons/SConscript index 46e24be..1390ace 100644 --- a/resource/csdk/stack/samples/tizen/build/scons/SConscript +++ b/resource/csdk/stack/samples/tizen/build/scons/SConscript @@ -9,6 +9,7 @@ Import('env') target_os = env.get('TARGET_OS') transport = env.get('TARGET_TRANSPORT') with_mq = env.get('WITH_MQ') +disable_ble_server = env.get('DISABLE_BLE_SERVER') print "Given Transport is %s" % transport @@ -27,6 +28,9 @@ if env.get('OIC_SUPPORT_TIZEN_TRACE') == 'True': if 'ALL' in transport: env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER']) print "CA Transport is ALL" + if env.get('DISABLE_BLE_SERVER'): + env.AppendUnique(CPPDEFINES = ['DISABLE_BLE_SERVER']) + print "BLE Server Disabled" else: if 'BT' in transport: env.AppendUnique(CPPDEFINES = ['EDR_ADAPTER']) @@ -37,6 +41,9 @@ else: if 'BLE' in transport: env.AppendUnique(CPPDEFINES = ['LE_ADAPTER']) print "CA Transport is BLE" + if env.get('DISABLE_BLE_SERVER'): + env.AppendUnique(CPPDEFINES = ['DISABLE_BLE_SERVER']) + print "BLE Server Disabled" else: env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER']) diff --git a/tools/tizen/iotivity-vd-tv-es-tizen30.spec b/tools/tizen/iotivity-vd-tv-es-tizen30.spec index 7b4ce2f..97da3c7 100644 --- a/tools/tizen/iotivity-vd-tv-es-tizen30.spec +++ b/tools/tizen/iotivity-vd-tv-es-tizen30.spec @@ -84,6 +84,7 @@ Source1002: %{name}-test.manifest %{!?BLE_CUSTOM_ADV: %define BLE_CUSTOM_ADV False} %{!?BLE_DIVISION: %define BLE_DIVISION VD} %{!?BLE_TIZEN_30: %define BLE_TIZEN_30 True} +%{!?DISABLE_BLE_SERVER: %define DISABLE_BLE_SERVER 0} %{!?MULTIPLE_OWNER: %define MULTIPLE_OWNER 0} BuildRequires: expat-devel @@ -181,6 +182,7 @@ scons %{JOB} --prefix=%{_prefix} \ BLE_CUSTOM_ADV=%{BLE_CUSTOM_ADV} \ BLE_DIVISION=%{BLE_DIVISION} \ BLE_TIZEN_30=%{BLE_TIZEN_30} \ + DISABLE_BLE_SERVER=%{DISABLE_BLE_SERVER} \ MULTIPLE_OWNER=%{MULTIPLE_OWNER} \ #eol diff --git a/tools/tizen/iotivity-vd-tv-tizen30.spec b/tools/tizen/iotivity-vd-tv-tizen30.spec index 557c55d..8c6bd80 100644 --- a/tools/tizen/iotivity-vd-tv-tizen30.spec +++ b/tools/tizen/iotivity-vd-tv-tizen30.spec @@ -84,6 +84,7 @@ Source1002: %{name}-test.manifest %{!?BLE_CUSTOM_ADV: %define BLE_CUSTOM_ADV False} %{!?BLE_DIVISION: %define BLE_DIVISION VD} %{!?BLE_TIZEN_30: %define BLE_TIZEN_30 True} +%{!?DISABLE_BLE_SERVER: %define DISABLE_BLE_SERVER 0} %{!?MULTIPLE_OWNER: %define MULTIPLE_OWNER 0} BuildRequires: expat-devel @@ -181,6 +182,7 @@ scons %{JOB} --prefix=%{_prefix} \ BLE_CUSTOM_ADV=%{BLE_CUSTOM_ADV} \ BLE_DIVISION=%{BLE_DIVISION} \ BLE_TIZEN_30=%{BLE_TIZEN_30} \ + DISABLE_BLE_SERVER=%{DISABLE_BLE_SERVER} \ MULTIPLE_OWNER=%{MULTIPLE_OWNER} \ #eol diff --git a/tools/tizen/iotivity.spec b/tools/tizen/iotivity.spec index 903a32b..e571f22 100644 --- a/tools/tizen/iotivity.spec +++ b/tools/tizen/iotivity.spec @@ -83,6 +83,7 @@ Source1002: %{name}-test.manifest %{!?BLE_CUSTOM_ADV: %define BLE_CUSTOM_ADV False} %{!?BLE_DIVISION: %define BLE_DIVISION VD} %{!?BLE_TIZEN_30: %define BLE_TIZEN_30 True} +%{!?DISABLE_BLE_SERVER: %define DISABLE_BLE_SERVER 0} %{!?MULTIPLE_OWNER: %define MULTIPLE_OWNER 0} BuildRequires: expat-devel @@ -179,6 +180,7 @@ scons %{JOB} --prefix=%{_prefix} \ BLE_CUSTOM_ADV=%{BLE_CUSTOM_ADV} \ BLE_DIVISION=%{BLE_DIVISION} \ BLE_TIZEN_30=%{BLE_TIZEN_30} \ + DISABLE_BLE_SERVER=%{DISABLE_BLE_SERVER} \ MULTIPLE_OWNER=%{MULTIPLE_OWNER} \ #eol -- 2.7.4