diff --git a/android/socket.c b/android/socket.c
index 9f8c535..740907b 100644
--- a/android/socket.c
+++ b/android/socket.c
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
#include "src/sdp-client.h"
+#include "src/sdpd.h"
+#include "bluetooth.h"
#include "log.h"
#include "hal-msg.h"
#include "hal-ipc.h"
guint stack_watch;
bdaddr_t dst;
+ uint32_t service_handle;
};
static struct rfcomm_sock *create_rfsock(int sock, int *hal_fd)
if (!g_source_remove(rfsock->stack_watch))
error("stack_watch source was not found");
+ if (rfsock->service_handle)
+ bt_adapter_remove_record(rfsock->service_handle);
+
g_free(rfsock);
}
uint8_t channel;
uint8_t svc_hint;
BtIOSecLevel sec_level;
- sdp_record_t * (*create_record)(uint8_t chan);
+ sdp_record_t * (*create_record)(uint8_t chan, const char *svc_name);
} profiles[] = {
{
.uuid = {
}
};
+static uint32_t sdp_service_register(struct profile_info *profile,
+ const void *svc_name)
+{
+ sdp_record_t *record;
+
+ if (!profile || !profile->create_record)
+ return 0;
+
+ record = profile->create_record(profile->channel, svc_name);
+ if (!record)
+ return 0;
+
+ if (bt_adapter_add_record(record, profile->svc_hint) < 0) {
+ error("Failed to register on SDP record");
+ sdp_record_free(record);
+ return 0;
+ }
+
+ return record->handle;
+}
+
static int bt_sock_send_fd(int sock_fd, const void *buf, int len, int send_fd)
{
ssize_t ret;
chan = profile->channel;
- DBG("rfcomm channel %d", chan);
+ DBG("rfcomm channel %d svc_name %s", chan, cmd->name);
rfsock = create_rfsock(-1, &hal_fd);
if (!rfsock)
return -1;
}
+ rfsock->service_handle = sdp_service_register(profile, cmd->name);
+
return hal_fd;
}