From 585f2ec6815f217f3b7ea633366ec94c53acdf0a Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Fri, 25 Jul 2008 19:37:19 +0000 Subject: [PATCH] In some cases the remote name request is never returning us the event containing the name. It fails, the reason could be that the command has some differences in the fields depending on the BT version. This is handling the error code properly in this fail case avoiding the wait. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26637 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/bluetooth/RemoteDevice.cpp | 22 ++++++++++++++++------ src/servers/bluetooth/LocalDeviceImpl.cpp | 12 ++++++++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/kits/bluetooth/RemoteDevice.cpp b/src/kits/bluetooth/RemoteDevice.cpp index 82e59bcac6..599acfc383 100644 --- a/src/kits/bluetooth/RemoteDevice.cpp +++ b/src/kits/bluetooth/RemoteDevice.cpp @@ -10,13 +10,15 @@ #include #include #include - #include -#include #include #include + +#include + #include +#include #include "KitSupport.h" @@ -73,13 +75,21 @@ RemoteDevice::GetFriendlyName(bool alwaysAsk) BString name; int8 status; - if (reply.FindInt8("status", &status) == B_OK && - reply.FindString("friendlyname", &name) == B_OK ) { - return name; + if ((reply.FindInt8("status", &status) == B_OK) && (status == BT_OK)) { + + if ((reply.FindString("friendlyname", &name) == B_OK ) ) { + return name; + } else { + return BString("");// should not happen } + + } else { + // seems we got a netative event + return BString("#CommandFailed#Not Valid name"); + } } - return BString("#NotCompletedRequestr#Not Valid name"); + return BString("#NotCompletedRequest#Not Valid name"); } diff --git a/src/servers/bluetooth/LocalDeviceImpl.cpp b/src/servers/bluetooth/LocalDeviceImpl.cpp index 77a68f9c7e..89a10146a6 100644 --- a/src/servers/bluetooth/LocalDeviceImpl.cpp +++ b/src/servers/bluetooth/LocalDeviceImpl.cpp @@ -426,7 +426,16 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques case PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST): { - ClearWantedEvent(request, HCI_EVENT_CMD_STATUS, PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST)); + if (event->status==BT_OK) { + ClearWantedEvent(request, HCI_EVENT_CMD_STATUS, PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST)); + } + else { + BMessage reply; + reply.AddInt8("status", event->status); + Output::Instance()->Post("Negative reply for remote friendly name\n", BLACKBOARD_KIT); + printf("Sending reply ... %ld\n", request->SendReply(&reply)); + ClearWantedEvent(request); + } } break; /* @@ -504,7 +513,6 @@ LocalDeviceImpl::RemoteNameRequestComplete(struct hci_ev_remote_name_request_com // This request is not gonna be used anymore ClearWantedEvent(request); - }