2 * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3 * All rights reserved. Distributed under the terms of the MIT License.
5 #ifndef _BLUETOOTH_SERVER_APP_H
6 #define _BLUETOOTH_SERVER_APP_H
10 #include <Application.h>
11 #include <ObjectList.h>
14 #include <bluetooth/bluetooth.h>
15 #include <bluetooth/HCI/btHCI.h>
16 #include <bluetooth/HCI/btHCI_transport.h>
17 #include <bluetooth/HCI/btHCI_command.h>
19 #include "HCIDelegate.h"
20 #include "DeviceManager.h"
21 #include "LocalDeviceImpl.h"
23 #include <PortListener.h>
25 #define BT "bluetooth_server: "
28 BLACKBOARD_GENERAL
= 0,
29 BLACKBOARD_DEVICEMANAGER
,
34 } BluetoothServerBlackBoardIndex
;
36 #define BLACKBOARD_LD(X) (BLACKBOARD_END+X-HCI_DEVICE_INDEX_OFFSET)
38 typedef BObjectList
<LocalDeviceImpl
> LocalDevicesList
;
39 typedef PortListener
<struct hci_event_header
,
40 HCI_MAX_EVENT_SIZE
, // Event Body can hold max 255 + 2 header
41 24 // Some devices have sent chunks of 24 events(inquiry result)
42 > BluetoothPortListener
;
44 class BluetoothServer
: public BApplication
50 virtual bool QuitRequested(void);
51 virtual void ArgvReceived(int32 argc
, char **argv
);
52 virtual void ReadyToRun(void);
55 virtual void AppActivated(bool act
);
56 virtual void MessageReceived(BMessage
*message
);
58 static int32
SDPServerThread(void* data
);
61 status_t
HandleLocalDevicesCount(BMessage
* message
, BMessage
* reply
);
62 status_t
HandleAcquireLocalDevice(BMessage
* message
, BMessage
* reply
);
64 status_t
HandleGetProperty(BMessage
* message
, BMessage
* reply
);
65 status_t
HandleSimpleRequest(BMessage
* message
, BMessage
* reply
);
68 LocalDeviceImpl
* LocateLocalDeviceImpl(hci_id hid
);
72 LocalDeviceImpl
* LocateDelegateFromMessage(BMessage
* message
);
74 void ShowWindow(BWindow
* pWindow
);
76 void _InstallDeskbarIcon();
77 void _RemoveDeskbarIcon();
79 LocalDevicesList fLocalDevicesList
;
82 // Notification system
83 BluetoothPortListener
* fEventListener2
;
85 DeviceManager
* fDeviceManager
;
89 thread_id fSDPThreadID
;