Fix a serious TODO,
Report the index where the event opcode pair has been found. Currently server was expecting them to be the first entry of the request git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26198 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5c5b7a5760
commit
480cccf67b
@ -123,7 +123,7 @@ bail:
|
|||||||
|
|
||||||
|
|
||||||
BMessage*
|
BMessage*
|
||||||
LocalDeviceHandler::FindPetition(uint16 event, uint16 opcode)
|
LocalDeviceHandler::FindPetition(uint16 event, uint16 opcode, int32* indexFound)
|
||||||
{
|
{
|
||||||
int16 eventFound;
|
int16 eventFound;
|
||||||
int16 opcodeFound;
|
int16 opcodeFound;
|
||||||
@ -137,6 +137,7 @@ LocalDeviceHandler::FindPetition(uint16 event, uint16 opcode)
|
|||||||
printf("Petition %ld ... of %ld msg #%p\n", index, fEventsWanted.CountMessages(), msg);
|
printf("Petition %ld ... of %ld msg #%p\n", index, fEventsWanted.CountMessages(), msg);
|
||||||
msg->PrintToStream();
|
msg->PrintToStream();
|
||||||
eventIndex = 0;
|
eventIndex = 0;
|
||||||
|
|
||||||
// for each Event
|
// for each Event
|
||||||
while (msg->FindInt16("eventExpected", eventIndex, &eventFound) == B_OK ) {
|
while (msg->FindInt16("eventExpected", eventIndex, &eventFound) == B_OK ) {
|
||||||
if (eventFound == event) {
|
if (eventFound == event) {
|
||||||
@ -154,6 +155,8 @@ LocalDeviceHandler::FindPetition(uint16 event, uint16 opcode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fEventsWanted.Unlock();
|
fEventsWanted.Unlock();
|
||||||
|
if (indexFound != NULL)
|
||||||
|
*indexFound = eventIndex;
|
||||||
return msg;
|
return msg;
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ protected:
|
|||||||
void ClearWantedEvent(BMessage* msg, uint16 event, uint16 opcode = 0);
|
void ClearWantedEvent(BMessage* msg, uint16 event, uint16 opcode = 0);
|
||||||
void ClearWantedEvent(BMessage* msg);
|
void ClearWantedEvent(BMessage* msg);
|
||||||
|
|
||||||
BMessage* FindPetition(uint16 event, uint16 opcode = 0);
|
BMessage* FindPetition(uint16 event, uint16 opcode = 0, int32* indexFound = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -98,17 +98,18 @@ printf("### \n");
|
|||||||
|
|
||||||
|
|
||||||
BMessage* request = NULL;
|
BMessage* request = NULL;
|
||||||
|
int32 eventIndexLocation;
|
||||||
|
|
||||||
// Check if its a requested one
|
// Check if its a requested one
|
||||||
if ( event->ecode == HCI_EVENT_CMD_COMPLETE ) {
|
if ( event->ecode == HCI_EVENT_CMD_COMPLETE ) {
|
||||||
|
|
||||||
(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, &eventIndexLocation );
|
||||||
|
|
||||||
} else if ( event->ecode == HCI_EVENT_CMD_STATUS ) {
|
} else if ( event->ecode == HCI_EVENT_CMD_STATUS ) {
|
||||||
|
|
||||||
(Output::Instance()->Post("Incoming Command Status\n", BLACKBOARD_EVENTS));
|
(Output::Instance()->Post("Incoming Command Status\n", BLACKBOARD_EVENTS));
|
||||||
request = FindPetition(event->ecode, ((struct hci_ev_cmd_status*)(event+1))->opcode );
|
request = FindPetition(event->ecode, ((struct hci_ev_cmd_status*)(event+1))->opcode, &eventIndexLocation );
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -160,11 +161,11 @@ printf("### \n");
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_CMD_COMPLETE:
|
case HCI_EVENT_CMD_COMPLETE:
|
||||||
CommandComplete((struct hci_ev_cmd_complete*)(event+1), request);
|
CommandComplete((struct hci_ev_cmd_complete*)(event+1), request, eventIndexLocation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_CMD_STATUS:
|
case HCI_EVENT_CMD_STATUS:
|
||||||
CommandStatus((struct hci_ev_cmd_status*)(event+1), request);
|
CommandStatus((struct hci_ev_cmd_status*)(event+1), request, eventIndexLocation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_FLUSH_OCCUR:
|
case HCI_EVENT_FLUSH_OCCUR:
|
||||||
@ -230,7 +231,7 @@ printf("### \n");
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request) {
|
LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request, int32 index) {
|
||||||
|
|
||||||
int16 opcodeExpected;
|
int16 opcodeExpected;
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
@ -241,7 +242,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
|
|||||||
// Handle command complete information
|
// Handle command complete information
|
||||||
// FIX ME! the expected code might me in another
|
// FIX ME! the expected code might me in another
|
||||||
// index as is relative to the event not the request
|
// index as is relative to the event not the request
|
||||||
request->FindInt16("opcodeExpected", 0 /*REVIEW!*/, &opcodeExpected);
|
request->FindInt16("opcodeExpected", index, &opcodeExpected);
|
||||||
|
|
||||||
|
|
||||||
if (request->IsSourceWaiting() == false)
|
if (request->IsSourceWaiting() == false)
|
||||||
@ -332,7 +333,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* request) {
|
LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* request, int32 index) {
|
||||||
|
|
||||||
int16 opcodeExpected;
|
int16 opcodeExpected;
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
@ -341,13 +342,12 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques
|
|||||||
Output::Instance()->Post("\n", BLACKBOARD_LD_OFFSET + GetID());
|
Output::Instance()->Post("\n", BLACKBOARD_LD_OFFSET + GetID());
|
||||||
|
|
||||||
// Handle command complete information
|
// Handle command complete information
|
||||||
request->FindInt16("opcodeExpected", 0 /*REVIEW!*/, &opcodeExpected);
|
request->FindInt16("opcodeExpected", index, &opcodeExpected);
|
||||||
|
|
||||||
|
|
||||||
if (request->IsSourceWaiting() == false)
|
if (request->IsSourceWaiting() == false)
|
||||||
Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);
|
Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);
|
||||||
|
|
||||||
|
|
||||||
switch (opcodeExpected) {
|
switch (opcodeExpected) {
|
||||||
|
|
||||||
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY):
|
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY):
|
||||||
|
@ -37,8 +37,8 @@ public:
|
|||||||
status_t ProcessSimpleRequest(BMessage* request);
|
status_t ProcessSimpleRequest(BMessage* request);
|
||||||
|
|
||||||
/* Events handling */
|
/* Events handling */
|
||||||
void CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request);
|
void CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request, int32 index);
|
||||||
void CommandStatus(struct hci_ev_cmd_status* event, BMessage* request);
|
void CommandStatus(struct hci_ev_cmd_status* event, BMessage* request, int32 index);
|
||||||
|
|
||||||
// Inquiry
|
// Inquiry
|
||||||
void InquiryResult(uint8* numberOfResponses, BMessage* request);
|
void InquiryResult(uint8* numberOfResponses, BMessage* request);
|
||||||
|
Loading…
Reference in New Issue
Block a user