From 009fac990660d0f697395d351e2c1744a7966f59 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Sun, 9 Mar 2008 00:04:16 +0000 Subject: [PATCH] Code & text output cleaning git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24317 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/bluetooth/BPortNot.cpp | 14 +---- src/servers/bluetooth/BluetoothServer.cpp | 59 ++----------------- src/servers/bluetooth/CommandManager.cpp | 18 +++++- src/servers/bluetooth/CommandManager.h | 2 +- .../bluetooth/HCIControllerAccessor.cpp | 7 +++ src/servers/bluetooth/HCIControllerAccessor.h | 9 ++- src/servers/bluetooth/HCIDelegate.h | 12 +++- .../bluetooth/HCITransportAccessor.cpp | 13 +++- src/servers/bluetooth/HCITransportAccessor.h | 8 ++- src/servers/bluetooth/LocalDeviceHandler.cpp | 5 +- src/servers/bluetooth/LocalDeviceImpl.cpp | 55 +++++++---------- 11 files changed, 88 insertions(+), 114 deletions(-) diff --git a/src/servers/bluetooth/BPortNot.cpp b/src/servers/bluetooth/BPortNot.cpp index 7a12f4ebd2..a035ee0daa 100644 --- a/src/servers/bluetooth/BPortNot.cpp +++ b/src/servers/bluetooth/BPortNot.cpp @@ -63,19 +63,7 @@ BPortNot::loop() Output::Instance()->Post("Wrong type frame code", BLACKBOARD_GENERAL); continue; } - -#if 0 - for (int i=0 ; iLocateLocalDeviceImpl(GET_PORTCODE_HID(code)); if (ld == NULL) { Output::Instance()->Post("LocalDevice could not be fetched", BLACKBOARD_EVENTS); diff --git a/src/servers/bluetooth/BluetoothServer.cpp b/src/servers/bluetooth/BluetoothServer.cpp index ea263c7264..0915a9294d 100644 --- a/src/servers/bluetooth/BluetoothServer.cpp +++ b/src/servers/bluetooth/BluetoothServer.cpp @@ -158,7 +158,7 @@ void BluetoothServer::MessageReceived(BMessage *message) break; - /* Handle if the bluetooth preferences is running */ + /* Handle if the bluetooth preferences is running?? */ case B_SOME_APP_LAUNCHED: { const char *signature; @@ -178,7 +178,8 @@ void BluetoothServer::MessageReceived(BMessage *message) break; } - /* Can we reply right now? */ + // Can we reply right now? + // TOD: review this condition if (status != B_WOULD_BLOCK) { reply.AddInt32("status", status); message->SendReply(&reply); @@ -391,50 +392,6 @@ BluetoothServer::sdp_server_Thread(void* data) #if 0 -void BluetoothServer::DevicesWatching(void) { - - BDirectory* hdoses; - BEntry entrada; - BPath path; - - //status_t err; - int fd1 = -1; - - // only cheks the actual driver which we have - hdoses = new BDirectory("/dev/bus/bluetooth/h2/"); -// hdoses = new BDirectory("/dev/bus/bluetooth/h3/..."); -// hdoses = new BDirectory("/dev/bus/bluetooth/h4/..."); - Output::Instance()->Post("Exploring present devices ...\n",1); - - while (hdoses->GetNextEntry(&entrada,true) == B_OK) { - Output::Instance()->Post((char*)path.Path(), 1); - entrada.GetPath(&path); - if (entrada.IsDirectory()) { - Output::Instance()->Post((char*)path.Path(),1); - BDirectory* driver_directory = new BDirectory(path.Path()); - BEntry driver_entry; - - syslog(LOG_ALERT, "Bluetooth driver %s\n",path.Path()); - fprintf(stderr, "Bluetooth driver %s\n",path.Path()); - - while (driver_directory->GetNextEntry(&driver_entry,true) == B_OK) { - Output::Instance()->Post((char*)path.Path(),1); - driver_entry.GetPath(&path); - fd1 = open(path.Path(), O_RDWR); - - - - // TODO: Watching all folders under and set some kind of internal structure that hold all - // LocalDevices. - // devloop = new DeviceLooper(); - // devloop->StartMonitoringDevice("bus/bluetooth/h2"); - - if (fd1 < 0) { - syslog(LOG_ALERT,BT "Error opening device %s\n",path.Path()); - fprintf(stderr, "Error opening device %s\n",path.Path()); - } - else - { struct { size_t size; struct hci_command_header header; @@ -468,7 +425,7 @@ void BluetoothServer::DevicesWatching(void) { cm1.header.clen = 0; ioctl(fd1, ISSUE_BT_COMMAND, &cm1, sizeof(cm1)); - /*cm1.size = sizeof(struct hci_command_header); + cm1.size = sizeof(struct hci_command_header); cm1.header.opcode = B_HOST_TO_LENDIAN_INT16(hci_opcode_pack(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME)); cm1.header.clen = 0; ioctl(fd1, ISSUE_BT_COMMAND, &cm1, sizeof(cm1)); @@ -487,6 +444,7 @@ void BluetoothServer::DevicesWatching(void) { cm2.body.num_rsp = 8; cm2.header.clen = 5; ioctl(fd1, ISSUE_BT_COMMAND, &cm2, sizeof(cm1)); + snooze(60*1000*1000);*/ cm3.size = sizeof(struct hci_command_header)+sizeof(struct hci_remote_name_request); cm3.header.opcode = B_HOST_TO_LENDIAN_INT16(hci_opcode_pack(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST)); @@ -518,14 +476,7 @@ void BluetoothServer::DevicesWatching(void) { ioctl(fd1, ISSUE_BT_COMMAND, &cm4, sizeof(cm4)); */ } - } - } - } - syslog(LOG_ALERT,BT "All devices registered\n"); - fprintf(stderr, "Waiting with opened devices\n"); - -} #endif void diff --git a/src/servers/bluetooth/CommandManager.cpp b/src/servers/bluetooth/CommandManager.cpp index a0b19e4883..2874815187 100644 --- a/src/servers/bluetooth/CommandManager.cpp +++ b/src/servers/bluetooth/CommandManager.cpp @@ -47,7 +47,11 @@ inline void* buildCommand(uint8 ogf, uint8 ocf, void** param, size_t psize, size } -/* CONTROL BASEBAND */ +#if 0 +#pragma mark - CONTROL BASEBAND - +#endif + + void* buildReset(size_t* outsize) { return buildCommand(OGF_CONTROL_BASEBAND, OCF_RESET, NULL, 0, outsize); @@ -60,7 +64,11 @@ void* buildReadLocalName(size_t* outsize) } -/* LINK CONTROL */ +#if 0 +#pragma mark - LINK CONTROL - +#endif + + void* buildRemoteNameRequest(bdaddr_t bdaddr,uint8 pscan_rep_mode, uint16 clock_offset, size_t* outsize) { @@ -96,7 +104,11 @@ void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize) } -/* OGF_INFORMATIONAL_PARAM */ +#if 0 +#pragma mark - INFORMATIONAL_PARAM - +#endif + + void* buildReadBufferSize(size_t* outsize) { return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE, NULL, 0, outsize); diff --git a/src/servers/bluetooth/CommandManager.h b/src/servers/bluetooth/CommandManager.h index 223b9d6892..ae3a8e6bbe 100644 --- a/src/servers/bluetooth/CommandManager.h +++ b/src/servers/bluetooth/CommandManager.h @@ -22,4 +22,4 @@ void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize); void* buildReadBufferSize(size_t* outsize); void* buildReadBdAddr(size_t* outsize); -#endif \ No newline at end of file +#endif diff --git a/src/servers/bluetooth/HCIControllerAccessor.cpp b/src/servers/bluetooth/HCIControllerAccessor.cpp index 39f83709a2..0314ef8d39 100644 --- a/src/servers/bluetooth/HCIControllerAccessor.cpp +++ b/src/servers/bluetooth/HCIControllerAccessor.cpp @@ -1,3 +1,10 @@ +/* + * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + #include "HCIControllerAccessor.h" diff --git a/src/servers/bluetooth/HCIControllerAccessor.h b/src/servers/bluetooth/HCIControllerAccessor.h index cfe5032e04..87fe9ee2eb 100644 --- a/src/servers/bluetooth/HCIControllerAccessor.h +++ b/src/servers/bluetooth/HCIControllerAccessor.h @@ -1,4 +1,11 @@ -/* */ +/* + * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + + #ifndef _HCICONTROLLER_ACCESSOR_H_ #define _HCICONTROLLER_ACCESSOR_H_ diff --git a/src/servers/bluetooth/HCIDelegate.h b/src/servers/bluetooth/HCIDelegate.h index 2bac212323..d02df9e368 100644 --- a/src/servers/bluetooth/HCIDelegate.h +++ b/src/servers/bluetooth/HCIDelegate.h @@ -1,3 +1,10 @@ +/* + * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + #ifndef _HCIDELEGATE_H_ #define _HCIDELEGATE_H_ @@ -20,14 +27,13 @@ class HCIDelegate { status_t status; fFD = open (path->Path(), O_RDWR); - printf("## fdesc %d\n", fFD); if (fFD > 0) { // find out which ID was assigned status = ioctl(fFD, GET_HCI_ID, &fHID, 0); - printf("## id fdesc %ld ### %ld\n", fHID, status); - + printf("%s: hid retrieved %ld status=%ld\n", __FUNCTION__, fHID, status); } else { + printf("%s: Device driver could not be opened %ld\n", __FUNCTION__, fHID); fHID = B_ERROR; } diff --git a/src/servers/bluetooth/HCITransportAccessor.cpp b/src/servers/bluetooth/HCITransportAccessor.cpp index ccdc099af3..52c7074bf0 100644 --- a/src/servers/bluetooth/HCITransportAccessor.cpp +++ b/src/servers/bluetooth/HCITransportAccessor.cpp @@ -1,3 +1,10 @@ +/* + * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + #include @@ -17,11 +24,11 @@ HCITransportAccessor::IssueCommand(raw_command rc, size_t size) if (GetID() < 0 || fFD < 0) return B_ERROR; -printf("Command going: len = %d\n", size); -for (int16 index = 0 ; index < size; index++ ) { +printf("### Command going: len = %ld\n", size); +for (uint16 index = 0 ; index < size; index++ ) { printf("%x:",((uint8*)rc)[index]); } -printf("\n"); +printf("### \n"); return ioctl(fFD, ISSUE_BT_COMMAND, rc, size); diff --git a/src/servers/bluetooth/HCITransportAccessor.h b/src/servers/bluetooth/HCITransportAccessor.h index 370364ee97..b3d876413c 100644 --- a/src/servers/bluetooth/HCITransportAccessor.h +++ b/src/servers/bluetooth/HCITransportAccessor.h @@ -1,4 +1,10 @@ -/* */ +/* + * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + #ifndef _HCITRANSPORT_ACCESSOR_H_ #define _HCITRANSPORT_ACCESSOR_H_ diff --git a/src/servers/bluetooth/LocalDeviceHandler.cpp b/src/servers/bluetooth/LocalDeviceHandler.cpp index 52624f9ca5..3f71ddc9b4 100644 --- a/src/servers/bluetooth/LocalDeviceHandler.cpp +++ b/src/servers/bluetooth/LocalDeviceHandler.cpp @@ -110,9 +110,10 @@ LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event = 0, uint16 opc } bail: */ - fEventsWanted.Unlock(); - fEventsWanted.RemoveMessage(msg); + + fEventsWanted.Unlock(); + } diff --git a/src/servers/bluetooth/LocalDeviceImpl.cpp b/src/servers/bluetooth/LocalDeviceImpl.cpp index 8cb19f63ef..faadc4e61f 100644 --- a/src/servers/bluetooth/LocalDeviceImpl.cpp +++ b/src/servers/bluetooth/LocalDeviceImpl.cpp @@ -15,9 +15,14 @@ #include #include - #include + +#if 0 +#pragma mark - Class methods - +#endif + + // Factory methods LocalDeviceImpl* LocalDeviceImpl::CreateControllerAccessor(BPath* path) @@ -49,27 +54,33 @@ LocalDeviceImpl::LocalDeviceImpl(HCIDelegate* hd) : LocalDeviceHandler(hd) } #if 0 -#pragma mark - Class methods - +#pragma mark - Event handling methods - #endif void LocalDeviceImpl::HandleEvent(struct hci_event_header* event) { - // Check if it was a non requested events + +printf("### Event comming: len = %d\n", event->elen); +for (int16 index = 0 ; index < event->elen + 2; index++ ) { + printf("%x:",((uint8*)event)[index]); +} +printf("### \n"); + + // Events here might have not been initated by us switch (event->ecode) { case HCI_EVENT_HARDWARE_ERROR: //HardwareError(event); return; + case HCI_EVENT_CONN_REQUEST: + + break; + default: // lets go on break; } -printf("Event comming: len = %d\n", event->elen); -for (int16 index = 0 ; index < event->elen + 2; index++ ) { - printf("%x:",((uint8*)event)[index]); -} -printf("\n"); BMessage* request = NULL; @@ -101,10 +112,7 @@ printf("\n"); case HCI_EVENT_CONN_COMPLETE: break; - - case HCI_EVENT_CONN_REQUEST: - break; - + case HCI_EVENT_DISCONNECTION_COMPLETE: break; @@ -216,15 +224,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re // Handle command complete information request->FindInt16("opcodeExpected", 0 /*REVIEW!*/, &opcodeExpected); -printf("Command complete ...%p\n",event); -for (int16 index = 0 ; index < 10; index++ ) { - printf("%x:",((uint8*)event)[index]); -} -printf("\n"); - if (request->IsSourceWaiting() == false) - Output::Instance()->Post("nobody waiting\n", BLACKBOARD_KIT); + Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT); switch (opcodeExpected) { @@ -232,14 +234,7 @@ printf("\n"); case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR): { struct hci_rp_read_bd_addr* readbdaddr = (struct hci_rp_read_bd_addr*)(event+1); - - printf("read bdaddr ...%p\n", readbdaddr); - for (int16 index = 0 ; index < 10; index++ ) { - printf("%x:",((uint8*)readbdaddr)[index]); - } - printf("\n"); - - + if (readbdaddr->status == BT_OK) { @@ -266,12 +261,6 @@ printf("\n"); { struct hci_rp_read_local_name* readLocalName = (struct hci_rp_read_local_name*)(event+1); - printf("read bdaddr ...%p\n", readLocalName); - for (int16 index = 0 ; index < 10; index++ ) { - printf("%x:",((uint8*)readLocalName)[index]); - } - printf("\n"); - reply.AddInt8("status", readLocalName->status); if (readLocalName->status == BT_OK) {