oal-adapter-mgr.c
oal-device-mgr.c
oal-hid-host.c
+oal-hid-device.c
oal-socket.c
oal-audio-src.c
oal-a2dp-sink.c
./src/bt-hal-gap-agent.c
./src/bt-hal-agent.c
./src/bt-hal-hidhost.c
+./src/bt-hal-hiddevice.c
./src/bt-hal-av.c
./src/bt-hal-av-dbus-handler.c
./src/bt-hal-a2dp-sink.c
#define HAL_HIDHOST_STATE_FAILED 0x08
#define HAL_HIDHOST_STATE_UNKNOWN 0x09
+/* HID device events */
+#define HAL_HIDDEVICE_STATE_CONNECTED 0x00
+#define HAL_HIDDEVICE_STATE_DISCONNECTED 0x01
+
#define HAL_EV_HIDHOST_CONN_STATE 0x81
struct hal_ev_hidhost_conn_state {
uint8_t bdaddr[6];
uint8_t status;
} __attribute__((packed));
+#define HAL_EV_HIDDEVICE_CONN_STATE 0x88
+struct hal_ev_hiddevice_conn_state {
+ uint8_t bdaddr[6];
+ uint8_t state;
+} __attribute__((packed));
+
/* Bluetooth Socket HAL events */
struct hal_ev_sock_connect {
short size;
#include <hardware/bluetooth.h>
#include <hardware/bt_hh.h>
+#include <hardware/bt_hd.h>
#include <hardware/bt_av.h>
#include <hardware/bt_hf.h>
#include <hardware/bt_sock.h>
#include <bt-hal-adapter-dbus-handler.h>
#include <bt-hal-device-dbus-handler.h>
#include <bt-hal-hidhost.h>
+#include <bt-hal-hiddevice.h>
#include <bt-hal-socket.h>
#include <bt-hal-av.h>
#include <bt-hal-hf.h>
if (!strncmp(profile_id, BT_PROFILE_HIDHOST_ID, strlen(profile_id)))
return bt_get_hidhost_interface();
+ if (!strcmp(profile_id, BT_PROFILE_HIDDEVICE_ID))
+ return bt_get_hiddevice_interface();
+
if (!strcmp(profile_id, BT_PROFILE_SOCKETS_ID))
return bt_get_socket_interface();
static GDBusConnection *manager_conn;
static handle_stack_msg event_cb = NULL;
static handle_stack_msg hid_event_cb = NULL;
+static handle_stack_msg hid_device_event_cb = NULL;
static handle_stack_msg av_event_cb = NULL;
static handle_stack_msg a2dp_sink_event_cb = NULL;
static handle_stack_msg hf_event_cb = NULL;
}
static void __bt_hal_send_hid_connection_state_event(
- gboolean connected, char *address)
+ gboolean connected, const char *address)
{
struct hal_ev_hidhost_conn_state ev;
hid_event_cb(HAL_EV_HIDHOST_CONN_STATE, &ev, sizeof(ev));
}
+static void __bt_hal_send_hid_device_connection_state_event(
+ gboolean connected, const char *address)
+{
+ struct hal_ev_hiddevice_conn_state ev;
+
+ ev.state = (connected == TRUE) ?
+ HAL_HIDDEVICE_STATE_CONNECTED :
+ HAL_HIDDEVICE_STATE_DISCONNECTED;
+
+ _bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
+
+ if (!hid_device_event_cb)
+ ERR("HID device event handler not registered");
+ else
+ hid_device_event_cb(HAL_EV_HIDDEVICE_CONN_STATE, &ev, sizeof(ev));
+}
+
static void __bt_hal_handle_input_event(GVariant *msg, const char *path)
{
gboolean property_flag = FALSE;
DBG("Address: %s", address);
DBG("Profile UUID: %s", profile_uuid);
DBG("State: %d", state);
- if (strncmp(profile_uuid, HID_UUID, strlen(HID_UUID)) == 0) {
+ if (strcmp(profile_uuid, HID_UUID) == 0) {
+ DBG("HID Host Profile state: %d", state);
if (state == BT_HAL_PROFILE_STATE_CONNECTED)
__bt_hal_send_hid_connection_state_event(TRUE, address);
else if (state == BT_HAL_PROFILE_STATE_DISCONNECTED)
__bt_hal_send_hid_connection_state_event(FALSE, address);
else
- DBG("Profile state: %d", state);
-
- } else if ((strncmp(profile_uuid, A2DP_SINK_UUID, strlen(A2DP_SINK_UUID)) == 0)) {
+ DBG("HID Host Profile state: Invalid");
+ } else if (strcmp(profile_uuid, HID_DEVICE_UUID) == 0) {
+ DBG("HID Device Profile state: %d", state);
+ if (state == BT_HAL_PROFILE_STATE_CONNECTED)
+ __bt_hal_send_hid_device_connection_state_event(TRUE, address);
+ else if (state == BT_HAL_PROFILE_STATE_DISCONNECTED)
+ __bt_hal_send_hid_device_connection_state_event(FALSE, address);
+ else
+ DBG("HID Device Profile state: Invalid");
+ } else if ((strcmp(profile_uuid, A2DP_SINK_UUID) == 0)) {
if (state == BT_HAL_PROFILE_STATE_CONNECTED) {
DBG("A2DP Profile state changed: BT_PROFILE_STATE_CONNECTED");
__bt_hal_send_av_connection_state_event(TRUE, address);
} else {
ERR("A2DP Profile state: Invalid");
}
- } else if ((strncmp(profile_uuid, A2DP_SOURCE_UUID, strlen(A2DP_SOURCE_UUID)) == 0)) {
+ } else if ((strcmp(profile_uuid, A2DP_SOURCE_UUID) == 0)) {
if (state == BT_HAL_PROFILE_STATE_CONNECTED) {
DBG("A2DP Sink Profile state changed: BT_HAL_PROFILE_STATE_CONNECTED");
__bt_hal_send_a2dp_sink_connection_state_event(TRUE, address);
} else {
ERR("HFP Profile state: Invalid");
}
- } else if (strncmp(profile_uuid, HFP_AG_UUID, strlen(HFP_AG_UUID)) == 0) {
+ } else if (strcmp(profile_uuid, HFP_AG_UUID) == 0) {
if (state == BT_HAL_PROFILE_STATE_CONNECTING)
DBG("HFP Client Profile state changed: BT_PROFILE_STATE_CONNECTING");
else if (state == BT_HAL_PROFILE_STATE_CONNECTED) {
} else {
ERR("HFP Client Profile state: Invalid");
}
- } else if ((strncmp(profile_uuid, AVRCP_TARGET_UUID, strlen(AVRCP_TARGET_UUID)) == 0)) {
+ } else if ((strcmp(profile_uuid, AVRCP_TARGET_UUID) == 0)) {
if (state == BT_HAL_PROFILE_STATE_CONNECTED) {
DBG("AVRCP Controller Profile state changed: BT_HAL_PROFILE_STATE_CONNECTED");
__bt_hal_send_avrcp_ctrl_connection_state_event(TRUE, address);
case HAL_HIDHOST:
hid_event_cb = cb;
break;
+ case HAL_HIDDEVICE:
+ hid_device_event_cb = cb;
+ break;
case HAL_A2DP_SRC:
av_event_cb = cb;
break;
typedef enum {
HAL_HIDHOST,
+ HAL_HIDDEVICE,
HAL_A2DP_SRC,
HAL_A2DP_SNK,
HAL_HF_AG,
--- /dev/null
+/*
+ * bluetooth-frwk
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#include "bt-hal.h"
+#include "bt-hal-log.h"
+#include "bt-hal-msg.h"
+#include "bt-hal-utils.h"
+
+#include "bt-hal-hid-dbus-handler.h"
+#include "bt-hal-event-receiver.h"
+
+static const bthd_callbacks_t *bt_hal_hid_device_cbacks;
+
+static bool interface_ready(void)
+{
+ return bt_hal_hid_device_cbacks != NULL;
+}
+
+static void __bt_hal_handle_conn_state(void *buf, uint16_t len)
+{
+ struct hal_ev_hiddevice_conn_state *ev = buf;
+
+ if (bt_hal_hid_device_cbacks->connection_state_cb)
+ bt_hal_hid_device_cbacks->connection_state_cb((bt_bdaddr_t *) ev->bdaddr,
+ ev->state);
+}
+
+static void __bt_hal_handle_hid_device_events(int message, void *buf, uint16_t len)
+{
+ DBG("+");
+
+ if (!interface_ready())
+ return;
+
+ switch (message) {
+ case HAL_EV_HIDDEVICE_CONN_STATE:
+ DBG("Event: HAL_EV_HIDDEVICE_CONN_STATE");
+ __bt_hal_handle_conn_state(buf, len);
+ break;
+ default:
+ DBG("Event Currently not handled!!");
+ break;
+ }
+
+ DBG("-");
+}
+
+static bt_status_t init(bthd_callbacks_t *callbacks)
+{
+ DBG("");
+
+ if (interface_ready())
+ return BT_STATUS_DONE;
+
+ bt_hal_hid_device_cbacks = callbacks;
+ DBG("Register HID events callback function");
+ _bt_hal_register_event_handler_cb(HAL_HIDDEVICE, __bt_hal_handle_hid_device_events);
+
+ return BT_STATUS_SUCCESS;
+}
+
+static void cleanup(void)
+{
+ DBG("");
+
+ if (!interface_ready())
+ return;
+
+ _bt_hal_unregister_hid_dbus_handler_cb();
+ _bt_hal_unregister_event_handler_cb(HAL_HIDDEVICE);
+
+ bt_hal_hid_device_cbacks = NULL;
+}
+
+static bthd_interface_t hiddevice_if = {
+ .size = sizeof(hiddevice_if),
+ .init = init,
+ .cleanup = cleanup
+};
+
+bthd_interface_t *bt_get_hiddevice_interface(void)
+{
+ return &hiddevice_if;
+}
+
--- /dev/null
+/*
+ * bluetooth-frwk
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __BT_HAL_HIDDEVICE_H__
+#define __BT_HAL_HIDDEVICE_H__
+
+bthd_interface_t *bt_get_hiddevice_interface(void);
+
+#endif /* __BT_HAL_HIDDEVICE_H__ */
+
/* UUIDs */
#define HID_UUID "00001124-0000-1000-8000-00805f9b34fb"
+#define HID_DEVICE_UUID "00001124-0000-1000-8000-00805f9b43bf"
#define A2DP_SINK_UUID "0000110b-0000-1000-8000-00805f9b34fb"
#define A2DP_SOURCE_UUID "0000110a-0000-1000-8000-00805f9b34fb"
#define AVRCP_CTRL_UUID "0000110e-0000-1000-8000-00805f9b34fb"
#define BT_PROFILE_HEALTH_ID "health"
#define BT_PROFILE_SOCKETS_ID "socket"
#define BT_PROFILE_HIDHOST_ID "hidhost"
+#define BT_PROFILE_HIDDEVICE_ID "hiddevice"
#define BT_PROFILE_PAN_ID "pan"
#define BT_PROFILE_MAP_CLIENT_ID "map_client"
--- /dev/null
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_INCLUDE_BT_HD_H
+#define ANDROID_INCLUDE_BT_HD_H
+
+#include <stdint.h>
+
+__BEGIN_DECLS
+
+/* HID Device connection states */
+typedef enum {
+ BTHD_CONN_STATE_CONNECTED = 0,
+ BTHD_CONN_STATE_CONNECTING,
+ BTHD_CONN_STATE_DISCONNECTED,
+ BTHD_CONN_STATE_DISCONNECTING,
+ BTHD_CONN_STATE_UNKNOWN
+} bthd_connection_state_t;
+
+/** Callback for connection state change.
+ * state will have one of the values from bthd_connection_state_t
+ */
+typedef void (*bthd_connection_state_callback)(bt_bdaddr_t *bd_addr, bthd_connection_state_t state);
+
+/** BT-HD callback structure. */
+typedef struct {
+ /** set to sizeof(BtHdCallbacks) */
+ size_t size;
+ bthd_connection_state_callback connection_state_cb;
+} bthd_callbacks_t;
+
+/** Represents the standard BT-HD interface. */
+typedef struct {
+
+ /** set to sizeof(BtHdInterface) */
+ size_t size;
+
+ /**
+ * Register the BtHd callbacks
+ */
+ bt_status_t (*init)(bthd_callbacks_t* callbacks);
+
+ /** Closes the interface. */
+ void (*cleanup)(void);
+
+} bthd_interface_t;
+__END_DECLS
+
+#endif /* ANDROID_INCLUDE_BT_HD_H */
EVENT(OAL_EVENT_OAL_INITIALISED_FAILED) /* OAL Initialisation event */ \
EVENT(OAL_EVENT_HID_CONNECTED) /* event_hid_conn_t */\
EVENT(OAL_EVENT_HID_DISCONNECTED) /* event_hid_conn_t */\
+ EVENT(OAL_EVENT_HID_DEVICE_CONNECTED) /* event_hid_conn_t */\
+ EVENT(OAL_EVENT_HID_DEVICE_DISCONNECTED) /* event_hid_conn_t */\
EVENT(OAL_EVENT_SOCKET_OUTGOING_CONNECTED) /* RFCOMM */ \
EVENT(OAL_EVENT_SOCKET_DISCONNECTED) /* RFCOMM */ \
EVENT(OAL_EVENT_AUDIO_CONNECTING) /* bt_address_t */ \
--- /dev/null
+/*
+ * Open Adaptation Layer (OAL)
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _OAL_HID_DEVICE_H_
+#define _OAL_HID_DEVICE_H_
+
+#include <oal-manager.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Enable HID Device Feature
+ *
+ * @remarks HID Device role will be enabled.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre OAL API must be initialized with oal_bt_init().
+ *
+ * @see hid_device_disable()
+ */
+oal_status_t hid_device_enable(void);
+
+
+/**
+ * @brief Disable HID Device Feature
+ *
+ * @remarks HID Device role will be disabled.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre HID Device should be enabled with hid_device_enable().
+ *
+ * @see hid_device_enable()
+ */
+oal_status_t hid_device_disable(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* _OAL_HID_DEVICE_H_ */
--- /dev/null
+/*
+ * Open Adaptation Layer (OAL)
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <dlog.h>
+#include <string.h>
+
+#include <bluetooth.h>
+#include <bt_hd.h>
+
+#include "oal-event.h"
+#include "oal-internal.h"
+#include "oal-common.h"
+#include "oal-manager.h"
+#include "oal-hid-device.h"
+#include "oal-utils.h"
+
+#define CHECK_OAL_HID_DEVICE_ENABLED() \
+ do { \
+ if (hid_device_api == NULL) { \
+ BT_ERR("HID Device Not Enabled"); \
+ return OAL_STATUS_NOT_READY; \
+ } \
+ } while (0)
+
+static const bthd_interface_t *hid_device_api;
+
+static void connection_state_callback(bt_bdaddr_t *bd_addr, bthd_connection_state_t state)
+{
+ event_hid_conn_t *event = g_new0(event_hid_conn_t, 1);
+ int event_type;
+
+ BT_DBG("%d", state);
+
+ if (!event) {
+ BT_ERR("event is NULL");
+ return;
+ }
+
+ memcpy(event->address.addr, bd_addr->address, BT_ADDRESS_BYTES_NUM);
+
+ event->status = OAL_STATUS_SUCCESS;
+
+ switch (state) {
+ case BTHD_CONN_STATE_CONNECTED:
+ event_type = OAL_EVENT_HID_DEVICE_CONNECTED;
+ break;
+ case BTHD_CONN_STATE_DISCONNECTED:
+ event_type = OAL_EVENT_HID_DEVICE_DISCONNECTED;
+ break;
+ default:
+ BT_ERR("Unhandled Connection state %d", state);
+ g_free(event);
+ return;
+ }
+
+ send_event_bda_trace(event_type, event, sizeof(event_hid_conn_t), (bt_address_t*)bd_addr);
+}
+
+static bthd_callbacks_t sBluetoothHidDeviceCallbacks = {
+ .size = sizeof(sBluetoothHidDeviceCallbacks),
+ .connection_state_cb = connection_state_callback,
+};
+
+oal_status_t hid_device_enable(void)
+{
+ const bt_interface_t *blued_api;
+ int ret;
+
+ API_TRACE();
+ blued_api = adapter_get_stack_interface();
+
+ if (blued_api == NULL) {
+ BT_ERR("Stack is not initialized");
+ return OAL_STATUS_NOT_READY;
+ }
+ if (hid_device_api != NULL) {
+ BT_WARN("HID Device Interface is already initialized...");
+ return OAL_STATUS_ALREADY_DONE;
+ }
+
+ hid_device_api = (const bthd_interface_t *)blued_api->get_profile_interface(BT_PROFILE_HIDDEVICE_ID);
+ if (hid_device_api == NULL) {
+ BT_ERR("HID Device interface failed");
+ return OAL_STATUS_INTERNAL_ERROR;
+ }
+
+ if ((ret = hid_device_api->init(&sBluetoothHidDeviceCallbacks)) != BT_STATUS_SUCCESS) {
+ BT_ERR("HID Device Init failed: %s", status2string(ret));
+ hid_device_api->cleanup();
+ hid_device_api = NULL;
+ return convert_to_oal_status(ret);
+ }
+ return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t hid_device_disable(void)
+{
+ API_TRACE();
+
+ CHECK_OAL_HID_DEVICE_ENABLED();
+
+ hid_device_api->cleanup();
+
+ hid_device_api = NULL;
+ return OAL_STATUS_SUCCESS;
+}
+
./services/bt-service-dpm.c
./services/bt-service-agent-util.c
./services/hid/bt-service-hidhost.c
+./services/hid/bt-service-hiddevice.c
./services/socket/bt-service-socket.c
./services/rfcomm/bt-service-rfcomm.c
./services/audio/bt-service-audio.c
#include "bt-service-dpm.h"
#endif
#include "bt-service-hidhost.h"
+#include "bt-service-hiddevice.h"
#include "bt-service-socket.h"
#include "bt-service-hdp.h"
if (ret != BLUETOOTH_ERROR_NONE)
BT_ERR("_bt_hidhost_initialize Failed");
+ ret = _bt_hiddevice_initialize();
+ if (ret != BLUETOOTH_ERROR_NONE)
+ BT_ERR("_bt_hiddevice_initialize Failed");
+
ret = _bt_socket_init();
if (ret != BLUETOOTH_ERROR_NONE)
BT_ERR("_bt_socket_init Failed");
_bt_service_event_handler_callback adapter_cb;
_bt_service_event_handler_callback device_cb;
_bt_service_event_handler_callback hid_cb;
+_bt_service_event_handler_callback hid_device_cb;
_bt_service_event_handler_callback socket_cb;
_bt_service_event_handler_callback audio_event_cb;
_bt_service_event_handler_callback a2dp_source_cb;
BT_INFO("Register BT_HID_MODULE Callback");
hid_cb = cb;
break;
+ case BT_HID_DEVICE_MODULE:
+ BT_INFO("Register BT_HID_DEVICE_MODULE Callback");
+ hid_device_cb = cb;
+ break;
case BT_SOCKET_MODULE:
BT_INFO("Register BT_SOCKET_MODULE Callback");
socket_cb = cb;
BT_INFO("Un-Register BT_HID_MODULE Callback");
hid_cb = NULL;
break;
+ case BT_HID_DEVICE_MODULE:
+ BT_INFO("Un-Register BT_HID_DEVICE_MODULE Callback");
+ hid_device_cb = NULL;
+ break;
case BT_SOCKET_MODULE:
BT_INFO("Un-Register BT_SOCKET_MODULE Callback");
socket_cb = NULL;
if (hid_cb)
hid_cb(event_type, event_data);
break;
+ case OAL_EVENT_HID_DEVICE_CONNECTED:
+ case OAL_EVENT_HID_DEVICE_DISCONNECTED:
+ if (hid_device_cb)
+ hid_device_cb(event_type, event_data);
+ break;
case OAL_EVENT_SOCKET_OUTGOING_CONNECTED:
case OAL_EVENT_SOCKET_DISCONNECTED:
case OAL_EVENT_SOCKET_AUTHORIZE_REQUEST:
--- /dev/null
+/*
+ * bluetooth-frwk
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <dlog.h>
+#include <string.h>
+
+#include "bt-internal-types.h"
+#include "bt-request-handler.h"
+#include "bt-service-util.h"
+#include "bt-service-event.h"
+#include "bt-service-event-receiver.h"
+#include "bt-service-common.h"
+#include "bt-service-hiddevice.h"
+#include "oal-event.h"
+#include "oal-hid-device.h"
+
+static void __bt_hid_device_event_handler(int event_type, gpointer event_data)
+{
+ char address[BT_ADDRESS_STRING_SIZE];
+ int result = BLUETOOTH_ERROR_NONE;
+ event_hid_conn_t *event = event_data;
+
+ BT_DBG("+");
+
+ if (event == NULL)
+ return;
+
+ memset(address, 0x00, BT_ADDRESS_STRING_SIZE);
+ _bt_convert_addr_type_to_string(address, event->address.addr);
+
+ switch (event_type) {
+ case OAL_EVENT_HID_DEVICE_CONNECTED:
+ _bt_send_event(BT_HID_DEVICE_EVENT,
+ BLUETOOTH_HID_DEVICE_CONNECTED,
+ g_variant_new("(is)", result, address));
+ break;
+ case OAL_EVENT_HID_DEVICE_DISCONNECTED:
+ _bt_send_event(BT_HID_DEVICE_EVENT,
+ BLUETOOTH_HID_DEVICE_DISCONNECTED,
+ g_variant_new("(is)", result, address));
+ break;
+ default:
+ BT_ERR("Unhandled event: %d", event_type);
+ }
+
+ BT_DBG("-");
+}
+
+int _bt_hiddevice_initialize()
+{
+ BT_DBG("+");
+
+ /* Enable HID Device Profile */
+ if (OAL_STATUS_SUCCESS != hid_device_enable()) {
+ BT_ERR("HID Device Enable failed");
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ /* Register HID Device event handler */
+ _bt_service_register_event_handler_callback(
+ BT_HID_DEVICE_MODULE, __bt_hid_device_event_handler);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+void _bt_hiddevice_deinitialize()
+{
+ BT_DBG("+");
+
+ /* Unregister HID Device event handler */
+ _bt_service_unregister_event_handler_callback(BT_HID_DEVICE_MODULE);
+
+ /* Disable HID Device Profile */
+ hid_device_disable();
+}
+
BT_ADAPTER_MODULE,
BT_DEVICE_MODULE,
BT_HID_MODULE,
+ BT_HID_DEVICE_MODULE,
BT_SOCKET_MODULE,
BT_A2DP_SOURCE_MODULE,
BT_A2DP_SINK_MODULE,
--- /dev/null
+/*
+ * bluetooth-frwk
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __BT_SERVICE_HIDDEVICE_H__
+#define __BT_SERVICE_HIDDEVICE_H__
+
+#include "bluetooth-api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int _bt_hiddevice_initialize(void);
+void _bt_hiddevice_deinitialize(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __BT_SERVICE_HIDDEVICE_H__ */