summaryrefslogtreecommitdiff
path: root/src/bluetooth-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth-common.c')
-rw-r--r--src/bluetooth-common.c79
1 files changed, 78 insertions, 1 deletions
diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c
index b3f328f..da623f9 100644
--- a/src/bluetooth-common.c
+++ b/src/bluetooth-common.c
@@ -301,6 +301,10 @@ static bt_event2index_table_t event2index[] = {
{ BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED, BT_EVENT_MESH_NODE_MODEL_GROUP_VIR_SUB },
{ BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, BT_EVENT_MESH_NODE_MODEL_PUBLICATION },
{ BLUETOOTH_EVENT_MESH_JOIN_COMPLETED, BT_EVENT_MESH_JOIN_NETWORK },
+ { BLUETOOTH_EVENT_L2CAP_LE_DATA_RECEIVED, BT_EVENT_DATA_RECEIVED},
+ { BLUETOOTH_EVENT_L2CAP_LE_CONNECTED, BT_EVENT_L2CAP_CHANNEL_CONNECTION_STATE_CHANGED},
+ { BLUETOOTH_EVENT_L2CAP_LE_DISCONNECTED, BT_EVENT_L2CAP_CHANNEL_CONNECTION_STATE_CHANGED},
+ { BLUETOOTH_EVENT_L2CAP_LE_AUTHORIZE, BT_EVENT_L2CAP_CHANNEL_CONNECTION_REQUESTED},
{ 0, -1 }
};
@@ -1554,6 +1558,10 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
bt_ipsp_connection_info_t *bt_ipsp_iface_info = NULL;
bt_pxp_property_changed_params_t *bt_pxp_property_info = NULL;
bluetooth_tds_activation_req_t *tds_act_req_info = NULL;
+ bluetooth_l2cap_le_connection_t *l2cap_le_connection_ind = NULL;
+ bluetooth_l2cap_le_disconnection_t *l2cap_le_disconnection_ind = NULL;
+ bluetooth_l2cap_le_connection_request_t *l2cap_le_request_ind = NULL;
+ bt_socket_l2cap_le_connection_s l2cap_le_connection;
#ifdef TIZEN_GATT_CLIENT
bt_gatt_char_property_t *char_prop = NULL;
@@ -4287,7 +4295,76 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
(_bt_get_error_code(param->result), (bt_mesh_node_h) info,
bt_event_slot_container[event_index].user_data);
break;
- }
+ } case BLUETOOTH_EVENT_L2CAP_LE_DATA_RECEIVED:
+ BT_INFO("L2CAP_LE: bt_socket_data_received_cb() will be * called");
+ ((bt_socket_data_received_cb)bt_event_slot_container[event_index].callback)
+ ((bt_socket_received_data_s *)(param->param_data), bt_event_slot_container[event_index].user_data);
+ break;
+ case BLUETOOTH_EVENT_L2CAP_LE_CONNECTED:
+ BT_INFO("L2CAP_LE: bt_socket_l2cap_channel_connection_state_changed_cb() will be called with BT_SOCKET_CONNECTED");
+ if (param->result == BLUETOOTH_ERROR_INVALID_PARAM)
+ error_code = BT_ERROR_OPERATION_FAILED;
+ else
+ error_code = _bt_get_error_code(param->result);
+
+ memset(&l2cap_le_connection, 0x00, sizeof(bt_socket_l2cap_le_connection_s));
+ l2cap_le_connection_ind = (bluetooth_l2cap_le_connection_t *)(param->param_data);
+
+ if (l2cap_le_connection_ind) {
+ l2cap_le_connection.socket_fd = l2cap_le_connection_ind->socket_fd;
+ l2cap_le_connection.local_role = l2cap_le_connection_ind->device_role;
+ l2cap_le_connection.server_fd = l2cap_le_connection_ind->server_id;
+ l2cap_le_connection.psm = l2cap_le_connection_ind->psm;
+
+ BT_INFO("L2CAP_LE PSM[%d] FD[%d] Role [%d] serverFD [%d]", l2cap_le_connection_ind->psm,
+ l2cap_le_connection_ind->socket_fd, (int)l2cap_le_connection_ind->device_role,
+ l2cap_le_connection_ind->server_id);
+
+ _bt_convert_address_to_string(&(l2cap_le_connection.remote_address),
+ &(l2cap_le_connection_ind->device_addr));
+ }
+
+ ((bt_socket_l2cap_channel_connection_state_changed_cb)bt_event_slot_container[event_index].callback)
+ (error_code, BT_SOCKET_CONNECTED, &l2cap_le_connection, bt_event_slot_container[event_index].user_data);
+
+ if (l2cap_le_connection.remote_address != NULL) {
+ free(l2cap_le_connection.remote_address);
+ l2cap_le_connection.remote_address = NULL;
+ }
+ break;
+ case BLUETOOTH_EVENT_L2CAP_LE_DISCONNECTED:
+ BT_INFO("L2CAP_LE: bt_socket_l2cap_channel_connection_state_changed_cb() will be called with BT_SOCKET_DISCONNECTED");
+
+ memset(&l2cap_le_connection, 0x00, sizeof(bt_socket_l2cap_le_connection_s));
+ l2cap_le_disconnection_ind = (bluetooth_l2cap_le_disconnection_t *)(param->param_data);
+
+ if (l2cap_le_disconnection_ind) {
+ l2cap_le_connection.socket_fd = l2cap_le_disconnection_ind->socket_fd;
+ l2cap_le_connection.local_role = l2cap_le_disconnection_ind->device_role;
+ l2cap_le_connection.psm = l2cap_le_disconnection_ind->psm;
+
+ _bt_convert_address_to_string(&(l2cap_le_connection.remote_address),
+ &(l2cap_le_disconnection_ind->device_addr));
+ }
+
+ ((bt_socket_l2cap_channel_connection_state_changed_cb)bt_event_slot_container[event_index].callback)
+ (_bt_get_error_code(param->result), BT_SOCKET_DISCONNECTED, &l2cap_le_connection, bt_event_slot_container[event_index].user_data);
+
+ if (l2cap_le_connection.remote_address != NULL) {
+ free(l2cap_le_connection.remote_address);
+ l2cap_le_connection.remote_address = NULL;
+ }
+ break;
+ case BLUETOOTH_EVENT_L2CAP_LE_AUTHORIZE:
+ BT_INFO("L2CAP_LE: Authorize bt_socket_connection_requested_cb() will be called");
+ l2cap_le_request_ind = (bluetooth_l2cap_le_connection_request_t *)(param->param_data);
+ _bt_convert_address_to_string(&device_addr, &(l2cap_le_request_ind->device_addr));
+ ((bt_socket_connection_requested_cb)bt_event_slot_container[event_index].callback)
+ (l2cap_le_request_ind->socket_fd, device_addr, bt_event_slot_container[event_index].user_data);
+
+ if (device_addr != NULL)
+ free(device_addr);
+ break;
default:
BT_INFO("Unknown function");
break;