From: DoHyun Pyun Date: Tue, 12 Sep 2017 05:34:15 +0000 (+0900) Subject: Fix tizen coding style errors and warnings X-Git-Tag: submit/tizen/20170912.093658^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3961465245e3954b9247d3fd26f2c6439f237466;p=platform%2Fcore%2Fapi%2Fbluetooth.git Fix tizen coding style errors and warnings Change-Id: Ia82b0ab5149a020ea9880c6e77212c96bffcb8ce Signed-off-by: DoHyun Pyun --- diff --git a/include/bluetooth_internal.h b/include/bluetooth_internal.h index 01b8061..c7d261f 100644 --- a/include/bluetooth_internal.h +++ b/include/bluetooth_internal.h @@ -999,7 +999,7 @@ int bt_device_get_profile_restricted(const char *device_address, bt_restricted_p * @retval #BT_ERROR_INVALID_PARAMETER Invalid Parameter * @retval #BT_ERROR_NOT_ENABLED Invalid Parameter */ -int bt_device_set_profile_trusted(const char *device_address,bt_trusted_profile_t profile, bool trust); +int bt_device_set_profile_trusted(const char *device_address, bt_trusted_profile_t profile, bool trust); /** * @internal @@ -1013,7 +1013,7 @@ int bt_device_set_profile_trusted(const char *device_address,bt_trusted_profile_ * @retval #BT_ERROR_NOT_ENABLED Invalid Parameter * @retval #BT_ERROR_INVALID_PARAMETER Invalid Parameter */ -int bt_device_get_profile_trusted(const char *device_address,bt_trusted_profile_t profile, int *trust); +int bt_device_get_profile_trusted(const char *device_address, bt_trusted_profile_t profile, int *trust); /** * @internal diff --git a/include/bluetooth_type_internal.h b/include/bluetooth_type_internal.h index da3eee1..650ab1d 100644 --- a/include/bluetooth_type_internal.h +++ b/include/bluetooth_type_internal.h @@ -65,7 +65,7 @@ typedef enum { */ typedef enum { BT_ATT_ERROR_INTERNAL = -1, - BT_ATT_ERROR_NONE = 0x00, + BT_ATT_ERROR_NONE = 0x00, /* Attribute error codes */ BT_ATT_ERROR_INVALID_HANDLE = 0x01, diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c index b0e63f5..ce9fc4e 100644 --- a/src/bluetooth-adapter.c +++ b/src/bluetooth-adapter.c @@ -3880,10 +3880,11 @@ int bt_adapter_le_scan_filter_set_proximity_uuid(bt_scan_filter_h scan_filter) ret = bt_adapter_le_scan_filter_register(pxp_linkloss_alert_filter); if (ret != BT_ERROR_NONE) { BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + ret = bt_adapter_le_scan_filter_destroy(pxp_linkloss_alert_filter); - if (ret != BT_ERROR_NONE) { + if (ret != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); - } + pxp_linkloss_alert_filter = NULL; } } else { @@ -3899,10 +3900,11 @@ int bt_adapter_le_scan_filter_set_proximity_uuid(bt_scan_filter_h scan_filter) ret = bt_adapter_le_scan_filter_register(pxp_immediate_alert_filter); if (ret != BT_ERROR_NONE) { BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + ret = bt_adapter_le_scan_filter_destroy(pxp_immediate_alert_filter); - if (ret != BT_ERROR_NONE) { + if (ret != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); - } + pxp_immediate_alert_filter = NULL; } } else { @@ -3918,10 +3920,11 @@ int bt_adapter_le_scan_filter_set_proximity_uuid(bt_scan_filter_h scan_filter) ret = bt_adapter_le_scan_filter_register(pxp_signal_loss_filter); if (ret != BT_ERROR_NONE) { BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + ret = bt_adapter_le_scan_filter_destroy(pxp_signal_loss_filter); - if (ret != BT_ERROR_NONE) { + if (ret != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); - } + pxp_signal_loss_filter = NULL; } } else { @@ -3940,40 +3943,43 @@ int bt_adapter_le_scan_filter_unset_proximity_uuid(bt_scan_filter_h scan_filter) /* unregister Linkloss alert scan filter */ if (pxp_linkloss_alert_filter) { + ret = bt_adapter_le_scan_filter_unregister(pxp_linkloss_alert_filter); - if (ret != BT_ERROR_NONE) { + if (ret != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); - } + ret = bt_adapter_le_scan_filter_destroy(pxp_linkloss_alert_filter); - if (ret != BT_ERROR_NONE) { + if (ret != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); - } + pxp_linkloss_alert_filter = NULL; } /* unregister Immediate alert scan filter */ if (pxp_immediate_alert_filter) { + ret = bt_adapter_le_scan_filter_unregister(pxp_immediate_alert_filter); - if (ret != BT_ERROR_NONE) { + if (ret != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); - } + ret = bt_adapter_le_scan_filter_destroy(pxp_immediate_alert_filter); - if (ret != BT_ERROR_NONE) { + if (ret != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); - } + pxp_immediate_alert_filter = NULL; } /* unregister Signal loss scan filter */ if (pxp_signal_loss_filter) { + ret = bt_adapter_le_scan_filter_unregister(pxp_signal_loss_filter); - if (ret != BT_ERROR_NONE) { + if (ret != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); - } + ret = bt_adapter_le_scan_filter_destroy(pxp_signal_loss_filter); - if (ret != BT_ERROR_NONE) { + if (ret != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); - } + pxp_signal_loss_filter = NULL; } diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 2ca22e6..dd866f7 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -624,6 +624,8 @@ tc_table_t tc_gatt[] = { , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC}, {"Register Link Loss Service" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC}, + {"Register HID Over GATT Service" + , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HOGP_SVC}, {"Register Custom Service" , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC}, {"Change Custom Value" @@ -3323,11 +3325,13 @@ static void __bt_otp_client_object_discovery_cb(int result, const char *remote_a if (result == BT_ERROR_NONE) { TC_PRT("Number of Objects [%d]", obj_list->num_objects); - for (k = 0; k < obj_list->num_objects; k++) { + + for (k = 0; k < obj_list->num_objects; k++) TC_PRT("Object[%d] Id: [%llu] Name: [%s]", k+1, obj_list->data[k]->id, obj_list->data[k]->name); - } - } else + + } else { BT_ERR("Object discovery failed!"); + } } static void __bt_otp_client_object_select_cb(int result, const char *remote_address, @@ -3346,18 +3350,18 @@ static void __bt_otp_client_object_select_cb(int result, const char *remote_addr static void __bt_otp_client_read_object_complete_cb(int result, const char *remote_address, char *file_path, void *user_data) { - if (result == BT_ERROR_NONE) { + if (result == BT_ERROR_NONE) TC_PRT("Read object success!, File location [%s]", file_path); - } else + else BT_ERR("Read object failed!"); } static void __bt_otp_client_object_create_cb(int result, const char *remote_address, unsigned long long obj_id, void *user_data) { - if (result == BT_ERROR_NONE) { + if (result == BT_ERROR_NONE) TC_PRT("Object[%llu] created successfully in remote server!", obj_id); - } else + else BT_ERR("Object creation failed!"); } @@ -5958,6 +5962,62 @@ int test_input_callback(void *data) break; } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_HOGP_ADVERTISING_DATA: { + const char *battery_svc_uuid_16 = "180f"; + const char *hid_svc_uuid_16 = "1812"; + const char *gatt_svc_uuid_16 = "1801"; + int appearance = 192; /* 192 is generic watch */ + + advertiser = advertiser_list[advertiser_index]; + + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + TC_PRT("created le advertiser(%d)", ret); + advertiser_list[advertiser_index] = advertiser; + } else { + ret = bt_adapter_le_clear_advertising_data(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING); + if (ret != BT_ERROR_NONE) + TC_PRT("clear advertising data [0x%04x]", ret); + ret = bt_adapter_le_clear_advertising_data(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE); + if (ret != BT_ERROR_NONE) + TC_PRT("clear scan response data [0x%04x]", ret); + } + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, hid_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, gatt_svc_uuid_16); + if (ret != BT_ERROR_NONE) + TC_PRT("add service_uuid [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_appearance(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); + if (ret != BT_ERROR_NONE) + TC_PRT("add appearance data [0x%04x]", ret); + + ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, true); + if (ret != BT_ERROR_NONE) + TC_PRT("add tx_power_level [0x%04x]", ret); + + /* Default scsn response data */ + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + if (ret != BT_ERROR_NONE) + TC_PRT("set device name [0x%04x]", ret); + + break; + } case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE: { int mode = BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED; @@ -7828,6 +7888,190 @@ int test_input_callback(void *data) break; } + case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HOGP_SVC: { + bt_gatt_h service1 = NULL; + bt_gatt_h service2 = NULL; + bt_gatt_h service3 = NULL; + bt_gatt_h characteristic1_1 = NULL; + bt_gatt_h characteristic2_1 = NULL; + bt_gatt_h characteristic2_2 = NULL; + bt_gatt_h characteristic2_3 = NULL; + bt_gatt_h characteristic2_4 = NULL; + bt_gatt_h characteristic2_5 = NULL; + bt_gatt_h characteristic2_6 = NULL; + bt_gatt_h characteristic2_7 = NULL; + bt_gatt_h descriptor1_1 = NULL; + bt_gatt_h descriptor2_3 = NULL; + bt_gatt_h descriptor2_4_1 = NULL; + bt_gatt_h descriptor2_4_2 = NULL; + bt_gatt_h descriptor2_5_1 = NULL; + bt_gatt_h descriptor2_5_2 = NULL; + char *service_uuid1 = "180f"; /* Battery Service */ + char *service_uuid2 = "1812"; /* HID Service */ + char *service_uuid3 = "1801"; /* Generic Attribute Service */ + char *char_uuid1 = "2a19"; /* Battery Level */ + char *char_uuid2_1 = "2a4a"; /* HID information */ + char *char_uuid2_2 = "2a4b"; + char *char_uuid2_3 = "2a33"; + char *char_uuid2_4 = "2a4d"; + char *char_uuid2_5 = "2a4d"; + char *char_uuid2_6 = "2a4c"; + char *char_uuid2_7 = "2a4e"; + char *desc_uuid1_1 = "2902"; /* Client Characteristic Configuration */ + char *desc_uuid2_3 = "2902"; /* Client Characteristic Configuration */ + char *desc_uuid2_4_1 = "2902"; /* Client Characteristic Configuration */ + char *desc_uuid2_4_2 = "2908"; /* Report Reference */ + char *desc_uuid2_5_1 = "2908"; /* Report Reference */ + char *desc_uuid2_5_2 = "2901"; /* Characteristic User Description */ + int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE; + + char char_value[1] = {80}; /* 80% */ + char char_value_unknown[4] = {10, 20, 30, 40}; + char desc_value_configration[2] = {0, 0}; /* Notification & Indication */ + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + /* Battery Service */ + ret = bt_gatt_service_create(service_uuid1, + BT_GATT_SERVICE_TYPE_PRIMARY, + &service1); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid1, permissions, + properties, char_value, + 1, &characteristic1_1); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service1, characteristic1_1); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid1_1, permissions, + desc_value_configration, 2, &descriptor1_1); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic1_1, descriptor1_1); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service1); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + + /* HID Service */ + ret = bt_gatt_service_create(service_uuid2, + BT_GATT_SERVICE_TYPE_PRIMARY, + &service2); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_1, permissions, + properties, char_value_unknown, + 4, &characteristic2_1); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_1); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_2, permissions, + properties, char_value_unknown, + 4, &characteristic2_2); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_2); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_3, permissions, + properties, char_value_unknown, + 4, &characteristic2_3); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_3); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_3, permissions, + desc_value_configration, 2, &descriptor2_3); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_3, descriptor2_3); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_4, permissions, + properties, char_value_unknown, + 4, &characteristic2_4); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_4); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_4_1, permissions, + desc_value_configration, 2, &descriptor2_4_1); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_4, descriptor2_4_1); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_4_2, permissions, + desc_value_configration, 2, &descriptor2_4_2); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_4, descriptor2_4_2); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_5, permissions, + properties, char_value_unknown, + 4, &characteristic2_5); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_5); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_5_1, permissions, + desc_value_configration, 2, &descriptor2_5_1); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_5, descriptor2_5_1); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_descriptor_create(desc_uuid2_5_2, permissions, + desc_value_configration, 2, &descriptor2_5_2); + TC_PRT("bt_gatt_descriptor_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_add_descriptor(characteristic2_5, descriptor2_5_2); + TC_PRT("bt_gatt_characteristic_add_descriptor : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_6, permissions, + properties, char_value_unknown, + 4, &characteristic2_6); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_6); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_characteristic_create(char_uuid2_7, permissions, + properties, char_value_unknown, + 4, &characteristic2_7); + TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_service_add_characteristic(service2, characteristic2_7); + TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service2); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + + /* Generic Attribute Service */ + ret = bt_gatt_service_create(service_uuid3, + BT_GATT_SERVICE_TYPE_PRIMARY, + &service3); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service3); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + break; + } case BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC: { bt_gatt_h service = NULL; bt_gatt_h characteristic = NULL; @@ -10717,12 +10961,14 @@ int test_input_callback(void *data) switch (test_id) { case BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT: { char *directory = NULL; - if (g_test_param.param_count < 1) { + + if (g_test_param.param_count < 1) TC_PRT("No relative path set"); - } else { + else directory = g_test_param.params[0]; - } + TC_PRT("%s", directory); + ret = bt_otp_server_initialize(directory); if (ret < BT_ERROR_NONE) TC_PRT("failed with [0x%04x]", ret); diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h index 8c11dd4..a30a2ad 100644 --- a/test/bt_unit_test.h +++ b/test/bt_unit_test.h @@ -110,6 +110,7 @@ typedef enum { BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_DEVICE_DISCOVERY, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_DEVICE_DISCOVERY, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_HOGP_ADVERTISING_DATA, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE, @@ -257,6 +258,7 @@ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA, BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_THERMOMETER_MEASUREMENT, BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_DEVICE_INFORMATION_SVC, BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_LINK_LOSS_SVC, + BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HOGP_SVC, BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC, BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL, BT_UNIT_TEST_FUNCTION_GATT_START_SERVER,