diff options
author | Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com> | 2014-02-11 17:58:18 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-02-12 13:50:49 +0100 |
commit | 6c411b18321ebebfddba5e12e4a8ea008a277a43 (patch) | |
tree | 501a38d0cc5413bef0ee111575ae3831f980a90b /android/socket.c | |
parent | a41087b916096ee69c9d0dbf76e127dfc046bb31 (diff) | |
download | bluez-6c411b18321ebebfddba5e12e4a8ea008a277a43.tar.gz |
android/socket: Register SDP record for application service
This patch adds SDP record for services registered from application
(other than built-in services).
Diffstat (limited to 'android/socket.c')
-rw-r--r-- | android/socket.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/android/socket.c b/android/socket.c index 22827b710..876439bd8 100644 --- a/android/socket.c +++ b/android/socket.c @@ -350,6 +350,22 @@ static sdp_record_t *create_spp_record(uint8_t chan, const char *svc_name) return record; } +static sdp_record_t *create_app_record(uint8_t chan, + const uint8_t *app_uuid, + const char *svc_name) +{ + sdp_record_t *record; + uuid_t uuid; + + sdp_uuid128_create(&uuid, app_uuid); + + record = create_rfcomm_record(chan, &uuid, svc_name, false); + if (!record) + return NULL; + + return record; +} + static const struct profile_info { uint8_t uuid[16]; uint8_t channel; @@ -396,19 +412,24 @@ static const struct profile_info { }, }; -static uint32_t sdp_service_register(const struct profile_info *profile, - const void *svc_name) +static uint32_t sdp_service_register(uint8_t channel, const uint8_t *uuid, + const struct profile_info *profile, + const void *svc_name) { - sdp_record_t *record; - - if (!profile || !profile->create_record) - return 0; + sdp_record_t *record = NULL; + uint8_t svc_hint = 0; + + if (profile && profile->create_record) { + record = profile->create_record(channel, svc_name); + svc_hint = profile->svc_hint; + } else if (uuid) { + record = create_app_record(channel, uuid, svc_name); + } - record = profile->create_record(profile->channel, svc_name); if (!record) return 0; - if (bt_adapter_add_record(record, profile->svc_hint) < 0) { + if (bt_adapter_add_record(record, svc_hint) < 0) { error("Failed to register on SDP record"); sdp_record_free(record); return 0; @@ -782,7 +803,8 @@ static uint8_t rfcomm_listen(int chan, const uint8_t *name, const uint8_t *uuid, goto failed; } - rfsock->service_handle = sdp_service_register(profile, name); + rfsock->service_handle = sdp_service_register(chan, uuid, profile, + name); servers[chan].rfsock = rfsock; |