* @see bt_initialize()
*/
int bt_adapter_le_set_scan_phy(bt_adapter_le_phy_e phy);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
+ * @brief Sets Bluetooth LE scan role.
+ * @since_tizen 8.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @param[in] isLegacy Advertisement is extended or legacy
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled
+ * @retval #BT_ERROR_INVALID_PARAMETER Parameter is invalid
+ * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ * @pre The state of local bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ */
+int bt_adapter_le_set_advertising_legacy_mode(bt_advertiser_h advertiser, bool isLegacy);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
+ * @brief Sets Bluetooth LE scan role.
+ * @since_tizen 8.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @param[in] primary_phy Primary phy of advertiser. Valid values are BT_LE_1M_PHY, BT_LE_CODED_PHY.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled
+ * @retval #BT_ERROR_INVALID_PARAMETER Parameter is invalid
+ * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ * @pre The state of local bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ */
+int bt_adapter_le_set_advertising_primary_phy(bt_advertiser_h advertiser,
+ bt_adapter_le_phy_e primary_phy);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
+ * @brief Sets Bluetooth LE scan role.
+ * @since_tizen 8.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @param[in] secondary_phy Secondary phy of advertiser, Valid values are BT_LE_1M_PHY,
+ * BT_LE_2M_PHY, BT_LE_CODED_PHY.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled
+ * @retval #BT_ERROR_INVALID_PARAMETER Parameter is invalid
+ * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ * @pre The state of local bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ */
+int bt_adapter_le_set_advertising_secondary_phy(bt_advertiser_h advertiser,
+ bt_adapter_le_phy_e secondary_phy);
+
/**
* @internal
* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
int tx_power_level;
int advertising_interval_min;
int advertising_interval_max;
+ bool is_legacy;
+ int primary_phy;
+ int secondary_phy;
} bt_adapter_le_advertising_parameters_s;
typedef struct {
__adv = (bt_advertiser_s *)g_malloc0(sizeof(bt_advertiser_s));
__adv->handle = GPOINTER_TO_INT(__adv);
+ __adv->adv_params.is_legacy = TRUE;
+
*advertiser = (bt_advertiser_h)__adv;
advertiser_list = g_slist_append(advertiser_list, __adv);
char *new_p;
int adv_flag_len = 0;
int adv_ext_len = 0;
+ int max_data_len_supported = 0;
BT_CHECK_LE_SUPPORT();
BT_CHECK_INIT_STATUS();
data_type == BT_ADAPTER_LE_ADVERTISING_DATA_TX_POWER_LEVEL)
adv_ext_len = *system_data_len + 1;
+ if (__adv->adv_params.is_legacy == FALSE) {
+ BT_DBG("Extended Advertiser!");
+ max_data_len_supported = 251;//TODO: Make Enum for len
+ }
+
+ else {
+ BT_DBG("Legacy advertiser!");
+ max_data_len_supported = 31;//TODO: Make Enum for len
+ }
+
/* 2 bytes are required for Length and AD Type */
- if (adv_flag_len + *len + adv_ext_len + data_size + 2 > 31) {
+ if (adv_flag_len + *len + adv_ext_len + data_size + 2 > max_data_len_supported) {
BT_ERR("Quota exceeded"); /* LCOV_EXCL_LINE */
return BT_ERROR_QUOTA_EXCEEDED; /* LCOV_EXCL_LINE */
}
return BT_ERROR_NONE;
}
+int bt_adapter_le_set_advertising_legacy_mode(bt_advertiser_h advertiser, bool isLegacy)
+{
+ int error_code;
+ bt_advertiser_s *__adv = (bt_advertiser_s *)advertiser;
+
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_LE_5_0_SUPPORT();
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_ADV_EXT);
+ BT_CHECK_INPUT_PARAMETER(advertiser);
+
+ error_code = _bt_get_error_code(
+ bluetooth_check_privilege_advertising_parameter());
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code),
+ error_code);
+ return BT_ERROR_PERMISSION_DENIED;
+ }
+
+ BT_DBG("Setting legacy mode %d", isLegacy);
+ __adv->adv_params.is_legacy = isLegacy;
+
+ return BT_ERROR_NONE;
+}
+
+
+int bt_adapter_le_set_advertising_primary_phy(bt_advertiser_h advertiser,
+ bt_adapter_le_phy_e primary_phy)
+{
+ int error_code;
+ bt_advertiser_s *__adv = (bt_advertiser_s *)advertiser;
+
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_LE_5_0_SUPPORT();
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_ADV_EXT);
+ BT_CHECK_INPUT_PARAMETER(advertiser);
+
+ error_code = _bt_get_error_code(
+ bluetooth_check_privilege_advertising_parameter());
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code),
+ error_code);
+ return BT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (primary_phy != BT_LE_1M_PHY || primary_phy != BT_LE_CODED_PHY)
+ return BT_ERROR_INVALID_PARAMETER;
+
+ __adv->adv_params.primary_phy = primary_phy;
+ BT_INFO("Set primary PHY %d for advertiser", primary_phy);
+
+ return BT_ERROR_NONE;
+}
+
+int bt_adapter_le_set_advertising_secondary_phy(bt_advertiser_h advertiser,
+ bt_adapter_le_phy_e secondary_phy)
+{
+ int error_code;
+ bt_advertiser_s *__adv = (bt_advertiser_s *)advertiser;
+
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_LE_5_0_SUPPORT();
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_ADV_EXT);
+ BT_CHECK_INPUT_PARAMETER(advertiser);
+
+ error_code = _bt_get_error_code(
+ bluetooth_check_privilege_advertising_parameter());
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code),
+ error_code);
+ return BT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (secondary_phy == BT_LE_ALL_PHY)
+ return BT_ERROR_INVALID_PARAMETER;
+
+ __adv->adv_params.secondary_phy = secondary_phy;
+ BT_INFO("Set secondary PHY %d for advertiser", secondary_phy);
+
+ return BT_ERROR_NONE;
+}
+
/* LCOV_EXCL_START */
static int bt_adapter_le_remove_advertising_data(bt_advertiser_h advertiser,
bt_adapter_le_packet_type_e pkt_type,
memcpy(adv.data, __adv->adv_data, __adv->adv_data_len);
error_code = bluetooth_set_advertising_data(__adv->handle,
- &adv, __adv->adv_data_len);
+ &adv, __adv->adv_data_len, __adv->adv_params.is_legacy);
ret = _bt_get_error_code(error_code);
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret),
param.interval_max = max_interval;
param.filter_policy = __adv->adv_params.filter_policy;
param.type = __adv->adv_params.type;
+ param.is_legacy = __adv->adv_params.is_legacy;
+ param.primary_phy = __adv->adv_params.primary_phy;
+ param.secondary_phy = __adv->adv_params.secondary_phy;
param.tx_power_level = __adv->adv_params.tx_power_level;
error_code = bluetooth_set_custom_advertising(__adv->handle,
TRUE, ¶m);
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_INTERVAL},
{"bt_adapter_le_start_advertising_new"
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW},
+ {"bt_adapter_le_start_extended_advertising"
+ , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_EXT_ADVERTISING},
{"bt_adapter_le_stop_advertising"
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING},
{"bt_adapter_le_add_white_list"
TC_PRT("failed with : %s \n", __bt_get_error_message(ret));
break;
}
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_EXT_ADVERTISING: {
+ bt_adapter_le_advertising_state_changed_cb cb;
+
+ bool is_legacy = false;//TODO: Add set is_legacy API in unit test
+ int primary_phy = 1;//TODO: Add set Primary Phy API in unit test
+ int secondary_phy = 1;//TODO: Add set Secondary Phy API in unit test
+ char manufacture_data[] = {"SAMSUNG SAMSUNG SAMSUNG SAMSUNG SAMSUNG SAMSUNG SAMSUNG SAMSUNG SAMSUNG SAMSUNG\n"};
+ int manufacturer_id = 117;
+
+ if (advertiser_index == 0)
+ cb = __bt_adapter_le_advertising_state_changed_cb;
+ else if (advertiser_index == 1)
+ cb = __bt_adapter_le_advertising_state_changed_cb_2;
+ else
+ cb = __bt_adapter_le_advertising_state_changed_cb_3;
+
+ 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;
+ }
+
+ TC_PRT("advertiser: %p", advertiser);
+
+ ret = bt_adapter_le_set_advertising_legacy_mode(advertiser, is_legacy);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("set legacy mode failed with : %s \n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_le_set_advertising_primary_phy(advertiser, primary_phy);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("set primary phy failed with : %s \n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_le_set_advertising_secondary_phy(advertiser, secondary_phy);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("set secondary phy failed with : %s \n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING,
+ manufacturer_id, manufacture_data, sizeof(manufacture_data));
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("add manufacturer data failed with : %s \n", __bt_get_error_message(ret));
+ }
+
+ ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("Atart advertiser failed with : %s \n", __bt_get_error_message(ret));
+ break;
+ }
+
case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: {
int slot_id = 0;
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CUSTOM_TX_POWER,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_INTERVAL,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING_NEW,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_EXTENDED_ADVERTISING,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_ADVERTISING,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_EXT_ADVERTISING,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ALLOW_LIST,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REMOVE_ALLOW_LIST,
return BLUETOOTH_ERROR_NONE;
}
-API int bluetooth_set_advertising_data(int handle, const bluetooth_advertising_data_t *value, int length)
+API int bluetooth_set_advertising_data(int handle, const bluetooth_advertising_data_t *value, int length, bool is_legacy)
{
return BLUETOOTH_ERROR_NONE;
}