From fef016caf6d8ecd012f9685144368c4fbdbf7217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Mod=C3=A9en?= Date: Thu, 10 Jan 2013 16:33:36 +0000 Subject: [PATCH] Adding more debug info to bluetooth. * more changes will come. --- src/kits/bluetooth/CommandManager.cpp | 30 +++++++++++++++++++----- src/kits/bluetooth/DeviceClass.cpp | 11 +++++---- src/kits/bluetooth/DiscoveryAgent.cpp | 8 +++++++ src/kits/bluetooth/DiscoveryListener.cpp | 12 ++++++---- src/kits/bluetooth/KitSupport.cpp | 5 +++- src/kits/bluetooth/RemoteDevice.cpp | 18 +++++++++++++- 6 files changed, 68 insertions(+), 16 deletions(-) diff --git a/src/kits/bluetooth/CommandManager.cpp b/src/kits/bluetooth/CommandManager.cpp index fad66ca482..931f4d18f6 100644 --- a/src/kits/bluetooth/CommandManager.cpp +++ b/src/kits/bluetooth/CommandManager.cpp @@ -8,10 +8,12 @@ #include +#include inline void* buildCommand(uint8 ogf, uint8 ocf, void** param, size_t psize, size_t* outsize) { + CALLED(); struct hci_command_header* header; #ifdef BT_IOCTLS_PASS_SIZE @@ -57,6 +59,7 @@ status_t NonParameterCommandRequest(uint8 ofg, uint8 ocf, int32* result, hci_id hId, BMessenger* messenger) { + CALLED(); int8 bt_status = BT_ERROR; BluetoothCommand<> simpleCommand(ofg, ocf); @@ -87,6 +90,7 @@ NonParameterCommandRequest(uint8 ofg, uint8 ocf, int32* result, hci_id hId, void* buildReset(size_t* outsize) { + CALLED(); return buildCommand(OGF_CONTROL_BASEBAND, OCF_RESET, NULL, 0, outsize); } @@ -94,6 +98,7 @@ void* buildReset(size_t* outsize) void* buildReadLocalName(size_t* outsize) { + CALLED(); return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME, NULL, 0, outsize); } @@ -101,6 +106,7 @@ void* buildReadLocalName(size_t* outsize) void* buildReadClassOfDevice(size_t* outsize) { + CALLED(); return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_CLASS_OF_DEV, NULL, 0, outsize); } @@ -108,6 +114,7 @@ void* buildReadClassOfDevice(size_t* outsize) void* buildReadScan(size_t* outsize) { + CALLED(); return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_SCAN_ENABLE, NULL, 0, outsize); } @@ -115,6 +122,7 @@ void* buildReadScan(size_t* outsize) void* buildWriteScan(uint8 scanmode, size_t* outsize) { + CALLED(); struct hci_write_scan_enable* param; void* command = buildCommand(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE, (void**) ¶m, sizeof(struct hci_write_scan_enable), outsize); @@ -136,7 +144,7 @@ void* buildWriteScan(uint8 scanmode, size_t* outsize) void* buildRemoteNameRequest(bdaddr_t bdaddr, uint8 pscan_rep_mode, uint16 clock_offset, size_t* outsize) { - + CALLED(); struct hci_remote_name_request* param; void* command = buildCommand(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST, (void**)¶m, sizeof(struct hci_remote_name_request), outsize); @@ -153,7 +161,7 @@ void* buildRemoteNameRequest(bdaddr_t bdaddr, uint8 pscan_rep_mode, void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize) { - + CALLED(); struct hci_cp_inquiry* param; void* command = buildCommand(OGF_LINK_CONTROL, OCF_INQUIRY, (void**) ¶m, sizeof(struct hci_cp_inquiry), outsize); @@ -173,15 +181,15 @@ void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize) void* buildInquiryCancel(size_t* outsize) { - + CALLED(); return buildCommand(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL, NULL, 0, outsize); - } void* buildPinCodeRequestReply(bdaddr_t bdaddr, uint8 length, char pincode[16], size_t* outsize) { + CALLED(); struct hci_cp_pin_code_reply* param; if (length > HCI_PIN_SIZE) // PinCode cannot be longer than 16 @@ -202,7 +210,7 @@ void* buildPinCodeRequestReply(bdaddr_t bdaddr, uint8 length, char pincode[16], void* buildPinCodeRequestNegativeReply(bdaddr_t bdaddr, size_t* outsize) { - + CALLED(); struct hci_cp_pin_code_neg_reply* param; void* command = buildCommand(OGF_LINK_CONTROL, OCF_PIN_CODE_NEG_REPLY, @@ -220,6 +228,7 @@ void* buildPinCodeRequestNegativeReply(bdaddr_t bdaddr, size_t* outsize) void* buildAcceptConnectionRequest(bdaddr_t bdaddr, uint8 role, size_t* outsize) { + CALLED(); struct hci_cp_accept_conn_req* param; void* command = buildCommand(OGF_LINK_CONTROL, OCF_ACCEPT_CONN_REQ, @@ -236,6 +245,7 @@ void* buildAcceptConnectionRequest(bdaddr_t bdaddr, uint8 role, size_t* outsize) void* buildRejectConnectionRequest(bdaddr_t bdaddr, size_t* outsize) { + CALLED(); struct hci_cp_reject_conn_req* param; void* command = buildCommand(OGF_LINK_CONTROL, OCF_REJECT_CONN_REQ, @@ -256,6 +266,7 @@ void* buildRejectConnectionRequest(bdaddr_t bdaddr, size_t* outsize) void* buildReadLocalVersionInformation(size_t* outsize) { + CALLED(); return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_VERSION, NULL, 0, outsize); } @@ -263,6 +274,7 @@ void* buildReadLocalVersionInformation(size_t* outsize) void* buildReadBufferSize(size_t* outsize) { + CALLED(); return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE, NULL, 0, outsize); } @@ -270,6 +282,7 @@ void* buildReadBufferSize(size_t* outsize) void* buildReadBdAddr(size_t* outsize) { + CALLED(); return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR, NULL, 0, outsize); } @@ -703,6 +716,7 @@ const char* lmpVersion[] = { "1.0 " , "1.1 " , "1.2 " , "2.0 " , "2.1 "}; const char* BluetoothHciVersion(uint16 ver) { + CALLED(); return hciVersion[ver]; } @@ -710,6 +724,7 @@ BluetoothHciVersion(uint16 ver) const char* BluetoothLmpVersion(uint16 ver) { + CALLED(); return lmpVersion[ver]; } @@ -717,7 +732,7 @@ BluetoothLmpVersion(uint16 ver) const char* BluetoothCommandOpcode(uint16 opcode) { - + CALLED(); // NOTE: BT implementations beyond 2.1 // could specify new commands with OCF numbers // beyond the boundaries of the arrays and crash. @@ -761,6 +776,7 @@ BluetoothCommandOpcode(uint16 opcode) const char* BluetoothEvent(uint8 event) { + CALLED(); if (event < sizeof(bluetoothEvents) / sizeof(const char*)) return bluetoothEvents[event - 1]; else @@ -771,6 +787,7 @@ BluetoothEvent(uint8 event) const char* BluetoothManufacturer(uint16 manufacturer) { + CALLED(); if (manufacturer < sizeof(bluetoothManufacturers) / sizeof(const char*)) return bluetoothManufacturers[manufacturer]; else if (manufacturer == 0xFFFF) @@ -783,6 +800,7 @@ BluetoothManufacturer(uint16 manufacturer) const char* BluetoothError(uint8 error) { + CALLED(); if (error < sizeof(bluetoothErrors) / sizeof(const char*)) return bluetoothErrors[error]; else diff --git a/src/kits/bluetooth/DeviceClass.cpp b/src/kits/bluetooth/DeviceClass.cpp index 33ef99e86f..7eb3c4857b 100644 --- a/src/kits/bluetooth/DeviceClass.cpp +++ b/src/kits/bluetooth/DeviceClass.cpp @@ -4,6 +4,7 @@ */ #include +#include #include #include @@ -18,6 +19,7 @@ namespace Bluetooth { void DeviceClass::GetServiceClass(BString& serviceClass) { + CALLED(); static const char *services[] = { B_TRANSLATE_MARK("Positioning"), B_TRANSLATE_MARK("Networking"), B_TRANSLATE_MARK("Rendering"), B_TRANSLATE_MARK("Capturing"), B_TRANSLATE_MARK("Object transfer"), @@ -41,13 +43,13 @@ DeviceClass::GetServiceClass(BString& serviceClass) } else serviceClass << B_TRANSLATE("Unspecified"); - } void DeviceClass::GetMajorDeviceClass(BString& majorClass) { + CALLED(); static const char *major_devices[] = { B_TRANSLATE_MARK("Miscellaneous"), B_TRANSLATE_MARK("Computer"), B_TRANSLATE_MARK("Phone"), B_TRANSLATE_MARK("LAN access"), B_TRANSLATE_MARK("Audio/Video"), @@ -65,6 +67,7 @@ DeviceClass::GetMajorDeviceClass(BString& majorClass) void DeviceClass::GetMinorDeviceClass(BString& minorClass) { + CALLED(); uint major = MajorDeviceClass(); uint minor = MinorDeviceClass(); @@ -322,6 +325,7 @@ DeviceClass::GetMinorDeviceClass(BString& minorClass) void DeviceClass::DumpDeviceClass(BString& string) { + CALLED(); string << B_TRANSLATE("Service classes: "); GetServiceClass(string); string << " | "; @@ -337,6 +341,7 @@ DeviceClass::DumpDeviceClass(BString& string) void DeviceClass::Draw(BView* view, const BPoint& point) { + CALLED(); rgb_color kBlack = { 0,0,0,0 }; rgb_color kBlue = { 28,110,157,0 }; rgb_color kWhite = { 255,255,255,0 }; @@ -414,10 +419,8 @@ DeviceClass::Draw(BView* view, const BPoint& point) view->StrokeLine(BPoint(point.x + IconInsets + uint(PixelsForIcon/4), point.y + IconInsets + uint(PixelsForIcon/4))); break; - } - + } view->SetHighColor(kBlack); } - } diff --git a/src/kits/bluetooth/DiscoveryAgent.cpp b/src/kits/bluetooth/DiscoveryAgent.cpp index ece1202737..fb5a5e2e05 100644 --- a/src/kits/bluetooth/DiscoveryAgent.cpp +++ b/src/kits/bluetooth/DiscoveryAgent.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -23,6 +24,7 @@ namespace Bluetooth { RemoteDevicesList DiscoveryAgent::RetrieveDevices(int option) { + CALLED(); // No inquiry process initiated if (fLastUsedListener == NULL) return RemoteDevicesList(); @@ -34,6 +36,7 @@ DiscoveryAgent::RetrieveDevices(int option) status_t DiscoveryAgent::StartInquiry(int accessCode, DiscoveryListener* listener) { + CALLED(); return StartInquiry(accessCode, listener, GetInquiryTime()); } @@ -41,6 +44,7 @@ DiscoveryAgent::StartInquiry(int accessCode, DiscoveryListener* listener) status_t DiscoveryAgent::StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs) { + CALLED(); size_t size; if (fMessenger == NULL) @@ -91,6 +95,7 @@ DiscoveryAgent::StartInquiry(uint32 accessCode, DiscoveryListener* listener, big status_t DiscoveryAgent::CancelInquiry(DiscoveryListener* listener) { + CALLED(); size_t size; if (fMessenger == NULL) @@ -123,12 +128,14 @@ DiscoveryAgent::CancelInquiry(DiscoveryListener* listener) void DiscoveryAgent::SetLocalDeviceOwner(LocalDevice* ld) { + CALLED(); fLocalDevice = ld; } DiscoveryAgent::DiscoveryAgent(LocalDevice* ld) { + CALLED(); fLocalDevice = ld; fMessenger = _RetrieveBluetoothMessenger(); } @@ -136,6 +143,7 @@ DiscoveryAgent::DiscoveryAgent(LocalDevice* ld) DiscoveryAgent::~DiscoveryAgent() { + CALLED(); delete fMessenger; } diff --git a/src/kits/bluetooth/DiscoveryListener.cpp b/src/kits/bluetooth/DiscoveryListener.cpp index 6ee7bbb060..c8cf32e6d9 100644 --- a/src/kits/bluetooth/DiscoveryListener.cpp +++ b/src/kits/bluetooth/DiscoveryListener.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -24,21 +25,21 @@ namespace Bluetooth { void DiscoveryListener::DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod) { - + CALLED(); } void DiscoveryListener::InquiryStarted(status_t status) { - + CALLED(); } void DiscoveryListener::InquiryCompleted(int discType) { - + CALLED(); } @@ -50,6 +51,7 @@ DiscoveryListener::InquiryCompleted(int discType) void DiscoveryListener::SetLocalDeviceOwner(LocalDevice* ld) { + CALLED(); fLocalDevice = ld; } @@ -57,6 +59,7 @@ DiscoveryListener::SetLocalDeviceOwner(LocalDevice* ld) RemoteDevicesList DiscoveryListener::GetRemoteDevicesList(void) { + CALLED(); return fRemoteDevicesList; } @@ -64,6 +67,7 @@ DiscoveryListener::GetRemoteDevicesList(void) void DiscoveryListener::MessageReceived(BMessage* message) { + CALLED(); int8 status; switch (message->what) { @@ -147,9 +151,9 @@ DiscoveryListener::DiscoveryListener() BLooper(), fRemoteDevicesList(BT_MAX_RESPONSES) { + CALLED(); // TODO: Make a better handling of the running not running state Run(); } - } diff --git a/src/kits/bluetooth/KitSupport.cpp b/src/kits/bluetooth/KitSupport.cpp index 65f29bedc3..da9eef1136 100644 --- a/src/kits/bluetooth/KitSupport.cpp +++ b/src/kits/bluetooth/KitSupport.cpp @@ -6,6 +6,7 @@ */ #include #include +#include #include @@ -13,6 +14,7 @@ BMessenger* _RetrieveBluetoothMessenger(void) { + CALLED(); // Fix/review: leaking memory here BMessenger* fMessenger = new BMessenger(BLUETOOTH_SIGNATURE); @@ -26,12 +28,13 @@ BMessenger* _RetrieveBluetoothMessenger(void) uint8 GetInquiryTime() { + CALLED(); return BT_DEFAULT_INQUIRY_TIME; } void SetInquiryTime(uint8 time) { + CALLED(); ((void)(time)); } - diff --git a/src/kits/bluetooth/RemoteDevice.cpp b/src/kits/bluetooth/RemoteDevice.cpp index d80eb4f1f9..bbd8fcfe5d 100644 --- a/src/kits/bluetooth/RemoteDevice.cpp +++ b/src/kits/bluetooth/RemoteDevice.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -35,6 +36,7 @@ static const uint16 invalidConnectionHandle = 0xF000; bool RemoteDevice::IsTrustedDevice(void) { + CALLED(); return true; } @@ -42,6 +44,7 @@ RemoteDevice::IsTrustedDevice(void) BString RemoteDevice::GetFriendlyName(bool alwaysAsk) { + CALLED(); if (!alwaysAsk) { // Check if the name is already retrieved // TODO: Check if It is known from a KnownDevicesList @@ -101,6 +104,7 @@ RemoteDevice::GetFriendlyName(bool alwaysAsk) BString RemoteDevice::GetFriendlyName() { + CALLED(); return GetFriendlyName(true); } @@ -108,6 +112,7 @@ RemoteDevice::GetFriendlyName() bdaddr_t RemoteDevice::GetBluetoothAddress() { + CALLED(); return fBdaddr; } @@ -115,6 +120,7 @@ RemoteDevice::GetBluetoothAddress() bool RemoteDevice::Equals(RemoteDevice* obj) { + CALLED(); return bdaddrUtils::Compare(fBdaddr, obj->GetBluetoothAddress()); } @@ -125,6 +131,7 @@ RemoteDevice::Equals(RemoteDevice* obj) bool RemoteDevice::Authenticate() { + CALLED(); int8 btStatus = BT_ERROR; if (fMessenger == NULL || fDiscovererLocalDevice == NULL) @@ -200,6 +207,7 @@ RemoteDevice::Authenticate() status_t RemoteDevice::Disconnect(int8 reason) { + CALLED(); if (fHandle != invalidConnectionHandle) { int8 btStatus = BT_ERROR; @@ -248,6 +256,7 @@ RemoteDevice::Disconnect(int8 reason) bool RemoteDevice::IsAuthenticated() { + CALLED(); return true; } @@ -258,6 +267,7 @@ RemoteDevice::IsAuthenticated() bool RemoteDevice::IsEncrypted() { + CALLED(); return true; } @@ -265,6 +275,7 @@ RemoteDevice::IsEncrypted() LocalDevice* RemoteDevice::GetLocalDeviceOwner() { + CALLED(); return fDiscovererLocalDevice; } @@ -273,6 +284,7 @@ RemoteDevice::GetLocalDeviceOwner() void RemoteDevice::SetLocalDeviceOwner(LocalDevice* ld) { + CALLED(); fDiscovererLocalDevice = ld; } @@ -284,6 +296,7 @@ RemoteDevice::RemoteDevice(const bdaddr_t address, uint8 record[3]) fDiscovererLocalDevice(NULL), fHandle(invalidConnectionHandle) { + CALLED(); fBdaddr = address; fDeviceClass.SetRecord(record); fMessenger = _RetrieveBluetoothMessenger(); @@ -296,6 +309,7 @@ RemoteDevice::RemoteDevice(const BString& address) fDiscovererLocalDevice(NULL), fHandle(invalidConnectionHandle) { + CALLED(); fBdaddr = bdaddrUtils::FromString((const char*)address.String()); fMessenger = _RetrieveBluetoothMessenger(); } @@ -303,6 +317,7 @@ RemoteDevice::RemoteDevice(const BString& address) RemoteDevice::~RemoteDevice() { + CALLED(); delete fMessenger; } @@ -317,6 +332,7 @@ RemoteDevice::GetProperty(const char* property) /* Throwing */ status_t RemoteDevice::GetProperty(const char* property, uint32* value) /* Throwing */ { + CALLED(); return B_ERROR; } @@ -324,8 +340,8 @@ RemoteDevice::GetProperty(const char* property, uint32* value) /* Throwing */ DeviceClass RemoteDevice::GetDeviceClass() { + CALLED(); return fDeviceClass; } - }