From: Gowtham Anandha Babu Date: Thu, 13 Jul 2017 15:16:06 +0000 (+0530) Subject: [OTP] Fix PTS fail cases X-Git-Tag: accepted/tizen/unified/20170718.174144~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0beafff38fb90ccd8086be57a80b8a8acd344230;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git [OTP] Fix PTS fail cases Change-Id: Ib26a7e7465c49da3d9570f602c05799020171e8f Signed-off-by: Gowtham Anandha Babu --- diff --git a/bt-api/bt-gatt-service.c b/bt-api/bt-gatt-service.c index 51e63b5..73c1012 100644 --- a/bt-api/bt-gatt-service.c +++ b/bt-api/bt-gatt-service.c @@ -2618,6 +2618,10 @@ BT_EXPORT_API int bluetooth_gatt_send_response(int request_id, guint req_type, g_dbus_method_invocation_return_dbus_error(req_info->context, "org.bluez.Error.Failed", "Object Name Already Exists"); break; + case BLUETOOTH_ERROR_CCC_IMPROPERLY_CONFIGURED: + g_dbus_method_invocation_return_dbus_error(req_info->context, + "org.bluez.Error.Failed", "CCC Improperly Configured"); + break; default: g_dbus_method_invocation_return_dbus_error(req_info->context, "org.bluez.Error.Failed", "Application Error"); diff --git a/bt-otp/bt-otpserver.c b/bt-otp/bt-otpserver.c index f283dd0..8cc4493 100644 --- a/bt-otp/bt-otpserver.c +++ b/bt-otp/bt-otpserver.c @@ -398,8 +398,10 @@ int _bt_otp_prepare_ots(void) } /* Characteristic Object Properties */ - props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ; - perms = BLUETOOTH_GATT_PERMISSION_READ; + props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ | + BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE; + perms = BLUETOOTH_GATT_PERMISSION_READ | + BLUETOOTH_GATT_PERMISSION_WRITE; char_uuid = _otp_convert_uuid_to_uuid128(OTP_OBJECT_PROP_UUID); ret = add_new_characteristic(char_uuid, perms, props, &otp_object_prop_obj_path); @@ -1152,6 +1154,11 @@ int _bt_otp_oacp_write_cb(char *value, int len, int offset, g_free(uuid); break; case OACP_DELETE: + if (opcode == OACP_DELETE && + ~(selected_object->props & OBJECT_DELETE)) { + ret = OACP_PROCEDURE_NOT_SUPPORTED; + goto fail; + } snprintf(absolute_file_path, sizeof(absolute_file_path), "%s%s", directory, selected_object->name); @@ -1170,6 +1177,11 @@ int _bt_otp_oacp_write_cb(char *value, int len, int offset, ret = OACP_OPCODE_NOT_SUPPORTED; break; case OACP_EXECUTE: + if (opcode == OACP_EXECUTE && + ~(selected_object->props & OBJECT_EXECUTE)) { + ret = OACP_PROCEDURE_NOT_SUPPORTED; + goto fail; + } snprintf(absolute_file_path, sizeof(absolute_file_path), "file://%s%s", directory, selected_object->name); @@ -1186,6 +1198,18 @@ int _bt_otp_oacp_write_cb(char *value, int len, int offset, break; case OACP_READ: case OACP_WRITE: + if (opcode == OACP_WRITE && + ~(selected_object->props & OBJECT_WRITE)) { + ret = OACP_PROCEDURE_NOT_SUPPORTED; + goto fail; + } + + if (opcode == OACP_READ && + ~(selected_object->props & OBJECT_READ)) { + ret = OACP_PROCEDURE_NOT_SUPPORTED; + goto fail; + } + object_offset = (uint32_t)(value[4] & 0xFF) << 24 | (uint32_t)(value[3] & 0xFF) << 16 | (uint32_t)(value[2] & 0xFF) << 8 | @@ -1220,7 +1244,7 @@ int _bt_otp_oacp_write_cb(char *value, int len, int offset, err = _bt_otp_open_otc_and_listen(remote_addr, "ListenOtc"); if (err != BLUETOOTH_ERROR_NONE) { - ret = OACP_OPERATION_FAILED; + ret = OACP_CHANNEL_UNAVAILABLE; _bt_otp_free_oacp_op(); goto fail; } @@ -1651,6 +1675,7 @@ void _bt_otp_gatt_char_property_changed_event(GVariant *msg, guint16 offset = 0; char *value = NULL; struct indicate_info info; + g_variant_get(var, "(&s&s&syq@ay)", &char_path, &svc_handle, &addr, &req_id, &offset, &val); @@ -1664,9 +1689,15 @@ void _bt_otp_gatt_char_property_changed_event(GVariant *msg, if (len != 0) { if (!g_strcmp0(char_path, otp_oacp_obj_path)) { - result = _bt_otp_oacp_write_cb(value, len, offset, addr, &info); + if (!OACP_indicate) + result = BLUETOOTH_ERROR_CCC_IMPROPERLY_CONFIGURED; + else + result = _bt_otp_oacp_write_cb(value, len, offset, addr, &info); } else if (!g_strcmp0(char_path, otp_olcp_obj_path)) { - result = _bt_otp_olcp_write_cb(value, len, offset, &info); + if (!OLCP_indicate) + result = BLUETOOTH_ERROR_CCC_IMPROPERLY_CONFIGURED; + else + result = _bt_otp_olcp_write_cb(value, len, offset, &info); } else if (!g_strcmp0(char_path, otp_object_name_obj_path)) { if (oacp_create) { /* OACP_CREATE is ongoing */ diff --git a/include/bluetooth-api.h b/include/bluetooth-api.h index 94f8a89..6a0c717 100644 --- a/include/bluetooth-api.h +++ b/include/bluetooth-api.h @@ -213,6 +213,7 @@ extern "C" { #define BLUETOOTH_ERROR_OBJECT_NOT_SELECTED 0x81 #define BLUETOOTH_ERROR_CONCURRENCY_LIMIT_EXCEEDED 0x82 #define BLUETOOTH_ERROR_OBJECT_NAME_EXISITS 0x83 +#define BLUETOOTH_ERROR_CCC_IMPROPERLY_CONFIGURED 0xfd /** * Device disconnect reason