le_adv_slot = NULL;
}
-int _bt_service_adapter_le_init(void)
+int _bt_le_set_max_packet_len(void)
{
- le_adv_slot = g_malloc0(sizeof(bt_adapter_le_adv_slot_t) * le_feature_info.adv_inst_max);
+ int result = BLUETOOTH_ERROR_NONE;
+ int tx_octets, tx_time;
+ bluetooth_le_read_maximum_data_length_t max_len = {0};
- return BLUETOOTH_ERROR_NONE;
-}
+ if (BLUETOOTH_ERROR_NONE != _bt_le_read_maximum_data_length(&max_len))
+ return BLUETOOTH_ERROR_INTERNAL;
-void _bt_service_adapter_le_deinit(void)
-{
- __bt_free_le_adv_slot();
+ if (max_len.max_tx_octets > BT_LE_TX_LEN_DEFAULT) {
+ tx_octets = max_len.max_tx_octets > BT_LE_TX_LEN_MAX ?
+ BT_LE_TX_LEN_MAX : max_len.max_tx_octets;
+ tx_time = BT_LE_TX_TIME_MAX;
+
+ result = _bt_le_write_host_suggested_default_data_length(tx_octets, tx_time);
+
+ BT_DBG("Wrote max packet size : result[%d], MAX[%d], set[%d]",
+ result, max_len.max_tx_octets, tx_octets);
+ }
+
+ return result;
}
gboolean _bt_update_le_feature_support(const char *item, const char *value)
if (item == NULL || value == NULL)
return FALSE;
+ if (!le_adv_slot)
+ _bt_service_adapter_le_init();
+
if (g_strcmp0(item, "adv_inst_max") == 0) {
int slot_num;
void _bt_unregister_adv_slot_owner(int slot_id)
{
+ if (le_adv_slot[slot_id].hold_timer_id > 0) {
+ BT_INFO("Hold state adv is not unregistered");
+ return;
+ }
+
g_free(le_adv_slot[slot_id].sender);
le_adv_slot[slot_id].sender = NULL;
le_adv_slot[slot_id].adv_handle = 0;
gboolean status = FALSE;
int i;
+ if (le_adv_slot == NULL)
+ return FALSE;
+
for (i = 0; i < le_feature_info.adv_inst_max; i++) {
if (le_adv_slot[i].is_advertising == TRUE)
status = TRUE;
if (le_adv_slot[slot_id].is_advertising == TRUE && enable == TRUE)
return BLUETOOTH_ERROR_IN_PROGRESS;
- if (le_adv_slot[slot_id].sender != NULL && le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
- return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-
if (le_adv_slot[slot_id].hold_timer_id > 0) {
g_source_remove(le_adv_slot[slot_id].hold_timer_id);
le_adv_slot[slot_id].hold_timer_id = 0;
+ _bt_unregister_adv_slot_owner(slot_id);
}
+ if (le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
+ return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
proxy = _bt_get_adapter_proxy();
retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
if (le_adv_slot[slot_id].is_advertising == TRUE && enable == TRUE)
return BLUETOOTH_ERROR_IN_PROGRESS;
- if (le_adv_slot[slot_id].sender != NULL && le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
- return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-
if (le_adv_slot[slot_id].hold_timer_id > 0) {
g_source_remove(le_adv_slot[slot_id].hold_timer_id);
le_adv_slot[slot_id].hold_timer_id = 0;
+ _bt_unregister_adv_slot_owner(slot_id);
}
+ if (le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
+ return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
proxy = _bt_get_adapter_proxy();
retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
if (enable == TRUE)
__bt_register_adv_slot_owner(sender, adv_handle, slot_id);
- else
- _bt_unregister_adv_slot_owner(slot_id);
le_adv_slot[slot_id].is_advertising = enable;
BT_INFO_C("### Set advertising [%d], Slot id [%d]", enable, slot_id);
}
}
+static void __bt_free_le_scanner(void)
+{
+ GSList *l;
+ bt_adapter_le_scanner_t *scanner;
+
+ for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
+ scanner = l->data;
+ g_free(scanner->sender);
+ g_slist_free_full(scanner->filter_list, g_free);
+ g_free(scanner);
+ }
+
+ g_slist_free(scanner_list);
+ scanner_list = NULL;
+
+ scan_filter_enabled = FALSE;
+ is_le_scanning = FALSE;
+ is_le_set_scan_parameter = FALSE;
+}
+
void _bt_set_le_scan_status(gboolean mode)
{
is_le_scanning = mode;
reply = g_dbus_proxy_call_sync(proxy, "LEReadMaximumDataLength",
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- g_object_unref(proxy);
-
if (reply == NULL) {
BT_ERR("LEReadMaximumDataLength dBUS-RPC failed");
if (error != NULL) {
NULL,
&error);
- g_object_unref(proxy);
-
if (reply == NULL) {
BT_ERR("_bt_le_write_host_suggested_default_data_length dBUS-RPC failed");
if (error != NULL) {
return BLUETOOTH_ERROR_NONE;
}
+
+int _bt_service_adapter_le_init(void)
+{
+ le_adv_slot = g_malloc0(sizeof(bt_adapter_le_adv_slot_t) * le_feature_info.adv_inst_max);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+void _bt_service_adapter_le_deinit(void)
+{
+ __bt_free_le_adv_slot();
+ __bt_free_le_scanner();
+}