return BT_ERROR_INVALID_PARAMETER; \
}
-#define BT_FEATURE_COMMON "tizen.org/feature/network.bluetooth"
-#define BT_FEATURE_LE "tizen.org/feature/network.bluetooth.le"
-#define BT_FEATURE_LE_5_0 "tizen.org/feature/network.bluetooth.le.5_0"
-#define BT_FEATURE_IPSP "tizen.org/feature/network.bluetooth.le.ipsp"
-#define BT_FEATURE_AUDIO_CALL "tizen.org/feature/network.bluetooth.audio.call"
-#define BT_FEATURE_AUDIO_MEDIA "tizen.org/feature/network.bluetooth.audio.media"
-#define BT_FEATURE_AUDIO_CONTROLLER "tizen.org/feature/network.bluetooth.audio.controller"
-#define BT_FEATURE_HEALTH "tizen.org/feature/network.bluetooth.health"
-#define BT_FEATURE_HID_HOST "tizen.org/feature/network.bluetooth.hid"
-#define BT_FEATURE_HID_DEVICE "tizen.org/feature/network.bluetooth.hid_device"
-#define BT_FEATURE_OPP "tizen.org/feature/network.bluetooth.opp"
-#define BT_FEATURE_MAP "tizen.org/feature/network.bluetooth.map"
-#define BT_FEATURE_TETHERING "tizen.org/feature/network.tethering.bluetooth"
-#define BT_FEATURE_PBAP_CLIENT "tizen.org/feature/network.bluetooth.phonebook.client"
-#define BT_FEATURE_OOB "tizen.org/feature/network.bluetooth.oob"
-#define BT_FEATURE_GATT_SERVER "tizen.org/feature/network.bluetooth.le.gatt.server"
-#define BT_FEATURE_GATT_CLIENT "tizen.org/feature/network.bluetooth.le.gatt.client"
-
-#define BT_CHECK_SUPPORTED_FEATURE(feature_name) \
+typedef enum {
+ BT_FEATURE_BASE = 0,
+ BT_FEATURE_COMMON = BT_FEATURE_BASE,
+ BT_FEATURE_LE,
+ BT_FEATURE_LE_5_0,
+ BT_FEATURE_IPSP,
+ BT_FEATURE_AUDIO_CALL,
+ BT_FEATURE_AUDIO_MEDIA,
+ BT_FEATURE_AUDIO_CONTROLLER,
+ BT_FEATURE_HEALTH,
+ BT_FEATURE_HID_HOST,
+ BT_FEATURE_HID_DEVICE,
+ BT_FEATURE_OPP,
+ BT_FEATURE_MAP,
+ BT_FEATURE_TETHERING,
+ BT_FEATURE_PBAP_CLIENT,
+ BT_FEATURE_OOB,
+ BT_FEATURE_GATT_SERVER,
+ BT_FEATURE_GATT_CLIENT,
+ BT_FEATURE_MAX
+} bt_feature_t;
+
+typedef struct {
+ const char *name;
+ gboolean is_check;
+ gboolean value;
+} bt_feature_table_t;
+
+int _bt_check_supported_feature(bt_feature_t feature, bool *supported);
+
+#define BT_CHECK_SUPPORTED_FEATURE(feature) \
do { \
bool is_supported = false; \
- if (!system_info_get_platform_bool(feature_name, &is_supported)) { \
+ if (!_bt_check_supported_feature(feature, &is_supported)) { \
if (is_supported == false) { \
LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \
return BT_ERROR_NOT_SUPPORTED; \
} \
} else { \
- LOGE("[%s] Fail to get the system feature: [%s]", __FUNCTION__, feature_name); \
+ LOGE("[%s] Fail to get the system feature: [%d]", __FUNCTION__, feature); \
} \
} while (0)
-#define BT_CHECK_SUPPORTED_FEATURES(feature_name1, feature_name2) \
+#define BT_CHECK_SUPPORTED_FEATURES(feature1, feature2) \
do { \
bool is_supported = false; \
- if (!system_info_get_platform_bool(feature_name1, &is_supported)) { \
- if (is_supported == true) {\
+ if (!_bt_check_supported_feature(feature1, &is_supported)) { \
+ if (is_supported == true) { \
+ LOGI("[%s] SUPPORTED", __FUNCTION__); \
break; \
} \
} else { \
- LOGE("[%s] Fail to get the system feature: [%s]", __FUNCTION__, feature_name1); \
+ LOGE("[%s] Fail to get the system feature: [%d]", __FUNCTION__, feature1); \
} \
- if (!system_info_get_platform_bool(feature_name2, &is_supported)) { \
+ if (!_bt_check_supported_feature(feature2, &is_supported)) { \
if (is_supported == true) { \
+ LOGI("[%s] SUPPORTED", __FUNCTION__); \
break; \
} else {\
LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \
return BT_ERROR_NOT_SUPPORTED; \
} \
} else { \
- LOGE("[%s] Fail to get the system feature: [%s]", __FUNCTION__, feature_name2); \
+ LOGE("[%s] Fail to get the system feature: [%d]", __FUNCTION__, feature2); \
} \
} while (0)
{ 0, -1 }
};
+static bt_feature_table_t feature_table[] = {
+ {"tizen.org/feature/network.bluetooth", FALSE, FALSE}, /* BT_FEATURE_COMMON */
+ {"tizen.org/feature/network.bluetooth.le", FALSE, FALSE}, /* BT_FEATURE_LE */
+ {"tizen.org/feature/network.bluetooth.le.5_0", FALSE, FALSE}, /* BT_FEATURE_LE_5_0 */
+ {"tizen.org/feature/network.bluetooth.le.ipsp", FALSE, FALSE}, /* BT_FEATURE_IPSP */
+ {"tizen.org/feature/network.bluetooth.audio.call", FALSE, FALSE}, /* BT_FEATURE_AUDIO_CALL */
+ {"tizen.org/feature/network.bluetooth.audio.media", FALSE, FALSE}, /* BT_FEATURE_AUDIO_MEDIA */
+ {"tizen.org/feature/network.bluetooth.audio.controller", FALSE, FALSE}, /* BT_FEATURE_AUDIO_CONTROLLER */
+ {"tizen.org/feature/network.bluetooth.health", FALSE, FALSE}, /* BT_FEATURE_HEALTH */
+ {"tizen.org/feature/network.bluetooth.hid", FALSE, FALSE}, /* BT_FEATURE_HID_HOST */
+ {"tizen.org/feature/network.bluetooth.hid_device", FALSE, FALSE}, /* BT_FEATURE_HID_DEVICE */
+ {"tizen.org/feature/network.bluetooth.opp", FALSE, FALSE}, /* BT_FEATURE_OPP */
+ {"tizen.org/feature/network.bluetooth.map", FALSE, FALSE}, /* BT_FEATURE_MAP */
+ {"tizen.org/feature/network.tethering.bluetooth", FALSE, FALSE}, /* BT_FEATURE_TETHERING */
+ {"tizen.org/feature/network.bluetooth.phonebook.client", FALSE, FALSE}, /* BT_FEATURE_PBAP_CLIENT */
+ {"tizen.org/feature/network.bluetooth.oob", FALSE, FALSE}, /* BT_FEATURE_OOB */
+ {"tizen.org/feature/network.bluetooth.le.gatt.server", FALSE, FALSE}, /* BT_FEATURE_GATT_SERVER */
+ {"tizen.org/feature/network.bluetooth.le.gatt.client", FALSE, FALSE} /* BT_FEATURE_GATT_CLIENT */
+};
+
/*
* Internal Functions
*/
/*
* Common Functions
*/
+int _bt_check_supported_feature(bt_feature_t feature, bool *supported)
+{
+ int ret;
+
+ if (feature < BT_FEATURE_BASE || feature >= BT_FEATURE_MAX) {
+ BT_ERR("Invalid parameter. feature [%d]", feature);
+ return BT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (TRUE == feature_table[feature].is_check) {
+ *supported = feature_table[feature].value;
+ return BT_ERROR_NONE;
+ }
+
+ ret = system_info_get_platform_bool(feature_table[feature].name, supported);
+ if (SYSTEM_INFO_ERROR_NONE != ret) {
+ BT_ERR("fail to get %s", feature_table[feature].name);
+ return BT_ERROR_OPERATION_FAILED;
+ }
+
+ feature_table[feature].is_check = TRUE;
+ feature_table[feature].value = *supported;
+
+ return BT_ERROR_NONE;
+}
+
int _bt_check_init_status(void)
{
if (is_initialized != true) {