From 7facee2446c734ed9e2c77dca68b7bab4418cd3d Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 3 Jan 2013 15:44:51 +0200 Subject: [PATCH] core: Move mgmt setting convenience macros to lib/mgmt.h --- lib/mgmt.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ monitor/control.c | 1 + src/mgmt.c | 45 --------------------------------------------- src/shared/mgmt.c | 1 + tools/mgmt-tester.c | 1 + 5 files changed, 48 insertions(+), 45 deletions(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index e28005e90..f88822001 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -570,3 +570,48 @@ static inline const char *mgmt_errstr(uint8_t status) return ""; return mgmt_status[status]; } + +static inline bool mgmt_powered(uint32_t settings) +{ + return (settings & MGMT_SETTING_POWERED); +} + +static inline bool mgmt_connectable(uint32_t settings) +{ + return (settings & MGMT_SETTING_CONNECTABLE); +} + +static inline bool mgmt_fast_connectable(uint32_t settings) +{ + return (settings & MGMT_SETTING_FAST_CONNECTABLE); +} + +static inline bool mgmt_discoverable(uint32_t settings) +{ + return (settings & MGMT_SETTING_DISCOVERABLE); +} + +static inline bool mgmt_pairable(uint32_t settings) +{ + return (settings & MGMT_SETTING_PAIRABLE); +} + +static inline bool mgmt_ssp(uint32_t settings) +{ + return (settings & MGMT_SETTING_SSP); +} + +static inline int mgmt_bredr(uint32_t settings) +{ + return (settings & MGMT_SETTING_BREDR) != 0; +} + +static inline int mgmt_high_speed(uint32_t settings) +{ + return (settings & MGMT_SETTING_HS) != 0; +} + +static inline int mgmt_low_energy(uint32_t settings) +{ + return (settings & MGMT_SETTING_LE) != 0; +} diff --git a/monitor/control.c b/monitor/control.c index 9b760388d..021409b46 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -27,6 +27,7 @@ #endif #include +#include #include #include #include diff --git a/src/mgmt.c b/src/mgmt.c index 08bceb329..1a22982ce 100644 --- a/src/mgmt.c +++ b/src/mgmt.c @@ -297,51 +297,6 @@ static int mgmt_set_low_energy(int index, gboolean le) return mgmt_set_mode(index, MGMT_OP_SET_LE, le); } -static inline int mgmt_powered(uint32_t settings) -{ - return (settings & MGMT_SETTING_POWERED) != 0; -} - -static inline int mgmt_connectable(uint32_t settings) -{ - return (settings & MGMT_SETTING_CONNECTABLE) != 0; -} - -static inline int mgmt_fast_connectable(uint32_t settings) -{ - return (settings & MGMT_SETTING_FAST_CONNECTABLE) != 0; -} - -static inline int mgmt_discoverable(uint32_t settings) -{ - return (settings & MGMT_SETTING_DISCOVERABLE) != 0; -} - -static inline int mgmt_pairable(uint32_t settings) -{ - return (settings & MGMT_SETTING_PAIRABLE) != 0; -} - -static inline int mgmt_ssp(uint32_t settings) -{ - return (settings & MGMT_SETTING_SSP) != 0; -} - -static inline int mgmt_bredr(uint32_t settings) -{ - return (settings & MGMT_SETTING_BREDR) != 0; -} - -static inline int mgmt_high_speed(uint32_t settings) -{ - return (settings & MGMT_SETTING_HS) != 0; -} - -static inline int mgmt_low_energy(uint32_t settings) -{ - return (settings & MGMT_SETTING_LE) != 0; -} - static void update_settings(struct btd_adapter *adapter, uint32_t settings) { DBG("new settings 0x%08x", settings); diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c index 8fb7aa703..de63ae74b 100644 --- a/src/shared/mgmt.c +++ b/src/shared/mgmt.c @@ -27,6 +27,7 @@ #include #include +#include #include diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index e91e07864..4117e8c90 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -26,6 +26,7 @@ #endif #include +#include #include "lib/bluetooth.h" #include "lib/mgmt.h" -- 2.47.3