1 /* 2 * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com 3 * 4 * All rights reserved. Distributed under the terms of the MIT License. 5 * 6 */ 7 8 #ifndef _BLUETOOTH_SERVER_APP_H 9 #define _BLUETOOTH_SERVER_APP_H 10 11 #include <stdlib.h> 12 #include <Application.h> 13 #include <OS.h> 14 #include <ObjectList.h> 15 16 #include "BPortNot.h" 17 #include "HCIDelegate.h" 18 #include "DeviceManager.h" 19 #include "LocalDeviceImpl.h" 20 21 #include <bluetooth/bluetooth.h> 22 #include <bluetooth/HCI/btHCI.h> 23 #include <bluetooth/HCI/btHCI_transport.h> 24 #include <bluetooth/HCI/btHCI_command.h> 25 26 27 #define BT "bluetooth_server: " 28 29 #define BLACKBOARD_GENERAL 0 30 #define BLACKBOARD_DEVICEMANAGER 1 31 #define BLACKBOARD_EVENTS 2 32 #define BLACKBOARD_KIT 3 33 #define BLACKBOARD_LD_OFFSET 4 34 35 typedef BObjectList<LocalDeviceImpl> LocalDevicesList; 36 37 38 class BluetoothServer : public BApplication 39 { 40 public: 41 42 BluetoothServer(); 43 44 virtual bool QuitRequested(void); 45 virtual void ArgvReceived(int32 argc, char **argv); 46 virtual void ReadyToRun(void); 47 48 49 virtual void AppActivated(bool act); 50 virtual void MessageReceived(BMessage *message); 51 52 53 static int32 notification_Thread(void* data); 54 static int32 sdp_server_Thread(void* data); 55 56 /* Messages reply */ 57 status_t HandleLocalDevicesCount(BMessage* message, BMessage* reply); 58 status_t HandleAcquireLocalDevice(BMessage* message, BMessage* reply); 59 status_t HandleGetFriendlyName(BMessage* message, BMessage* reply); 60 status_t HandleGetAddress(BMessage* message, BMessage* reply); 61 62 status_t HandleSimpleRequest(BMessage* message, BMessage* reply); 63 64 65 LocalDeviceImpl* LocateLocalDeviceImpl(hci_id hid); 66 67 private: 68 69 LocalDeviceImpl* LocateDelegateFromMessage(BMessage* message); 70 71 void ShowWindow(BWindow* pWindow); 72 73 LocalDevicesList fLocalDevicesList; 74 // UI 75 76 // Notification system 77 thread_id fEventListener; 78 DeviceManager* fDeviceManager; 79 80 BPoint fCenter; 81 }; 82 83 #endif 84