#include "bt-common.h"
#include "bt-request-sender.h"
#include "bt-event-handler.h"
-
-#ifdef TIZEN_FEATURE_BT_DPM
#include "bt-dpm.h"
-#endif
#define BLUETOOTH_SOCK_CONNECT_INFO_LEN 16
#define BATTERY_MONITOR_RFCOMM_INTERVAL 5
static bool __rfcomm_record_rx_data(void)
{
- BT_INFO("");
- if (bluetooth_get_battery_monitor_state()) {
- if (rx_data) {
- int ret = _bt_common_send_rfcomm_rx_details(rx_data);
- if (ret == BLUETOOTH_ERROR_NONE) {
- rx_data = 0;
- return TRUE;
- }
- else {
- BT_ERR("RFCOMM rx data could not be registered");
- }
+ if (rx_data) {
+ int ret = _bt_common_send_rfcomm_rx_details(rx_data);
+ if (ret == BLUETOOTH_ERROR_NONE) {
+ rx_data = 0;
+ return TRUE;
+ } else {
+ BT_ERR("RFCOMM rx data could not be registered");
}
}
+
+ rx_data = 0;
rx_tag = 0;
+
return FALSE;
}
BT_INFO_C("### Connected [RFCOMM Server]");
+ if (_bt_common_send_rfcomm_conn_info(RFCOMM_ROLE_SERVER,
+ TRUE, conn_info.socket_fd) != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Fail to send the connection info");
+
_bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_CONNECTED,
BLUETOOTH_ERROR_NONE, &conn_info,
event_info->cb, event_info->user_data);
BT_INFO("Disconnected FD [%d]", conn->fd);
disconn_info.socket_fd = conn->fd;
+ if (_bt_common_send_rfcomm_conn_info(RFCOMM_ROLE_SERVER,
+ FALSE, disconn_info.socket_fd) != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Fail to send the connection info");
+
_bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_DISCONNECTED,
BLUETOOTH_ERROR_NONE, &disconn_info,
event_info->cb, event_info->user_data);
if (bluetooth_get_battery_monitor_state()) {
if (rx_tag == 0) {
- BT_INFO("Adding rfcomm rx timeout function for battery monitor");
+ BT_DBG("Adding rfcomm rx timeout function for battery monitor");
rx_tag = g_timeout_add_seconds(BATTERY_MONITOR_RFCOMM_INTERVAL, (GSourceFunc)__rfcomm_record_rx_data, NULL);
}
rx_data += len;
return -1;
}
-#ifdef TIZEN_FEATURE_BT_DPM
if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
char addr_str[20];
return -1;
}
-#endif
conn = g_new0(rfcomm_conn_t, 1);
conn->fd = fd;
object_id = _bt_register_new_conn(path, new_server_connection);
if (object_id < 0) {
__rfcomm_delete_id(id);
+ g_free(path);
return NULL;
}
info = g_new0(rfcomm_info_t, 1);
return;
}
+
+void _bt_rfcomm_server_reset_timer(void)
+{
+ if (rx_tag > 0) {
+ g_source_remove(rx_tag);
+ rx_tag = 0;
+ }
+
+ rx_data = 0;
+}
#else
#define BT_RFCOMM_SERVER_ID_MAX 254
return BLUETOOTH_ERROR_PERMISSION_DEINED;
}
-#ifdef TIZEN_FEATURE_BT_DPM
if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
BT_ERR("Not allow to use SPP profile");
return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
}
-#endif
#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
BT_INFO("<<<<<<<<< RFCOMM Create socket from app >>>>>>>>>");
return BLUETOOTH_ERROR_PERMISSION_DEINED;
}
-#ifdef TIZEN_FEATURE_BT_DPM
if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
BT_ERR("Not allow to use SPP profile");
return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
}
-#endif
BT_INFO("<<<<<<<<< RFCOMM Create socket from app >>>>>>>>>");
info = __register_method_2(path, bus_name);
return BLUETOOTH_ERROR_INVALID_PARAM;
}
-#ifdef TIZEN_FEATURE_BT_DPM
if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
BT_ERR("Not allow to use SPP profile");
return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
}
-#endif
#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
BT_INFO("RFCOMM Listen & accept from app");
BT_CHECK_ENABLED(return);
-#ifdef TIZEN_FEATURE_BT_DPM
if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
BT_ERR("Not allow to use SPP profile");
return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
}
-#endif
BT_INFO("RFCOMM Listen & accept from app");
return BLUETOOTH_ERROR_INVALID_PARAM;
}
-#ifdef TIZEN_FEATURE_BT_DPM
if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
BT_ERR("Not allow to use SPP profile");
return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
}
-#endif
#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
BT_INFO("RFCOMM Listen");
BT_CHECK_ENABLED(return);
-#ifdef TIZEN_FEATURE_BT_DPM
if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
BT_ERR("Not allow to use SPP profile");
return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
}
-#endif
if (server_fd < 0) {
BT_ERR("Invalid FD");