- Fix correct handling of the command status event
- Fix Removal of specifil event wanted in a given request git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24971 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
088fb3cd47
commit
717c9b00f2
@ -74,50 +74,49 @@ LocalDeviceHandler::ClearWantedEvent(BMessage* msg)
|
||||
|
||||
|
||||
void
|
||||
LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event, uint16 opcode = 0)
|
||||
LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event, uint16 opcode)
|
||||
{
|
||||
// Remove the whole petition from queue
|
||||
fEventsWanted.Lock();
|
||||
|
||||
int16 eventFound;
|
||||
int16 opcodeFound;
|
||||
int32 eventIndex;
|
||||
int32 eventIndex = 0;
|
||||
|
||||
for (int32 index = 0 ; index < fEventsWanted.CountMessages() ; index++) {
|
||||
|
||||
BMessage* msg = fEventsWanted.FindMessage(index);
|
||||
// for each Event
|
||||
while (msg->FindInt16("eventExpected", eventIndex, &eventFound) == B_OK ) {
|
||||
|
||||
eventIndex = 0;
|
||||
// for each Event
|
||||
while (msg->FindInt16("eventExpected", eventIndex, &eventFound) == B_OK ) {
|
||||
if (eventFound == event) {
|
||||
|
||||
// there is an opcode specified
|
||||
if (opcode != 0) {
|
||||
printf("@ Event expected found @%ld\n", eventIndex);
|
||||
|
||||
if (eventFound == event) {
|
||||
|
||||
printf("@ Event matches %ld\n", eventIndex);
|
||||
// there is an opcode specified
|
||||
if (opcode != 0) {
|
||||
|
||||
// The opcode matches
|
||||
if ( (msg->FindInt16("opcodeExpected", eventIndex, &opcodeFound) == B_OK) &&
|
||||
((uint16)opcodeFound != opcode) ) {
|
||||
|
||||
// this should remove only the entry
|
||||
(void)msg->RemoveData("eventExpected", eventIndex);
|
||||
(void)msg->RemoveData("opcodeExpected", eventIndex);
|
||||
goto bail;
|
||||
}
|
||||
} else {
|
||||
// Event matches so far
|
||||
// The opcode matches
|
||||
if ( (msg->FindInt16("opcodeExpected", eventIndex, &opcodeFound) == B_OK) &&
|
||||
((uint16)opcodeFound == opcode) ) {
|
||||
|
||||
// this should remove only the entry
|
||||
printf("@ Removed event %d and opcoce %d from message %p\n", event, opcode, msg);
|
||||
(void)msg->RemoveData("eventExpected", eventIndex);
|
||||
(void)msg->RemoveData("opcodeExpected", eventIndex);
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Event matches so far
|
||||
printf("@ Removed event %d from message %p\n", event, msg);
|
||||
(void)msg->RemoveData("eventExpected", eventIndex);
|
||||
goto bail;
|
||||
}
|
||||
|
||||
}
|
||||
eventIndex++;
|
||||
}
|
||||
}
|
||||
eventIndex++;
|
||||
}
|
||||
|
||||
bail:
|
||||
|
||||
fEventsWanted.RemoveMessage(msg);
|
||||
fEventsWanted.Unlock();
|
||||
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ printf("### \n");
|
||||
|
||||
} else if ( event->ecode == HCI_EVENT_CMD_STATUS ) {
|
||||
|
||||
(Output::Instance()->Post("Incoming Command Complete\n", BLACKBOARD_EVENTS));
|
||||
(Output::Instance()->Post("Incoming Command Status\n", BLACKBOARD_EVENTS));
|
||||
request = FindPetition(event->ecode, ((struct hci_ev_cmd_status*)(event+1))->opcode );
|
||||
|
||||
} else
|
||||
@ -346,17 +346,15 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques
|
||||
|
||||
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);
|
||||
|
||||
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY):
|
||||
{
|
||||
reply.what = BT_MSG_INQUIRY_STARTED;
|
||||
reply.AddInt8("status", commandStatus->status);
|
||||
reply.AddInt8("status", event->status);
|
||||
|
||||
if (commandStatus->status == BT_OK) {
|
||||
Output::Instance()->Post("Positive reply for inquiry\n", BLACKBOARD_KIT);
|
||||
if (event->status == BT_OK) {
|
||||
Output::Instance()->Post("Positive reply for inquiry status\n", BLACKBOARD_KIT);
|
||||
} else {
|
||||
Output::Instance()->Post("Negative reply for friendly name\n", BLACKBOARD_KIT);
|
||||
Output::Instance()->Post("Negative reply for inquiry status\n", BLACKBOARD_KIT);
|
||||
}
|
||||
|
||||
printf("Sending reply ... %ld\n",request->SendReply(&reply));
|
||||
@ -384,7 +382,6 @@ LocalDeviceImpl::InquiryResult(struct inquiry_info* event, BMessage* request)
|
||||
|
||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, request->SendReply(&reply));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -393,9 +390,11 @@ LocalDeviceImpl::InquiryComplete(uint8* status, BMessage* request)
|
||||
{
|
||||
BMessage reply(BT_MSG_INQUIRY_COMPLETED);
|
||||
|
||||
reply.AddInt8("status", *status);
|
||||
reply.AddInt8("status", *status);
|
||||
|
||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, request->SendReply(&reply));
|
||||
|
||||
|
||||
ClearWantedEvent(request);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user