From b48fa68ace063e766334c04d4e9ed0d2a96ac3b2 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Thu, 31 Jul 2008 21:03:17 +0000 Subject: [PATCH] Fix bluetooth_server debug window tabs, they were getting out of bounds due the index assignation git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26704 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/bluetooth/HCI/btHCI.h | 1 + .../network/devices/bluetooth/bluetooth.cpp | 9 +++++---- src/servers/bluetooth/BluetoothServer.cpp | 8 ++++---- src/servers/bluetooth/BluetoothServer.h | 15 ++++++++++----- src/servers/bluetooth/LocalDeviceImpl.cpp | 8 ++++---- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/headers/os/bluetooth/HCI/btHCI.h b/headers/os/bluetooth/HCI/btHCI.h index e68738bf8e..0ec0f49718 100644 --- a/headers/os/bluetooth/HCI/btHCI.h +++ b/headers/os/bluetooth/HCI/btHCI.h @@ -10,6 +10,7 @@ /* typedefs */ typedef int32 hci_id; +#define HCI_DEVICE_INDEX_OFFSET 0x7c typedef enum { H2 = 2, H3, H4, H5 } transport_type; diff --git a/src/add-ons/kernel/network/devices/bluetooth/bluetooth.cpp b/src/add-ons/kernel/network/devices/bluetooth/bluetooth.cpp index 902939ad90..af41ebcc9b 100644 --- a/src/add-ons/kernel/network/devices/bluetooth/bluetooth.cpp +++ b/src/add-ons/kernel/network/devices/bluetooth/bluetooth.cpp @@ -32,6 +32,7 @@ #define SUBMODULE_COLOR 34 #include +#include struct bluetooth_device : net_device, DoublyLinkedListLinkImpl { int fd; @@ -77,14 +78,14 @@ bluetooth_init(const char *name, net_device **_device) MutexLocker _(&sListLock); if (sDeviceList.IsEmpty()) - device->index = 0x0000007C; // REVIEW: dev index + device->index = HCI_DEVICE_INDEX_OFFSET; // REVIEW: dev index else device->index = (sDeviceList.Tail())->index + 1; // TODO: index will be assigned by netstack // TODO: add to list whould be done in up hook sDeviceList.Add(device); - debugf("Device %s %x\n", device->name, device->index ); + debugf("Device %s %lx\n", device->name, device->index ); *_device = device; return B_OK; @@ -96,7 +97,7 @@ bluetooth_uninit(net_device *_device) { bluetooth_device *device = (bluetooth_device *)_device; - debugf("index %x\n",device->index); + debugf("index %lx\n",device->index); // if the device is still part of the list, remove it if (device->GetDoublyLinkedListLink()->next != NULL @@ -258,7 +259,7 @@ dump_bluetooth_devices(int argc, char** argv) while (iterator.HasNext()) { device = iterator.Next(); - kprintf("\tname=%s index=%#x\n",device->name, device->index); + kprintf("\tname=%s index=%#lx\n",device->name, device->index); } return 0; diff --git a/src/servers/bluetooth/BluetoothServer.cpp b/src/servers/bluetooth/BluetoothServer.cpp index 5ea9f73d71..b9c9d5d5c5 100644 --- a/src/servers/bluetooth/BluetoothServer.cpp +++ b/src/servers/bluetooth/BluetoothServer.cpp @@ -125,13 +125,13 @@ void BluetoothServer::MessageReceived(BMessage *message) if (ldi->GetID() >= 0) { fLocalDevicesList.AddItem(ldi); - Output::Instance()->AddTab("Local Device", BLACKBOARD_LD_OFFSET + ldi->GetID()); - (Output::Instance()->Post( str.String(), BLACKBOARD_LD_OFFSET + ldi->GetID())); - (Output::Instance()->Post(" LocalDevice added\n", BLACKBOARD_LD_OFFSET + ldi->GetID())); + Output::Instance()->AddTab("Local Device", BLACKBOARD_LD(ldi->GetID())); + (Output::Instance()->Post( str.String(), BLACKBOARD_LD(ldi->GetID()))); + (Output::Instance()->Post(" LocalDevice added\n", BLACKBOARD_LD(ldi->GetID()))); } else { - (Output::Instance()->Post("Adding LocalDevice failed\n", BLACKBOARD_GENERAL)); + (Output::Instance()->Post("Adding LocalDevice failed\n", BLACKBOARD_GENERAL)); } status = B_WOULD_BLOCK; diff --git a/src/servers/bluetooth/BluetoothServer.h b/src/servers/bluetooth/BluetoothServer.h index 35d8be5f1c..d779997b56 100644 --- a/src/servers/bluetooth/BluetoothServer.h +++ b/src/servers/bluetooth/BluetoothServer.h @@ -26,11 +26,16 @@ #define BT "bluetooth_server: " -#define BLACKBOARD_GENERAL 0 -#define BLACKBOARD_DEVICEMANAGER 1 -#define BLACKBOARD_EVENTS 2 -#define BLACKBOARD_KIT 3 -#define BLACKBOARD_LD_OFFSET 4 +typedef enum { + BLACKBOARD_GENERAL = 0, + BLACKBOARD_DEVICEMANAGER, + BLACKBOARD_EVENTS, + BLACKBOARD_KIT, + // more blackboards + BLACKBOARD_END +} BluetoothServerBlackBoardIndex; + +#define BLACKBOARD_LD(X) (BLACKBOARD_END+X+HCI_DEVICE_INDEX_OFFSET) typedef BObjectList LocalDevicesList; diff --git a/src/servers/bluetooth/LocalDeviceImpl.cpp b/src/servers/bluetooth/LocalDeviceImpl.cpp index 89a10146a6..8142a3c9bf 100644 --- a/src/servers/bluetooth/LocalDeviceImpl.cpp +++ b/src/servers/bluetooth/LocalDeviceImpl.cpp @@ -244,8 +244,8 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re int16 opcodeExpected; BMessage reply; - Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD_OFFSET + GetID()); - Output::Instance()->Post("\n", BLACKBOARD_LD_OFFSET + GetID()); + Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD(GetID())); + Output::Instance()->Post("\n", BLACKBOARD_LD(GetID())); // Handle command complete information request->FindInt16("opcodeExpected", index, &opcodeExpected); @@ -394,8 +394,8 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques int16 opcodeExpected; BMessage reply; - Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD_OFFSET + GetID()); - Output::Instance()->Post("\n", BLACKBOARD_LD_OFFSET + GetID()); + Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD(GetID())); + Output::Instance()->Post("\n", BLACKBOARD_LD(GetID())); // Handle command complete information request->FindInt16("opcodeExpected", index, &opcodeExpected);