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
This commit is contained in:
Oliver Ruiz Dorantes
2008-07-31 21:03:17 +00:00
parent 12c9f1761f
commit b48fa68ace
5 changed files with 24 additions and 17 deletions
+1
View File
@@ -10,6 +10,7 @@
/* typedefs */ /* typedefs */
typedef int32 hci_id; typedef int32 hci_id;
#define HCI_DEVICE_INDEX_OFFSET 0x7c
typedef enum { H2 = 2, H3, H4, H5 } transport_type; typedef enum { H2 = 2, H3, H4, H5 } transport_type;
@@ -32,6 +32,7 @@
#define SUBMODULE_COLOR 34 #define SUBMODULE_COLOR 34
#include <btDebug.h> #include <btDebug.h>
#include <bluetooth/HCI/btHCI.h>
struct bluetooth_device : net_device, DoublyLinkedListLinkImpl<bluetooth_device> { struct bluetooth_device : net_device, DoublyLinkedListLinkImpl<bluetooth_device> {
int fd; int fd;
@@ -77,14 +78,14 @@ bluetooth_init(const char *name, net_device **_device)
MutexLocker _(&sListLock); MutexLocker _(&sListLock);
if (sDeviceList.IsEmpty()) if (sDeviceList.IsEmpty())
device->index = 0x0000007C; // REVIEW: dev index device->index = HCI_DEVICE_INDEX_OFFSET; // REVIEW: dev index
else else
device->index = (sDeviceList.Tail())->index + 1; // TODO: index will be assigned by netstack device->index = (sDeviceList.Tail())->index + 1; // TODO: index will be assigned by netstack
// TODO: add to list whould be done in up hook // TODO: add to list whould be done in up hook
sDeviceList.Add(device); sDeviceList.Add(device);
debugf("Device %s %x\n", device->name, device->index ); debugf("Device %s %lx\n", device->name, device->index );
*_device = device; *_device = device;
return B_OK; return B_OK;
@@ -96,7 +97,7 @@ bluetooth_uninit(net_device *_device)
{ {
bluetooth_device *device = (bluetooth_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 the device is still part of the list, remove it
if (device->GetDoublyLinkedListLink()->next != NULL if (device->GetDoublyLinkedListLink()->next != NULL
@@ -258,7 +259,7 @@ dump_bluetooth_devices(int argc, char** argv)
while (iterator.HasNext()) { while (iterator.HasNext()) {
device = iterator.Next(); 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; return 0;
+4 -4
View File
@@ -125,13 +125,13 @@ void BluetoothServer::MessageReceived(BMessage *message)
if (ldi->GetID() >= 0) { if (ldi->GetID() >= 0) {
fLocalDevicesList.AddItem(ldi); fLocalDevicesList.AddItem(ldi);
Output::Instance()->AddTab("Local Device", BLACKBOARD_LD_OFFSET + ldi->GetID()); Output::Instance()->AddTab("Local Device", BLACKBOARD_LD(ldi->GetID()));
(Output::Instance()->Post( str.String(), BLACKBOARD_LD_OFFSET + ldi->GetID())); (Output::Instance()->Post( str.String(), BLACKBOARD_LD(ldi->GetID())));
(Output::Instance()->Post(" LocalDevice added\n", BLACKBOARD_LD_OFFSET + ldi->GetID())); (Output::Instance()->Post(" LocalDevice added\n", BLACKBOARD_LD(ldi->GetID())));
} else { } else {
(Output::Instance()->Post("Adding LocalDevice failed\n", BLACKBOARD_GENERAL)); (Output::Instance()->Post("Adding LocalDevice failed\n", BLACKBOARD_GENERAL));
} }
status = B_WOULD_BLOCK; status = B_WOULD_BLOCK;
+10 -5
View File
@@ -26,11 +26,16 @@
#define BT "bluetooth_server: " #define BT "bluetooth_server: "
#define BLACKBOARD_GENERAL 0 typedef enum {
#define BLACKBOARD_DEVICEMANAGER 1 BLACKBOARD_GENERAL = 0,
#define BLACKBOARD_EVENTS 2 BLACKBOARD_DEVICEMANAGER,
#define BLACKBOARD_KIT 3 BLACKBOARD_EVENTS,
#define BLACKBOARD_LD_OFFSET 4 BLACKBOARD_KIT,
// more blackboards
BLACKBOARD_END
} BluetoothServerBlackBoardIndex;
#define BLACKBOARD_LD(X) (BLACKBOARD_END+X+HCI_DEVICE_INDEX_OFFSET)
typedef BObjectList<LocalDeviceImpl> LocalDevicesList; typedef BObjectList<LocalDeviceImpl> LocalDevicesList;
+4 -4
View File
@@ -244,8 +244,8 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
int16 opcodeExpected; int16 opcodeExpected;
BMessage reply; BMessage reply;
Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD_OFFSET + GetID()); Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD(GetID()));
Output::Instance()->Post("\n", BLACKBOARD_LD_OFFSET + GetID()); Output::Instance()->Post("\n", BLACKBOARD_LD(GetID()));
// Handle command complete information // Handle command complete information
request->FindInt16("opcodeExpected", index, &opcodeExpected); request->FindInt16("opcodeExpected", index, &opcodeExpected);
@@ -394,8 +394,8 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques
int16 opcodeExpected; int16 opcodeExpected;
BMessage reply; BMessage reply;
Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD_OFFSET + GetID()); Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD(GetID()));
Output::Instance()->Post("\n", BLACKBOARD_LD_OFFSET + GetID()); Output::Instance()->Post("\n", BLACKBOARD_LD(GetID()));
// Handle command complete information // Handle command complete information
request->FindInt16("opcodeExpected", index, &opcodeExpected); request->FindInt16("opcodeExpected", index, &opcodeExpected);