This patch adds possibility to start BlueZ only in LE mode only.
It is useful for testing purpose, when you want test BlueZ in
peripheral mode against any dual mode device.
---
android/README | 3 +++
android/bluetooth.c | 7 ++++++-
android/hal-bluetooth.c | 15 ++++++++++++++-
android/hal-msg.h | 1 +
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/android/README b/android/README
index 6254d34..9b08610 100644
--- a/android/README
+++ b/android/README
@@ -166,6 +166,9 @@ options.
Property Value Description
-------------------------------------------
+mode le_only Enable BlueZ in Low Energy mode only.
+ <none> Enable BlueZ in default mode - enable br/edr/le
+ if possible.
handsfree hfp Enable Handsfree Profile (HFP) with narrowband
speech only
hfp_wbs Enable Handsfree Profile (HFP) with narrowband
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 93c7935..923285c 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -3894,10 +3894,15 @@ static const struct ipc_handler cmd_handlers[] = {
void bt_bluetooth_register(struct ipc *ipc, uint8_t mode)
{
- DBG("");
+ DBG("mode 0x%x", mode);
hal_ipc = ipc;
+ if ((mode == HAL_MODE_LE_ONLY) &&
+ (adapter.current_settings & MGMT_SETTING_LE) &&
+ (adapter.current_settings & MGMT_SETTING_BREDR))
+ set_mode(MGMT_OP_SET_BREDR, 0x00);
+
ipc_register(hal_ipc, HAL_SERVICE_ID_BLUETOOTH, cmd_handlers,
G_N_ELEMENTS(cmd_handlers));
}
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 48d5ea2..69009ff 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -29,6 +29,8 @@
#include "hal-ipc.h"
#include "hal-utils.h"
+#define MODE_PROPERTY_NAME "persist.sys.bluetooth.mode"
+
static const bt_callbacks_t *bt_hal_cbacks = NULL;
#define enum_prop_to_hal(prop, hal_prop, type) do { \
@@ -412,6 +414,17 @@ static const struct hal_ipc_handler ev_handlers[] = {
}
};
+static uint8_t get_mode(void)
+{
+ char value[PROPERTY_VALUE_MAX];
+
+ if (property_get(MODE_PROPERTY_NAME, value, "") > 0 &&
+ (!strcasecmp(value, "le_only")))
+ return HAL_MODE_LE_ONLY;
+
+ return HAL_MODE_DEFAULT;
+}
+
static int init(bt_callbacks_t *callbacks)
{
struct hal_cmd_register_module cmd;
@@ -433,7 +446,7 @@ static int init(bt_callbacks_t *callbacks)
}
cmd.service_id = HAL_SERVICE_ID_BLUETOOTH;
- cmd.mode = HAL_MODE_DEFAULT;
+ cmd.mode = get_mode();
status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
sizeof(cmd), &cmd, NULL, NULL, NULL);
diff --git a/android/hal-msg.h b/android/hal-msg.h
index ed0a67a..db21870 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -55,6 +55,7 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
#define HAL_OP_STATUS IPC_OP_STATUS
#define HAL_MODE_DEFAULT 0x00
+#define HAL_MODE_LE_ONLY 0x01
#define HAL_OP_REGISTER_MODULE 0x01
struct hal_cmd_register_module {
--
1.8.4
Hi Lukasz,
>>> This patch adds possibility to start BlueZ only in LE mode only.
>>>
>>> It is useful for testing purpose, when you want test BlueZ in
>>> peripheral mode against any dual mode device.
>>> ---
>>> android/README | 3 +++
>>> android/bluetooth.c | 7 ++++++-
>>> android/hal-bluetooth.c | 15 ++++++++++++++-
>>> android/hal-msg.h | 1 +
>>> 4 files changed, 24 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/android/README b/android/README
>>> index 6254d34..9b08610 100644
>>> --- a/android/README
>>> +++ b/android/README
>>> @@ -166,6 +166,9 @@ options.
>>>
>>> Property Value Description
>>> -------------------------------------------
>>> +mode le_only Enable BlueZ in Low Energy mode only.
>>> + <none> Enable BlueZ in default mode - enable br/edr/le
>>> + if possible.
>>
>> we better do ?bredr? and ?le? here.
>
>> If left empty it will default to auto detect mode with BR/EDR and LE enabled if available with your kernel and supported by the controller.
>>
> Yes this is exactly how it works.
>
>> There might be actually an use case where you have a dual-mode controller, but want to just only use BR/EDR. It will be especially hard to fine BR/EDR only controllers.
>>
> It's true.
> I started with le_only as I need that now. I left br/edr only case for
> the time somebody will need it as it is easy to extend.
> If you want it now, I will add it.
lets do it now. 0x00 = default/auto, 0x01 = bredr, 0x02 = le.
Regards
Marcel
Hi Marcel,
On 23 April 2014 02:29, Marcel Holtmann <[email protected]> wrote:
> Hi Lukasz,
>
>> This patch adds possibility to start BlueZ only in LE mode only.
>>
>> It is useful for testing purpose, when you want test BlueZ in
>> peripheral mode against any dual mode device.
>> ---
>> android/README | 3 +++
>> android/bluetooth.c | 7 ++++++-
>> android/hal-bluetooth.c | 15 ++++++++++++++-
>> android/hal-msg.h | 1 +
>> 4 files changed, 24 insertions(+), 2 deletions(-)
>>
>> diff --git a/android/README b/android/README
>> index 6254d34..9b08610 100644
>> --- a/android/README
>> +++ b/android/README
>> @@ -166,6 +166,9 @@ options.
>>
>> Property Value Description
>> -------------------------------------------
>> +mode le_only Enable BlueZ in Low Energy mode only.
>> + <none> Enable BlueZ in default mode - enable br/e=
dr/le
>> + if possible.
>
> we better do =E2=80=9Cbredr=E2=80=9D and =E2=80=9Cle=E2=80=9D here.
> If left empty it will default to auto detect mode with BR/EDR and LE enab=
led if available with your kernel and supported by the controller.
>
Yes this is exactly how it works.
> There might be actually an use case where you have a dual-mode controller=
, but want to just only use BR/EDR. It will be especially hard to fine BR/E=
DR only controllers.
>
It's true.
I started with le_only as I need that now. I left br/edr only case for
the time somebody will need it as it is easy to extend.
If you want it now, I will add it.
> Regards
>
> Marcel
>
BR
\=C5=81ukasz
Hi Lukasz,
> This patch adds possibility to start BlueZ only in LE mode only.
>
> It is useful for testing purpose, when you want test BlueZ in
> peripheral mode against any dual mode device.
> ---
> android/README | 3 +++
> android/bluetooth.c | 7 ++++++-
> android/hal-bluetooth.c | 15 ++++++++++++++-
> android/hal-msg.h | 1 +
> 4 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/android/README b/android/README
> index 6254d34..9b08610 100644
> --- a/android/README
> +++ b/android/README
> @@ -166,6 +166,9 @@ options.
>
> Property Value Description
> -------------------------------------------
> +mode le_only Enable BlueZ in Low Energy mode only.
> + <none> Enable BlueZ in default mode - enable br/edr/le
> + if possible.
we better do ?bredr? and ?le? here. If left empty it will default to auto detect mode with BR/EDR and LE enabled if available with your kernel and supported by the controller.
There might be actually an use case where you have a dual-mode controller, but want to just only use BR/EDR. It will be especially hard to fine BR/EDR only controllers.
Regards
Marcel
Hi David,
On Sun, May 25, 2014 at 5:38 PM, <[email protected]> wrote:
> Hi Lukasz,
>
> Maybe unrelated, but I'm looking for a way to enforce BlueZ to run LE only (central) under linux 3.13.
> btmgmt bredr seems to do this, but could I do it via some "config-level" setting to ensure no one on the system can initiate anything else than LE related things.
>
AFAIK For now it is possible only for Android version.
For "normal" BlueZ you need to extend BlueZ daemon. Probably add
special config to main.conf and add similar handling it as we did for
Android.
> best David
>
BR
Lukasz
> On 23 Apr 2014, at 00:16, Lukasz Rymanowski <[email protected]> wrote:
>
>> This patch adds possibility to start BlueZ only in LE mode only.
>>
>> It is useful for testing purpose, when you want test BlueZ in
>> peripheral mode against any dual mode device.
>> ---
>> android/README | 3 +++
>> android/bluetooth.c | 7 ++++++-
>> android/hal-bluetooth.c | 15 ++++++++++++++-
>> android/hal-msg.h | 1 +
>> 4 files changed, 24 insertions(+), 2 deletions(-)
>>
>> diff --git a/android/README b/android/README
>> index 6254d34..9b08610 100644
>> --- a/android/README
>> +++ b/android/README
>> @@ -166,6 +166,9 @@ options.
>>
>> Property Value Description
>> -------------------------------------------
>> +mode le_only Enable BlueZ in Low Energy mode only.
>> + <none> Enable BlueZ in default mode - enable br/edr/le
>> + if possible.
>> handsfree hfp Enable Handsfree Profile (HFP) with narrowband
>> speech only
>> hfp_wbs Enable Handsfree Profile (HFP) with narrowband
>> diff --git a/android/bluetooth.c b/android/bluetooth.c
>> index 93c7935..923285c 100644
>> --- a/android/bluetooth.c
>> +++ b/android/bluetooth.c
>> @@ -3894,10 +3894,15 @@ static const struct ipc_handler cmd_handlers[] = {
>>
>> void bt_bluetooth_register(struct ipc *ipc, uint8_t mode)
>> {
>> - DBG("");
>> + DBG("mode 0x%x", mode);
>>
>> hal_ipc = ipc;
>>
>> + if ((mode == HAL_MODE_LE_ONLY) &&
>> + (adapter.current_settings & MGMT_SETTING_LE) &&
>> + (adapter.current_settings & MGMT_SETTING_BREDR))
>> + set_mode(MGMT_OP_SET_BREDR, 0x00);
>> +
>> ipc_register(hal_ipc, HAL_SERVICE_ID_BLUETOOTH, cmd_handlers,
>> G_N_ELEMENTS(cmd_handlers));
>> }
>> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
>> index 48d5ea2..69009ff 100644
>> --- a/android/hal-bluetooth.c
>> +++ b/android/hal-bluetooth.c
>> @@ -29,6 +29,8 @@
>> #include "hal-ipc.h"
>> #include "hal-utils.h"
>>
>> +#define MODE_PROPERTY_NAME "persist.sys.bluetooth.mode"
>> +
>> static const bt_callbacks_t *bt_hal_cbacks = NULL;
>>
>> #define enum_prop_to_hal(prop, hal_prop, type) do { \
>> @@ -412,6 +414,17 @@ static const struct hal_ipc_handler ev_handlers[] = {
>> }
>> };
>>
>> +static uint8_t get_mode(void)
>> +{
>> + char value[PROPERTY_VALUE_MAX];
>> +
>> + if (property_get(MODE_PROPERTY_NAME, value, "") > 0 &&
>> + (!strcasecmp(value, "le_only")))
>> + return HAL_MODE_LE_ONLY;
>> +
>> + return HAL_MODE_DEFAULT;
>> +}
>> +
>> static int init(bt_callbacks_t *callbacks)
>> {
>> struct hal_cmd_register_module cmd;
>> @@ -433,7 +446,7 @@ static int init(bt_callbacks_t *callbacks)
>> }
>>
>> cmd.service_id = HAL_SERVICE_ID_BLUETOOTH;
>> - cmd.mode = HAL_MODE_DEFAULT;
>> + cmd.mode = get_mode();
>>
>> status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
>> sizeof(cmd), &cmd, NULL, NULL, NULL);
>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>> index ed0a67a..db21870 100644
>> --- a/android/hal-msg.h
>> +++ b/android/hal-msg.h
>> @@ -55,6 +55,7 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
>> #define HAL_OP_STATUS IPC_OP_STATUS
>>
>> #define HAL_MODE_DEFAULT 0x00
>> +#define HAL_MODE_LE_ONLY 0x01
>>
>> #define HAL_OP_REGISTER_MODULE 0x01
>> struct hal_cmd_register_module {
>> --
>> 1.8.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Lukasz,
Maybe unrelated, but I'm looking for a way to enforce BlueZ to run LE only (central) under linux 3.13.
btmgmt bredr seems to do this, but could I do it via some "config-level" setting to ensure no one on the system can initiate anything else than LE related things.
best David
On 23 Apr 2014, at 00:16, Lukasz Rymanowski <[email protected]> wrote:
> This patch adds possibility to start BlueZ only in LE mode only.
>
> It is useful for testing purpose, when you want test BlueZ in
> peripheral mode against any dual mode device.
> ---
> android/README | 3 +++
> android/bluetooth.c | 7 ++++++-
> android/hal-bluetooth.c | 15 ++++++++++++++-
> android/hal-msg.h | 1 +
> 4 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/android/README b/android/README
> index 6254d34..9b08610 100644
> --- a/android/README
> +++ b/android/README
> @@ -166,6 +166,9 @@ options.
>
> Property Value Description
> -------------------------------------------
> +mode le_only Enable BlueZ in Low Energy mode only.
> + <none> Enable BlueZ in default mode - enable br/edr/le
> + if possible.
> handsfree hfp Enable Handsfree Profile (HFP) with narrowband
> speech only
> hfp_wbs Enable Handsfree Profile (HFP) with narrowband
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 93c7935..923285c 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -3894,10 +3894,15 @@ static const struct ipc_handler cmd_handlers[] = {
>
> void bt_bluetooth_register(struct ipc *ipc, uint8_t mode)
> {
> - DBG("");
> + DBG("mode 0x%x", mode);
>
> hal_ipc = ipc;
>
> + if ((mode == HAL_MODE_LE_ONLY) &&
> + (adapter.current_settings & MGMT_SETTING_LE) &&
> + (adapter.current_settings & MGMT_SETTING_BREDR))
> + set_mode(MGMT_OP_SET_BREDR, 0x00);
> +
> ipc_register(hal_ipc, HAL_SERVICE_ID_BLUETOOTH, cmd_handlers,
> G_N_ELEMENTS(cmd_handlers));
> }
> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
> index 48d5ea2..69009ff 100644
> --- a/android/hal-bluetooth.c
> +++ b/android/hal-bluetooth.c
> @@ -29,6 +29,8 @@
> #include "hal-ipc.h"
> #include "hal-utils.h"
>
> +#define MODE_PROPERTY_NAME "persist.sys.bluetooth.mode"
> +
> static const bt_callbacks_t *bt_hal_cbacks = NULL;
>
> #define enum_prop_to_hal(prop, hal_prop, type) do { \
> @@ -412,6 +414,17 @@ static const struct hal_ipc_handler ev_handlers[] = {
> }
> };
>
> +static uint8_t get_mode(void)
> +{
> + char value[PROPERTY_VALUE_MAX];
> +
> + if (property_get(MODE_PROPERTY_NAME, value, "") > 0 &&
> + (!strcasecmp(value, "le_only")))
> + return HAL_MODE_LE_ONLY;
> +
> + return HAL_MODE_DEFAULT;
> +}
> +
> static int init(bt_callbacks_t *callbacks)
> {
> struct hal_cmd_register_module cmd;
> @@ -433,7 +446,7 @@ static int init(bt_callbacks_t *callbacks)
> }
>
> cmd.service_id = HAL_SERVICE_ID_BLUETOOTH;
> - cmd.mode = HAL_MODE_DEFAULT;
> + cmd.mode = get_mode();
>
> status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
> sizeof(cmd), &cmd, NULL, NULL, NULL);
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index ed0a67a..db21870 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -55,6 +55,7 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
> #define HAL_OP_STATUS IPC_OP_STATUS
>
> #define HAL_MODE_DEFAULT 0x00
> +#define HAL_MODE_LE_ONLY 0x01
>
> #define HAL_OP_REGISTER_MODULE 0x01
> struct hal_cmd_register_module {
> --
> 1.8.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Do you or you know someone that could be up for the job?
best david
On 25 May 2014, at 22:34, Lukasz Rymanowski <[email protected]> wrote:
> Hi David,
>
> On Sun, May 25, 2014 at 5:38 PM, <[email protected]> wrote:
>> Hi Lukasz,
>>
>> Maybe unrelated, but I'm looking for a way to enforce BlueZ to run LE only (central) under linux 3.13.
>> btmgmt bredr seems to do this, but could I do it via some "config-level" setting to ensure no one on the system can initiate anything else than LE related things.
>>
>
> AFAIK For now it is possible only for Android version.
> For "normal" BlueZ you need to extend BlueZ daemon. Probably add
> special config to main.conf and add similar handling it as we did for
> Android.
>
>> best David
>>
>
> BR
> Lukasz
>
>> On 23 Apr 2014, at 00:16, Lukasz Rymanowski <[email protected]> wrote:
>>
>>> This patch adds possibility to start BlueZ only in LE mode only.
>>>
>>> It is useful for testing purpose, when you want test BlueZ in
>>> peripheral mode against any dual mode device.
>>> ---
>>> android/README | 3 +++
>>> android/bluetooth.c | 7 ++++++-
>>> android/hal-bluetooth.c | 15 ++++++++++++++-
>>> android/hal-msg.h | 1 +
>>> 4 files changed, 24 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/android/README b/android/README
>>> index 6254d34..9b08610 100644
>>> --- a/android/README
>>> +++ b/android/README
>>> @@ -166,6 +166,9 @@ options.
>>>
>>> Property Value Description
>>> -------------------------------------------
>>> +mode le_only Enable BlueZ in Low Energy mode only.
>>> + <none> Enable BlueZ in default mode - enable br/edr/le
>>> + if possible.
>>> handsfree hfp Enable Handsfree Profile (HFP) with narrowband
>>> speech only
>>> hfp_wbs Enable Handsfree Profile (HFP) with narrowband
>>> diff --git a/android/bluetooth.c b/android/bluetooth.c
>>> index 93c7935..923285c 100644
>>> --- a/android/bluetooth.c
>>> +++ b/android/bluetooth.c
>>> @@ -3894,10 +3894,15 @@ static const struct ipc_handler cmd_handlers[] = {
>>>
>>> void bt_bluetooth_register(struct ipc *ipc, uint8_t mode)
>>> {
>>> - DBG("");
>>> + DBG("mode 0x%x", mode);
>>>
>>> hal_ipc = ipc;
>>>
>>> + if ((mode == HAL_MODE_LE_ONLY) &&
>>> + (adapter.current_settings & MGMT_SETTING_LE) &&
>>> + (adapter.current_settings & MGMT_SETTING_BREDR))
>>> + set_mode(MGMT_OP_SET_BREDR, 0x00);
>>> +
>>> ipc_register(hal_ipc, HAL_SERVICE_ID_BLUETOOTH, cmd_handlers,
>>> G_N_ELEMENTS(cmd_handlers));
>>> }
>>> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
>>> index 48d5ea2..69009ff 100644
>>> --- a/android/hal-bluetooth.c
>>> +++ b/android/hal-bluetooth.c
>>> @@ -29,6 +29,8 @@
>>> #include "hal-ipc.h"
>>> #include "hal-utils.h"
>>>
>>> +#define MODE_PROPERTY_NAME "persist.sys.bluetooth.mode"
>>> +
>>> static const bt_callbacks_t *bt_hal_cbacks = NULL;
>>>
>>> #define enum_prop_to_hal(prop, hal_prop, type) do { \
>>> @@ -412,6 +414,17 @@ static const struct hal_ipc_handler ev_handlers[] = {
>>> }
>>> };
>>>
>>> +static uint8_t get_mode(void)
>>> +{
>>> + char value[PROPERTY_VALUE_MAX];
>>> +
>>> + if (property_get(MODE_PROPERTY_NAME, value, "") > 0 &&
>>> + (!strcasecmp(value, "le_only")))
>>> + return HAL_MODE_LE_ONLY;
>>> +
>>> + return HAL_MODE_DEFAULT;
>>> +}
>>> +
>>> static int init(bt_callbacks_t *callbacks)
>>> {
>>> struct hal_cmd_register_module cmd;
>>> @@ -433,7 +446,7 @@ static int init(bt_callbacks_t *callbacks)
>>> }
>>>
>>> cmd.service_id = HAL_SERVICE_ID_BLUETOOTH;
>>> - cmd.mode = HAL_MODE_DEFAULT;
>>> + cmd.mode = get_mode();
>>>
>>> status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
>>> sizeof(cmd), &cmd, NULL, NULL, NULL);
>>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>>> index ed0a67a..db21870 100644
>>> --- a/android/hal-msg.h
>>> +++ b/android/hal-msg.h
>>> @@ -55,6 +55,7 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
>>> #define HAL_OP_STATUS IPC_OP_STATUS
>>>
>>> #define HAL_MODE_DEFAULT 0x00
>>> +#define HAL_MODE_LE_ONLY 0x01
>>>
>>> #define HAL_OP_REGISTER_MODULE 0x01
>>> struct hal_cmd_register_module {
>>> --
>>> 1.8.4
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>>> the body of a message to [email protected]
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html