commands |= (1 << BTP_OP_GAP_READ_COTROLLER_INFO);
commands |= (1 << BTP_OP_GAP_RESET);
commands |= (1 << BTP_OP_GAP_SET_POWERED);
+ commands |= (1 << BTP_OP_GAP_SET_CONNECTABLE);
commands |= (1 << BTP_OP_GAP_SET_DISCOVERABLE);
commands |= (1 << BTP_OP_GAP_SET_BONDABLE);
commands |= (1 << BTP_OP_GAP_START_DISCOVERY);
btp_send_error(btp, BTP_GAP_SERVICE, index, status);
}
+static void update_current_settings(struct btp_adapter *adapter,
+ uint32_t new_settings)
+{
+ struct btp_new_settings_ev ev;
+
+ adapter->current_settings = new_settings;
+
+ ev.current_settings = L_CPU_TO_LE32(adapter->current_settings);
+
+ btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index,
+ sizeof(ev), &ev);
+}
+
+static void btp_gap_set_connectable(uint8_t index, const void *param,
+ uint16_t length, void *user_data)
+{
+ struct btp_adapter *adapter = find_adapter_by_index(index);
+ const struct btp_gap_set_connectable_cp *cp = param;
+ uint8_t status = BTP_ERROR_FAIL;
+ uint32_t new_settings;
+
+ if (length < sizeof(*cp))
+ goto failed;
+
+ if (!adapter) {
+ status = BTP_ERROR_INVALID_INDEX;
+ goto failed;
+ }
+
+ new_settings = adapter->current_settings;
+
+ if (cp->connectable)
+ new_settings |= 1 << BTP_GAP_SETTING_CONNECTABLE;
+ else
+ new_settings &= ~(1 << BTP_GAP_SETTING_CONNECTABLE);
+
+ update_current_settings(adapter, new_settings);
+
+ btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_SET_CONNECTABLE, index,
+ sizeof(new_settings), &new_settings);
+
+ return;
+
+failed:
+ btp_send_error(btp, BTP_GAP_SERVICE, index, status);
+}
+
static void btp_gap_set_discoverable(uint8_t index, const void *param,
uint16_t length, void *user_data)
{
btp_register(btp, BTP_GAP_SERVICE, BTP_OP_GAP_SET_POWERED,
btp_gap_set_powered, NULL, NULL);
+ btp_register(btp, BTP_GAP_SERVICE, BTP_OP_GAP_SET_CONNECTABLE,
+ btp_gap_set_connectable, NULL, NULL);
+
btp_register(btp, BTP_GAP_SERVICE, BTP_OP_GAP_SET_DISCOVERABLE,
btp_gap_set_discoverable, NULL, NULL);
}
}
-static void update_current_settings(struct btp_adapter *adapter,
- uint32_t new_settings)
-{
- struct btp_new_settings_ev ev;
-
- adapter->current_settings = new_settings;
-
- ev.current_settings = L_CPU_TO_LE32(adapter->current_settings);
-
- btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index,
- sizeof(ev), &ev);
-}
-
static void property_changed(struct l_dbus_proxy *proxy, const char *name,
struct l_dbus_message *msg, void *user_data)
{