130f1d1f3SOliver Ruiz Dorantes /* 230f1d1f3SOliver Ruiz Dorantes * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com 330f1d1f3SOliver Ruiz Dorantes * 430f1d1f3SOliver Ruiz Dorantes * All rights reserved. Distributed under the terms of the MIT License. 530f1d1f3SOliver Ruiz Dorantes * 630f1d1f3SOliver Ruiz Dorantes */ 730f1d1f3SOliver Ruiz Dorantes 830f1d1f3SOliver Ruiz Dorantes #ifndef _BLUETOOTH_SERVER_APP_H 930f1d1f3SOliver Ruiz Dorantes #define _BLUETOOTH_SERVER_APP_H 1030f1d1f3SOliver Ruiz Dorantes 1130f1d1f3SOliver Ruiz Dorantes #include <stdlib.h> 1230f1d1f3SOliver Ruiz Dorantes 13*c6083519SOliver Ruiz Dorantes #include <Application.h> 14*c6083519SOliver Ruiz Dorantes #include <ObjectList.h> 15*c6083519SOliver Ruiz Dorantes #include <OS.h> 1630f1d1f3SOliver Ruiz Dorantes 1730f1d1f3SOliver Ruiz Dorantes #include <bluetooth/bluetooth.h> 1830f1d1f3SOliver Ruiz Dorantes #include <bluetooth/HCI/btHCI.h> 1930f1d1f3SOliver Ruiz Dorantes #include <bluetooth/HCI/btHCI_transport.h> 2030f1d1f3SOliver Ruiz Dorantes #include <bluetooth/HCI/btHCI_command.h> 2130f1d1f3SOliver Ruiz Dorantes 22*c6083519SOliver Ruiz Dorantes #include "HCIDelegate.h" 23*c6083519SOliver Ruiz Dorantes #include "DeviceManager.h" 24*c6083519SOliver Ruiz Dorantes #include "LocalDeviceImpl.h" 25*c6083519SOliver Ruiz Dorantes 26*c6083519SOliver Ruiz Dorantes #include <PortListener.h> 2730f1d1f3SOliver Ruiz Dorantes 2830f1d1f3SOliver Ruiz Dorantes #define BT "bluetooth_server: " 2930f1d1f3SOliver Ruiz Dorantes 30b48fa68aSOliver Ruiz Dorantes typedef enum { 31b48fa68aSOliver Ruiz Dorantes BLACKBOARD_GENERAL = 0, 32b48fa68aSOliver Ruiz Dorantes BLACKBOARD_DEVICEMANAGER, 33b48fa68aSOliver Ruiz Dorantes BLACKBOARD_KIT, 34b48fa68aSOliver Ruiz Dorantes // more blackboards 35b48fa68aSOliver Ruiz Dorantes BLACKBOARD_END 36b48fa68aSOliver Ruiz Dorantes } BluetoothServerBlackBoardIndex; 37b48fa68aSOliver Ruiz Dorantes 38bbe09899SOliver Ruiz Dorantes #define BLACKBOARD_LD(X) (BLACKBOARD_END+X-HCI_DEVICE_INDEX_OFFSET) 3930f1d1f3SOliver Ruiz Dorantes 4030f1d1f3SOliver Ruiz Dorantes typedef BObjectList<LocalDeviceImpl> LocalDevicesList; 41*c6083519SOliver Ruiz Dorantes typedef PortListener<struct hci_event_header> BluetoothPortListener; 4230f1d1f3SOliver Ruiz Dorantes 4330f1d1f3SOliver Ruiz Dorantes class BluetoothServer : public BApplication 4430f1d1f3SOliver Ruiz Dorantes { 4530f1d1f3SOliver Ruiz Dorantes public: 4630f1d1f3SOliver Ruiz Dorantes 4730f1d1f3SOliver Ruiz Dorantes BluetoothServer(); 4830f1d1f3SOliver Ruiz Dorantes 4930f1d1f3SOliver Ruiz Dorantes virtual bool QuitRequested(void); 5030f1d1f3SOliver Ruiz Dorantes virtual void ArgvReceived(int32 argc, char **argv); 5130f1d1f3SOliver Ruiz Dorantes virtual void ReadyToRun(void); 5230f1d1f3SOliver Ruiz Dorantes 5330f1d1f3SOliver Ruiz Dorantes 5430f1d1f3SOliver Ruiz Dorantes virtual void AppActivated(bool act); 5530f1d1f3SOliver Ruiz Dorantes virtual void MessageReceived(BMessage *message); 5630f1d1f3SOliver Ruiz Dorantes 5730f1d1f3SOliver Ruiz Dorantes static int32 sdp_server_Thread(void* data); 5830f1d1f3SOliver Ruiz Dorantes 5930f1d1f3SOliver Ruiz Dorantes /* Messages reply */ 6030f1d1f3SOliver Ruiz Dorantes status_t HandleLocalDevicesCount(BMessage* message, BMessage* reply); 6130f1d1f3SOliver Ruiz Dorantes status_t HandleAcquireLocalDevice(BMessage* message, BMessage* reply); 6230f1d1f3SOliver Ruiz Dorantes 633fdaa5bfSOliver Ruiz Dorantes status_t HandleGetProperty(BMessage* message, BMessage* reply); 6430f1d1f3SOliver Ruiz Dorantes status_t HandleSimpleRequest(BMessage* message, BMessage* reply); 6530f1d1f3SOliver Ruiz Dorantes 6630f1d1f3SOliver Ruiz Dorantes 6730f1d1f3SOliver Ruiz Dorantes LocalDeviceImpl* LocateLocalDeviceImpl(hci_id hid); 6830f1d1f3SOliver Ruiz Dorantes 6930f1d1f3SOliver Ruiz Dorantes private: 7030f1d1f3SOliver Ruiz Dorantes 7130f1d1f3SOliver Ruiz Dorantes LocalDeviceImpl* LocateDelegateFromMessage(BMessage* message); 7230f1d1f3SOliver Ruiz Dorantes 7330f1d1f3SOliver Ruiz Dorantes void ShowWindow(BWindow* pWindow); 7430f1d1f3SOliver Ruiz Dorantes 7530f1d1f3SOliver Ruiz Dorantes LocalDevicesList fLocalDevicesList; 76*c6083519SOliver Ruiz Dorantes 7730f1d1f3SOliver Ruiz Dorantes 7830f1d1f3SOliver Ruiz Dorantes // Notification system 79*c6083519SOliver Ruiz Dorantes BluetoothPortListener* fEventListener2; 80*c6083519SOliver Ruiz Dorantes 8130f1d1f3SOliver Ruiz Dorantes DeviceManager* fDeviceManager; 8230f1d1f3SOliver Ruiz Dorantes 8330f1d1f3SOliver Ruiz Dorantes BPoint fCenter; 8430f1d1f3SOliver Ruiz Dorantes }; 8530f1d1f3SOliver Ruiz Dorantes 8630f1d1f3SOliver Ruiz Dorantes #endif 87