- Add capability to the server to handle Command Status events
- Add capability to reply the inquiry started command status git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24700 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d581ede6e2
commit
fd223db5ad
@ -63,17 +63,21 @@ LocalDeviceHandler::AddWantedEvent(BMessage* msg)
|
|||||||
fEventsWanted.Unlock();
|
fEventsWanted.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LocalDeviceHandler::ClearWantedEvent(BMessage* msg)
|
||||||
|
{
|
||||||
|
fEventsWanted.Lock();
|
||||||
|
fEventsWanted.RemoveMessage(msg);
|
||||||
|
fEventsWanted.Unlock();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event = 0, uint16 opcode = 0)
|
LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event, uint16 opcode = 0)
|
||||||
{
|
{
|
||||||
// Remove the whole petition from queue
|
// Remove the whole petition from queue
|
||||||
fEventsWanted.Lock();
|
fEventsWanted.Lock();
|
||||||
/*
|
|
||||||
if (event == 0) {
|
|
||||||
fEventsWanted.RemoveMessage(msg);
|
|
||||||
goto bail;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16 eventFound;
|
int16 eventFound;
|
||||||
int16 opcodeFound;
|
int16 opcodeFound;
|
||||||
@ -89,17 +93,19 @@ LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event = 0, uint16 opc
|
|||||||
if (eventFound == event) {
|
if (eventFound == event) {
|
||||||
|
|
||||||
// there is an opcode specified
|
// there is an opcode specified
|
||||||
if (opcde != 0)
|
if (opcode != 0) {
|
||||||
|
|
||||||
// The opcode matches
|
// The opcode matches
|
||||||
if ( (msg->FindInt16("opcodeExpected", eventIndex, &opcodeFound) == B_OK) &&
|
if ( (msg->FindInt16("opcodeExpected", eventIndex, &opcodeFound) == B_OK) &&
|
||||||
((uint16)opcodeFound != opcode) ) {
|
((uint16)opcodeFound != opcode) ) {
|
||||||
|
|
||||||
|
// FIX: this should remove only the entry
|
||||||
fEventsWanted.RemoveMessage(msg);
|
fEventsWanted.RemoveMessage(msg);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Event matches so far
|
// Event matches so far
|
||||||
|
// FIX: this should remove only the entry
|
||||||
fEventsWanted.RemoveMessage(msg);
|
fEventsWanted.RemoveMessage(msg);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -109,9 +115,9 @@ LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event = 0, uint16 opc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bail: */
|
bail:
|
||||||
fEventsWanted.RemoveMessage(msg);
|
|
||||||
|
fEventsWanted.RemoveMessage(msg);
|
||||||
fEventsWanted.Unlock();
|
fEventsWanted.Unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,9 @@ protected:
|
|||||||
BMessage* fProperties;
|
BMessage* fProperties;
|
||||||
|
|
||||||
void AddWantedEvent(BMessage* msg);
|
void AddWantedEvent(BMessage* msg);
|
||||||
void ClearWantedEvent(BMessage* msg, uint16 code, uint16 opcode = 0);
|
void ClearWantedEvent(BMessage* msg, uint16 event, uint16 opcode = 0);
|
||||||
|
void ClearWantedEvent(BMessage* msg);
|
||||||
|
|
||||||
BMessage* FindPetition(uint16 event, uint16 opcode = 0);
|
BMessage* FindPetition(uint16 event, uint16 opcode = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include <bluetooth/bluetooth_error.h>
|
#include <bluetooth/bluetooth_error.h>
|
||||||
#include <bluetooth/HCI/btHCI_event.h>
|
#include <bluetooth/HCI/btHCI_event.h>
|
||||||
|
|
||||||
|
#include <bluetoothserver_p.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
@ -91,8 +93,12 @@ printf("### \n");
|
|||||||
(Output::Instance()->Post("Incoming Command Complete\n", BLACKBOARD_EVENTS));
|
(Output::Instance()->Post("Incoming Command Complete\n", BLACKBOARD_EVENTS));
|
||||||
request = FindPetition(event->ecode, ((struct hci_ev_cmd_complete*)(event+1))->opcode );
|
request = FindPetition(event->ecode, ((struct hci_ev_cmd_complete*)(event+1))->opcode );
|
||||||
|
|
||||||
|
} else if ( event->ecode == HCI_EVENT_CMD_STATUS ) {
|
||||||
|
|
||||||
|
(Output::Instance()->Post("Incoming Command Complete\n", BLACKBOARD_EVENTS));
|
||||||
|
request = FindPetition(event->ecode, ((struct hci_ev_cmd_status*)(event+1))->opcode );
|
||||||
|
|
||||||
} else
|
} else
|
||||||
// TODO: Command status should also be considered
|
|
||||||
{
|
{
|
||||||
request = FindPetition(event->ecode);
|
request = FindPetition(event->ecode);
|
||||||
}
|
}
|
||||||
@ -145,6 +151,7 @@ printf("### \n");
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_CMD_STATUS:
|
case HCI_EVENT_CMD_STATUS:
|
||||||
|
CommandStatus((struct hci_ev_cmd_status*)(event+1), request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_FLUSH_OCCUR:
|
case HCI_EVENT_FLUSH_OCCUR:
|
||||||
@ -313,6 +320,52 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* request) {
|
||||||
|
|
||||||
|
int16 opcodeExpected;
|
||||||
|
BMessage reply;
|
||||||
|
|
||||||
|
Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD_OFFSET + GetID());
|
||||||
|
Output::Instance()->Post("\n", BLACKBOARD_LD_OFFSET + GetID());
|
||||||
|
|
||||||
|
// Handle command complete information
|
||||||
|
request->FindInt16("opcodeExpected", 0 /*REVIEW!*/, &opcodeExpected);
|
||||||
|
|
||||||
|
|
||||||
|
if (request->IsSourceWaiting() == false)
|
||||||
|
Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);
|
||||||
|
|
||||||
|
|
||||||
|
switch (opcodeExpected) {
|
||||||
|
|
||||||
|
case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR):
|
||||||
|
{
|
||||||
|
struct hci_ev_cmd_status* commandStatus = (struct hci_ev_cmd_status*)(event+1);
|
||||||
|
|
||||||
|
reply.what = BT_MSG_INQUIRY_STARTED;
|
||||||
|
reply.AddInt8("status", commandStatus->status);
|
||||||
|
|
||||||
|
if (commandStatus->status == BT_OK) {
|
||||||
|
Output::Instance()->Post("Positive reply for inquiry\n", BLACKBOARD_KIT);
|
||||||
|
} else {
|
||||||
|
Output::Instance()->Post("Negative reply for friendly name\n", BLACKBOARD_KIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Sending reply ... %ld\n",request->SendReply(&reply));
|
||||||
|
reply.PrintToStream();
|
||||||
|
|
||||||
|
ClearWantedEvent(request, PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Output::Instance()->Post("Command Status not handled\n", BLACKBOARD_KIT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#pragma mark - Request Methods -
|
#pragma mark - Request Methods -
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
|
|
||||||
/* Events handling */
|
/* Events handling */
|
||||||
void CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request);
|
void CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request);
|
||||||
|
void CommandStatus(struct hci_ev_cmd_status* event, BMessage* request);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user