git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26199 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2008-07-01 19:43:37 +00:00
parent 480cccf67b
commit 291e114333
6 changed files with 857 additions and 857 deletions
+26 -26
View File
@@ -1,26 +1,26 @@
/* /*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#include "HCIControllerAccessor.h" #include "HCIControllerAccessor.h"
HCIControllerAccessor::HCIControllerAccessor(BPath* path) : HCIDelegate(path) HCIControllerAccessor::HCIControllerAccessor(BPath* path) : HCIDelegate(path)
{ {
} }
status_t status_t
HCIControllerAccessor::IssueCommand(raw_command* rc, size_t size) HCIControllerAccessor::IssueCommand(raw_command* rc, size_t size)
{ {
if (GetID() < 0) if (GetID() < 0)
return B_ERROR; return B_ERROR;
return B_ERROR; return B_ERROR;
} }
+23 -23
View File
@@ -1,23 +1,23 @@
/* /*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _HCICONTROLLER_ACCESSOR_H_ #ifndef _HCICONTROLLER_ACCESSOR_H_
#define _HCICONTROLLER_ACCESSOR_H_ #define _HCICONTROLLER_ACCESSOR_H_
#include "HCIDelegate.h" #include "HCIDelegate.h"
class HCIControllerAccessor : public HCIDelegate { class HCIControllerAccessor : public HCIDelegate {
public: public:
HCIControllerAccessor(BPath* path); HCIControllerAccessor(BPath* path);
status_t IssueCommand(raw_command* rc, size_t size); status_t IssueCommand(raw_command* rc, size_t size);
}; };
#endif #endif
+65 -65
View File
@@ -1,65 +1,65 @@
/* /*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _HCIDELEGATE_H_ #ifndef _HCIDELEGATE_H_
#define _HCIDELEGATE_H_ #define _HCIDELEGATE_H_
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <Path.h> #include <Path.h>
#include <bluetooth/HCI/btHCI_transport.h> #include <bluetooth/HCI/btHCI_transport.h>
typedef void* raw_command; typedef void* raw_command;
class HCIDelegate { class HCIDelegate {
public: public:
HCIDelegate(BPath* path) HCIDelegate(BPath* path)
{ {
status_t status; status_t status;
fFD = open (path->Path(), O_RDWR); fFD = open (path->Path(), O_RDWR);
if (fFD > 0) { if (fFD > 0) {
// find out which ID was assigned // find out which ID was assigned
status = ioctl(fFD, GET_HCI_ID, &fHID, 0); status = ioctl(fFD, GET_HCI_ID, &fHID, 0);
printf("%s: hid retrieved %ld status=%ld\n", __FUNCTION__, fHID, status); printf("%s: hid retrieved %ld status=%ld\n", __FUNCTION__, fHID, status);
} }
else { else {
printf("%s: Device driver could not be opened %ld\n", __FUNCTION__, fHID); printf("%s: Device driver could not be opened %ld\n", __FUNCTION__, fHID);
fHID = B_ERROR; fHID = B_ERROR;
} }
} }
hci_id GetID(void) hci_id GetID(void)
{ {
return fHID; return fHID;
} }
virtual status_t IssueCommand(raw_command rc, size_t size) virtual status_t IssueCommand(raw_command rc, size_t size)
{ {
return B_ERROR; return B_ERROR;
} }
protected: protected:
hci_id fHID; hci_id fHID;
int fFD; int fFD;
private: private:
}; };
#endif #endif
+22 -22
View File
@@ -1,22 +1,22 @@
/* /*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _HCITRANSPORT_ACCESSOR_H_ #ifndef _HCITRANSPORT_ACCESSOR_H_
#define _HCITRANSPORT_ACCESSOR_H_ #define _HCITRANSPORT_ACCESSOR_H_
#include "HCIDelegate.h" #include "HCIDelegate.h"
class HCITransportAccessor : public HCIDelegate { class HCITransportAccessor : public HCIDelegate {
public: public:
HCITransportAccessor(BPath* path); HCITransportAccessor(BPath* path);
status_t IssueCommand(raw_command rc, size_t size); status_t IssueCommand(raw_command rc, size_t size);
}; };
#endif #endif
+170 -170
View File
@@ -1,170 +1,170 @@
/* /*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#include "LocalDeviceHandler.h" #include "LocalDeviceHandler.h"
LocalDeviceHandler::LocalDeviceHandler(HCIDelegate* hd) LocalDeviceHandler::LocalDeviceHandler(HCIDelegate* hd)
{ {
fHCIDelegate = hd; fHCIDelegate = hd;
fProperties = new BMessage(); fProperties = new BMessage();
} }
LocalDeviceHandler::~LocalDeviceHandler() LocalDeviceHandler::~LocalDeviceHandler()
{ {
} }
hci_id hci_id
LocalDeviceHandler::GetID() LocalDeviceHandler::GetID()
{ {
return fHCIDelegate->GetID(); return fHCIDelegate->GetID();
} }
bool bool
LocalDeviceHandler::Available() { LocalDeviceHandler::Available() {
return true; return true;
} }
void void
LocalDeviceHandler::Acquire(void) { LocalDeviceHandler::Acquire(void) {
} }
bool bool
LocalDeviceHandler::IsPropertyAvailable(const BString& property) { LocalDeviceHandler::IsPropertyAvailable(const BString& property) {
type_code typeFound; type_code typeFound;
int32 countFound; int32 countFound;
return (fProperties->GetInfo(property.String(), &typeFound, &countFound) == B_OK ); return (fProperties->GetInfo(property.String(), &typeFound, &countFound) == B_OK );
} }
void void
LocalDeviceHandler::AddWantedEvent(BMessage* msg) LocalDeviceHandler::AddWantedEvent(BMessage* msg)
{ {
fEventsWanted.Lock(); fEventsWanted.Lock();
// TODO: review why it is neede to replicate the msg // TODO: review why it is neede to replicate the msg
fEventsWanted.AddMessage(msg); fEventsWanted.AddMessage(msg);
fEventsWanted.Unlock(); fEventsWanted.Unlock();
} }
void void
LocalDeviceHandler::ClearWantedEvent(BMessage* msg) LocalDeviceHandler::ClearWantedEvent(BMessage* msg)
{ {
fEventsWanted.Lock(); fEventsWanted.Lock();
fEventsWanted.RemoveMessage(msg); fEventsWanted.RemoveMessage(msg);
fEventsWanted.Unlock(); fEventsWanted.Unlock();
} }
void void
LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event, uint16 opcode) LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event, uint16 opcode)
{ {
// Remove the whole petition from queue // Remove the whole petition from queue
fEventsWanted.Lock(); fEventsWanted.Lock();
int16 eventFound; int16 eventFound;
int16 opcodeFound; int16 opcodeFound;
int32 eventIndex = 0; int32 eventIndex = 0;
// for each Event // for each Event
while (msg->FindInt16("eventExpected", eventIndex, &eventFound) == B_OK ) { while (msg->FindInt16("eventExpected", eventIndex, &eventFound) == B_OK ) {
printf("@ Event expected found @%ld\n", eventIndex); printf("@ Event expected found @%ld\n", eventIndex);
if (eventFound == event) { if (eventFound == event) {
printf("@ Event matches %ld\n", eventIndex); printf("@ Event matches %ld\n", eventIndex);
// there is an opcode specified // there is an opcode specified
if (opcode != 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) ) {
// this should remove only the entry // this should remove only the entry
printf("@ Removed event %d and opcoce %d from message %p\n", event, opcode, msg); printf("@ Removed event %d and opcoce %d from message %p\n", event, opcode, msg);
(void)msg->RemoveData("eventExpected", eventIndex); (void)msg->RemoveData("eventExpected", eventIndex);
(void)msg->RemoveData("opcodeExpected", eventIndex); (void)msg->RemoveData("opcodeExpected", eventIndex);
goto bail; goto bail;
} }
} else { } else {
// Event matches so far // Event matches so far
printf("@ Removed event %d from message %p\n", event, msg); printf("@ Removed event %d from message %p\n", event, msg);
(void)msg->RemoveData("eventExpected", eventIndex); (void)msg->RemoveData("eventExpected", eventIndex);
goto bail; goto bail;
} }
} }
eventIndex++; eventIndex++;
} }
bail: bail:
fEventsWanted.Unlock(); fEventsWanted.Unlock();
} }
BMessage* BMessage*
LocalDeviceHandler::FindPetition(uint16 event, uint16 opcode, int32* indexFound) LocalDeviceHandler::FindPetition(uint16 event, uint16 opcode, int32* indexFound)
{ {
int16 eventFound; int16 eventFound;
int16 opcodeFound; int16 opcodeFound;
int32 eventIndex; int32 eventIndex;
fEventsWanted.Lock(); fEventsWanted.Lock();
// for each Petition // for each Petition
for (int32 index = 0 ; index < fEventsWanted.CountMessages() ; index++) { for (int32 index = 0 ; index < fEventsWanted.CountMessages() ; index++) {
BMessage* msg = fEventsWanted.FindMessage(index); BMessage* msg = fEventsWanted.FindMessage(index);
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) {
printf("Event found %ld\n", eventIndex); printf("Event found %ld\n", eventIndex);
// there is an opcode specified.. // there is an opcode specified..
if (msg->FindInt16("opcodeExpected", eventIndex, &opcodeFound) == B_OK) { if (msg->FindInt16("opcodeExpected", eventIndex, &opcodeFound) == B_OK) {
// ensure the opcode // ensure the opcode
if ((uint16)opcodeFound != opcode) { if ((uint16)opcodeFound != opcode) {
printf("opcode does not match %d\n", opcode); printf("opcode does not match %d\n", opcode);
break; break;
} }
printf("Opcdodes match %d %d \n", opcode , opcodeFound); printf("Opcdodes match %d %d \n", opcode , opcodeFound);
} }
fEventsWanted.Unlock(); fEventsWanted.Unlock();
if (indexFound != NULL) if (indexFound != NULL)
*indexFound = eventIndex; *indexFound = eventIndex;
return msg; return msg;
} }
eventIndex++; eventIndex++;
} }
} }
fEventsWanted.Unlock(); fEventsWanted.Unlock();
return NULL; return NULL;
} }
File diff suppressed because it is too large Load Diff