#endif
#define BLUETOOTH_SOCK_CONNECT_INFO_LEN 16
+#define BATTERY_MONITOR_RFCOMM_INTERVAL 5
#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
guint disconnect_idle_id;
} rfcomm_info_t;
+static unsigned int rx_data = 0;
+static guint rx_tag = 0;
+
+static bool __rfcomm_record_rx_data(void)
+{
+ 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;
+}
+
static rfcomm_info_t *__find_rfcomm_info_with_id(int id)
{
GSList *l;
for (l = rfcomm_nodes; l != NULL; l = l->next) {
rfcomm_info_t *info = l->data;
- if (g_strcmp0(info->path, path) == 0)
+ if (g_ascii_strcasecmp(info->path, path) == 0)
return info;
}
for (l = rfcomm_nodes; l != NULL; l = l->next) {
rfcomm_info_t *info = l->data;
- if (g_strcmp0(info->uuid, uuid) == 0)
+ if (g_ascii_strcasecmp(info->uuid, uuid) == 0)
return info;
}
if (!info)
return FALSE;
- if (strcmp(info->uuid, uuid) == 0)
+ if (g_ascii_strcasecmp(info->uuid, uuid) == 0)
return TRUE;
return FALSE;
conn_info.server_id = info->id;
BT_INFO_C("### Connected [RFCOMM Server]");
+
_bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_CONNECTED,
BLUETOOTH_ERROR_NONE, &conn_info,
event_info->cb, event_info->user_data);
result, &data_r,
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");
+ rx_tag = g_timeout_add_seconds(BATTERY_MONITOR_RFCOMM_INTERVAL, (GSourceFunc)__rfcomm_record_rx_data, NULL);
+ }
+ rx_data += len;
+ }
+
g_free(buffer);
return TRUE;
GSList *conn;
char addr[20];
- BT_INFO("### Disconnect all RFCOMM server connections");
+ BT_INFO(" ### Disconnect all RFCOMM server connections");
for (server = rfcomm_nodes; server; ) {
rfcomm_info_t *info = server->data;
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 FALSE;
}
-static int __rfcomm_listen(rfcomm_server_info_t *server_info)
+static int __rfcomm_listen(rfcomm_server_info_t *server_info, bool accept)
{
int result;
GUnixFDList *out_fd_list = NULL;
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
- g_array_append_vals(in_param1, server_info->uuid, BLUETOOTH_UUID_STRING_MAX);
- result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
- in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+ if (accept == false) {
+ g_array_append_vals(in_param1, server_info->uuid, BLUETOOTH_UUID_STRING_MAX);
+ result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
+ in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+ } else {
+ g_array_append_vals(in_param1, server_info->uuid, BLUETOOTH_UUID_STRING_MAX);
+ result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN_AND_ACCEPT,
+ in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+ }
BT_DBG("result: %x", result);
if (result != BLUETOOTH_ERROR_NONE) {
char address[20];
- BT_INFO("### Disconnect RFCOMM server");
+ BT_INFO(" ### Disconnect RFCOMM server");
if (socket_fd < 0) {
BT_ERR("Invalid FD");
return BLUETOOTH_ERROR_INVALID_PARAM;
server_info->max_pending_conn = max_pending_connection;
server_info->auto_accept = TRUE;
- return __rfcomm_listen(server_info);
+ return __rfcomm_listen(server_info, true);
#endif
}
server_info->max_pending_conn = max_pending_connection;
server_info->auto_accept = FALSE;
- return __rfcomm_listen(server_info);
+ return __rfcomm_listen(server_info, false);
#endif
}