#define TYPE_FIELD "string"
#define FEATURE_TAG "platform"
#define MODEL_CONFIG_TAG "model-config"
+#define CERTI_STACK_FILE "/var/lib/bluetooth/stack_test"
+#define CERTI_PROFILE_FILE "/var/lib/bluetooth/profile_test"
+
typedef enum {
TIZEN_PROFILE_UNKNOWN = 0,
TIZEN_MODEL_ROBOT = 0x80,
} tizen_model_t;
+typedef enum {
+ TIZEN_CERTI_MODE_UNKNOWN = 0,
+ TIZEN_CERTI_MODE_DISABLE = 0x1,
+ TIZEN_CERTI_MODE_STACK = 0x2,
+ TIZEN_CERTI_MODE_PROFILE = 0x4,
+} tizen_certifcation_mode_t;
+
static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
static tizen_model_t model = TIZEN_MODEL_UNKNOWN;
+static tizen_certifcation_mode_t certification_mode = TIZEN_CERTI_MODE_UNKNOWN;
static inline int __get_profile_from_model_config_xml(const char *field, char **value)
{
return model;
}
+static inline tizen_certifcation_mode_t _get_tizen_certification_mode(void)
+{
+ if (__builtin_expect(certification_mode != TIZEN_CERTI_MODE_UNKNOWN, 1))
+ return certification_mode;
+
+ if (access(CERTI_STACK_FILE, F_OK) == 0)
+ certification_mode |= TIZEN_CERTI_MODE_STACK;
+
+ if (access(CERTI_PROFILE_FILE, F_OK) == 0)
+ certification_mode |= TIZEN_CERTI_MODE_PROFILE;
+
+ if (certification_mode == TIZEN_CERTI_MODE_UNKNOWN)
+ certification_mode = TIZEN_CERTI_MODE_DISABLE;
+
+ return certification_mode;
+}
+
#define TIZEN_FEATURE_BLUEZ_BRCM_CHIP ((_get_tizen_profile()) == TIZEN_PROFILE_IVI)
#define TIZEN_FEATURE_BLUEZ_WEARABLE ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
#define TIZEN_FEATURE_BLUEZ_SMS_ONLY ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
#define TIZEN_FEATURE_BLUEZ_SPRD_PAGE_SCAN ((_get_tizen_model()) == TIZEN_MODEL_TM1)
#define TIZEN_FEATURE_BLUEZ_SPEAKER_REFERENCE ((_get_tizen_model()) == TIZEN_MODEL_RPI3 && (_get_tizen_profile()) == TIZEN_PROFILE_COMMON)
#define TIZEN_FEATURE_ROBOT_REFERENCE ((_get_tizen_model()) == TIZEN_MODEL_ROBOT)
+#define TIZEN_FEATURE_BLUEZ_STACK_CERTIFICATION (((_get_tizen_certification_mode()) & TIZEN_CERTI_MODE_STACK) != 0)
+#define TIZEN_FEATURE_BLUEZ_PROFILE_CERTIFICATION (((_get_tizen_certification_mode()) & TIZEN_CERTI_MODE_PROFILE) != 0)
#endif /* __TIZEN_PROFILE_H__ */
#include "src/shared/gatt-client.h"
#if defined TIZEN_FEATURE_BLUEZ_MODIFY
#include "../log.h"
+#include "../../profile.h"
#endif
#include <assert.h>
return false;
}
-#ifndef TIZEN_CERTIFICATE
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
att_id = bt_att_send(notify_data->client->att, BT_ATT_OP_WRITE_REQ,
pdu, sizeof(pdu), callback,
notify_data_ref(notify_data),
notify_data_unref);
#else
- /* GAP/SEC/SEM/BV-56-C, GAP/SEC/SEM/BV-59-C
- PTS expects to recieve the sperated value for notify and indicate
- So seperate the value and send it
- */
- bool notify = false;
- bool indicate = false;
-
att_id = 0;
- if (pdu[2] & 0x01)
- notify = true;
-
- if (pdu[2] & 0x02)
- indicate = true;
-
- if (notify == true) {
- pdu[2] = 0x01;
-
+ if (!TIZEN_FEATURE_BLUEZ_STACK_CERTIFICATION) {
att_id = bt_att_send(notify_data->client->att, BT_ATT_OP_WRITE_REQ,
pdu, sizeof(pdu), callback,
notify_data_ref(notify_data),
notify_data_unref);
- }
+ } else {
+ /* GAP/SEC/SEM/BV-56-C, GAP/SEC/SEM/BV-59-C
+ PTS expects to recieve the sperated value for notify and indicate
+ So seperate the value and send it
+ */
+ bool notify = false;
+ bool indicate = false;
- if (indicate == true) {
- pdu[2] = 0x02;
+ if (pdu[2] & 0x01)
+ notify = true;
- att_id = bt_att_send(notify_data->client->att, BT_ATT_OP_WRITE_REQ,
- pdu, sizeof(pdu), callback,
- NULL,
- NULL);
+ if (pdu[2] & 0x02)
+ indicate = true;
+
+ if (notify == true) {
+ pdu[2] = 0x01;
+
+ att_id = bt_att_send(notify_data->client->att, BT_ATT_OP_WRITE_REQ,
+ pdu, sizeof(pdu), callback,
+ notify_data_ref(notify_data),
+ notify_data_unref);
+ }
+
+ if (indicate == true) {
+ pdu[2] = 0x02;
+
+ att_id = bt_att_send(notify_data->client->att, BT_ATT_OP_WRITE_REQ,
+ pdu, sizeof(pdu), callback,
+ NULL,
+ NULL);
+ }
}
#endif
{
struct notify_data *notify_data = user_data;
-#ifdef TIZEN_CERTIFICATE
- if (notify_data == NULL)
- return;
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
+ if (TIZEN_FEATURE_BLUEZ_STACK_CERTIFICATION) {
+ if (notify_data == NULL)
+ return;
+ }
#endif
assert(notify_data->chrc->ccc_write_id);
#include "src/shared/util.h"
#include "src/shared/timeout.h"
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+#include "../../profile.h"
+#endif
+
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
gatt_db_read_by_type(server->db, start, end, type, q);
if (queue_isempty(q)) {
-#ifdef TIZEN_CERTIFICATE
- if (start == 0x00ff && end == 0x00ff) {
- ecode = BT_ATT_ERROR_AUTHENTICATION;
- goto error;
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
+ if (TIZEN_FEATURE_BLUEZ_STACK_CERTIFICATION) {
+ if (start == 0x00ff && end == 0x00ff) {
+ ecode = BT_ATT_ERROR_AUTHENTICATION;
+ goto error;
+ }
}
#endif
ecode = BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND;
goto error;
}
-#ifdef TIZEN_CERTIFICATE
- /* GATT/SR/GAW/BI-05-C
- Write Characteristic Value - Insufficient Authentication (0x05)
- For 0x2aff UUID, return authentication error
- We need to register 0x2aff UUID for this
- */
- const bt_uuid_t *uuid;
- static const bt_uuid_t error_uuid = { .type = BT_UUID16,
- .value.u16 = 0x2aff };
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
+ if (TIZEN_FEATURE_BLUEZ_STACK_CERTIFICATION) {
+ /* GATT/SR/GAW/BI-05-C
+ Write Characteristic Value - Insufficient Authentication (0x05)
+ For 0x2aff UUID, return authentication error
+ We need to register 0x2aff UUID for this
+ */
+ const bt_uuid_t *uuid;
+ static const bt_uuid_t error_uuid = { .type = BT_UUID16,
+ .value.u16 = 0x2aff };
- uuid = gatt_db_attribute_get_type(attr);
- if (!bt_uuid_cmp(&error_uuid, uuid)) {
- ecode = BT_ATT_ERROR_AUTHENTICATION;
- goto error;
+ uuid = gatt_db_attribute_get_type(attr);
+ if (!bt_uuid_cmp(&error_uuid, uuid)) {
+ ecode = BT_ATT_ERROR_AUTHENTICATION;
+ goto error;
+ }
}
#endif
attr = gatt_db_get_attribute(server->db, handle);
if (!attr) {
-#ifdef TIZEN_CERTIFICATE
- /* GATT/SR/GAR/BI-34-C
- GATT/SR/GAR/BI-35-C
- Read Characteristic Value - Invalid Transport Access over LE or BR/EDR (0x80)
- For 0x00FF UUID, return Invalid Transport Access Error
- We need to register 0x00FF UUID for this
-
- GATT/SR/GAR/BI-04-C
- Read Characteristic Value . Insufficient Authentication (0x05)
- For 0x2aff UUID, return authentication error
- We need to register 0x2aff UUID for this
- */
-
- const bt_uuid_t *uuid;
- char uuidstr[MAX_LEN_UUID_STR + 1];
-
- static const bt_uuid_t error_uuid = { .type = BT_UUID16,
- .value.u16 = 0x2aff };
-
- uuid = gatt_db_attribute_get_type(attr);
-
- bt_uuid_to_string(uuid, uuidstr, sizeof(uuidstr));
-
- if (handle == 0x00FF) {
- ecode = 0x80;
- } else if (!bt_uuid_cmp(&error_uuid, uuid)) {
- ecode = BT_ATT_ERROR_AUTHENTICATION;
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
+ if (TIZEN_FEATURE_BLUEZ_STACK_CERTIFICATION) {
+ /* GATT/SR/GAR/BI-34-C
+ GATT/SR/GAR/BI-35-C
+ Read Characteristic Value - Invalid Transport Access over LE or BR/EDR (0x80)
+ For 0x00FF UUID, return Invalid Transport Access Error
+ We need to register 0x00FF UUID for this
+
+ GATT/SR/GAR/BI-04-C
+ Read Characteristic Value . Insufficient Authentication (0x05)
+ For 0x2aff UUID, return authentication error
+ We need to register 0x2aff UUID for this
+ */
+
+ const bt_uuid_t *uuid;
+ char uuidstr[MAX_LEN_UUID_STR + 1];
+
+ static const bt_uuid_t error_uuid = { .type = BT_UUID16,
+ .value.u16 = 0x2aff };
+
+ uuid = gatt_db_attribute_get_type(attr);
+
+ bt_uuid_to_string(uuid, uuidstr, sizeof(uuidstr));
+
+ if (handle == 0x00FF) {
+ ecode = 0x80;
+ } else if (!bt_uuid_cmp(&error_uuid, uuid)) {
+ ecode = BT_ATT_ERROR_AUTHENTICATION;
+ } else {
+ ecode = BT_ATT_ERROR_INVALID_HANDLE;
+ }
} else {
ecode = BT_ATT_ERROR_INVALID_HANDLE;
}
goto error;
}
-#ifdef TIZEN_CERTIFICATE
- /* GATT/SR/GAR/BI-04-C
- Read Characteristic Value . Insufficient Authentication (0x05)
- For 0x2AFF UUID, return authentication error
- We need to register 0x2aff UUID for this
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
+ if (TIZEN_FEATURE_BLUEZ_STACK_CERTIFICATION) {
+ /* GATT/SR/GAR/BI-04-C
+ Read Characteristic Value . Insufficient Authentication (0x05)
+ For 0x2AFF UUID, return authentication error
+ We need to register 0x2aff UUID for this
- */
- const bt_uuid_t *uuid;
- static const bt_uuid_t error_uuid = { .type = BT_UUID16,
- .value.u16 = 0x2aff };
+ */
+ const bt_uuid_t *uuid;
+ static const bt_uuid_t error_uuid = { .type = BT_UUID16,
+ .value.u16 = 0x2aff };
- uuid = gatt_db_attribute_get_type(attr);
- if (!bt_uuid_cmp(&error_uuid, uuid)) {
- ecode = BT_ATT_ERROR_AUTHENTICATION;
- goto error;
+ uuid = gatt_db_attribute_get_type(attr);
+ if (!bt_uuid_cmp(&error_uuid, uuid)) {
+ ecode = BT_ATT_ERROR_AUTHENTICATION;
+ goto error;
+ }
}
#endif
goto error;
}
-#ifdef TIZEN_CERTIFICATE
- /* GATT/SR/GAW/BI-12-C
- Write Long Characteristic Value - Insufficient Authentication (0x05)
- For 0x2af8 or 0x2aff UUID, return authentication error
- We need to register 0x2af8 or 0x2aff UUID for this
- */
- const bt_uuid_t *uuid;
- static const bt_uuid_t long_uuid = { .type = BT_UUID16,
- .value.u16 = 0x2af8 };
- static const bt_uuid_t error_uuid = { .type = BT_UUID16,
- .value.u16 = 0x2aff };
-
- uuid = gatt_db_attribute_get_type(attr);
- if (!bt_uuid_cmp(&long_uuid, uuid) || !bt_uuid_cmp(&error_uuid, uuid)) {
- ecode = BT_ATT_ERROR_AUTHENTICATION;
- goto error;
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
+ if (TIZEN_FEATURE_BLUEZ_STACK_CERTIFICATION) {
+ /* GATT/SR/GAW/BI-12-C
+ Write Long Characteristic Value - Insufficient Authentication (0x05)
+ For 0x2af8 or 0x2aff UUID, return authentication error
+ We need to register 0x2af8 or 0x2aff UUID for this
+ */
+ const bt_uuid_t *uuid;
+ static const bt_uuid_t long_uuid = { .type = BT_UUID16,
+ .value.u16 = 0x2af8 };
+ static const bt_uuid_t error_uuid = { .type = BT_UUID16,
+ .value.u16 = 0x2aff };
+
+ uuid = gatt_db_attribute_get_type(attr);
+ if (!bt_uuid_cmp(&long_uuid, uuid) || !bt_uuid_cmp(&error_uuid, uuid)) {
+ ecode = BT_ATT_ERROR_AUTHENTICATION;
+ goto error;
+ }
}
#endif