- Add candidate interface for addons with custom configuration for LocalDevices.
- Add example implementation for Devices which need issue a Reset Command git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30300 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a87124634a
commit
c3053cacff
32
headers/os/bluetooth/LocalDeviceAddOn.h
Normal file
32
headers/os/bluetooth/LocalDeviceAddOn.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef LOCAL_DEVICE_ADDON_H
|
||||
#define LOCAL_DEVICE_ADDON_H
|
||||
|
||||
#include <bluetooth/LocalDevice.h>
|
||||
#include <bluetooth/RemoteDevice.h>
|
||||
|
||||
class LocalDeviceAddOn {
|
||||
|
||||
public:
|
||||
|
||||
LocalDeviceAddOn();
|
||||
virtual const char* GetName()=0;
|
||||
|
||||
virtual status_t InitCheck(LocalDevice* lDevice)=0;
|
||||
|
||||
virtual const char* GetActionDescription()=0;
|
||||
virtual status_t TakeAction(LocalDevice* lDevice)=0;
|
||||
|
||||
virtual const char* GetActionOnRemoteDescription()=0;
|
||||
virtual status_t TakeActionOnRemote(LocalDevice* lDevice, RemoteDevice* rDevice)=0;
|
||||
|
||||
virtual const char* GetOverridenPropertiesDescription()=0;
|
||||
virtual BMessage* OverridenProperties(LocalDevice* lDevice, const char* property)=0;
|
||||
|
||||
};
|
||||
|
||||
#define INSTANTIATE_LOCAL_DEVICE_ADDON(addon) LocalDeviceAddOn* InstantiateLocalDeviceAddOn(){return new addon();}
|
||||
#define EXPORT_LOCAL_DEVICE_ADDON extern "C" __declspec(dllexport) LocalDeviceAddOn* InstantiateLocalDeviceAddOn();
|
||||
|
||||
|
||||
|
||||
#endif
|
3
src/add-ons/bluetooth/Jamfile
Normal file
3
src/add-ons/bluetooth/Jamfile
Normal file
@ -0,0 +1,3 @@
|
||||
SubDir HAIKU_TOP src add-ons bluetooth ;
|
||||
|
||||
SubInclude HAIKU_TOP src add-ons bluetooth ResetLocalDevice ;
|
8
src/add-ons/bluetooth/ResetLocalDevice/Jamfile
Normal file
8
src/add-ons/bluetooth/ResetLocalDevice/Jamfile
Normal file
@ -0,0 +1,8 @@
|
||||
SubDir HAIKU_TOP src add-ons bluetooth ResetLocalDevice ;
|
||||
|
||||
UsePrivateHeaders bluetooth ;
|
||||
|
||||
Addon ClassicBe :
|
||||
ResetLocalDevice.cpp
|
||||
: be
|
||||
;
|
105
src/add-ons/bluetooth/ResetLocalDevice/ResetLocalDevice.cpp
Normal file
105
src/add-ons/bluetooth/ResetLocalDevice/ResetLocalDevice.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
#include "ResetLocalDevice.h"
|
||||
|
||||
#include <Messenger.h>
|
||||
|
||||
#include <bluetooth/bluetooth_error.h>
|
||||
#include <bluetooth/HCI/btHCI_command.h>
|
||||
#include <bluetooth/HCI/btHCI_event.h>
|
||||
|
||||
#include <bluetoothserver_p.h>
|
||||
#include <CommandManager.h>
|
||||
|
||||
|
||||
|
||||
ResetLocalDeviceAddOn::ResetLocalDeviceAddOn()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
ResetLocalDeviceAddOn::GetName()
|
||||
{
|
||||
return "Reset LocalDevice";
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ResetLocalDeviceAddOn::InitCheck(LocalDevice* lDevice)
|
||||
{
|
||||
// you can perform a Reset in all Devices
|
||||
fCheck = B_OK;
|
||||
return fCheck;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
ResetLocalDeviceAddOn::GetActionDescription()
|
||||
{
|
||||
return "Perform a Reset command to the LocalDevice";
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ResetLocalDeviceAddOn::TakeAction(LocalDevice* lDevice)
|
||||
{
|
||||
int8 bt_status = BT_ERROR;
|
||||
|
||||
BMessenger* fMessenger = new BMessenger(BLUETOOTH_SIGNATURE);
|
||||
|
||||
if (fMessenger == NULL || !fMessenger->IsValid())
|
||||
return B_ERROR;
|
||||
|
||||
BluetoothCommand<> Reset(OGF_CONTROL_BASEBAND, OCF_RESET);
|
||||
|
||||
BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST);
|
||||
BMessage reply;
|
||||
|
||||
request.AddInt32("hci_id", lDevice->GetID());
|
||||
request.AddData("raw command", B_ANY_TYPE, Reset.Data(), Reset.Size());
|
||||
request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE);
|
||||
request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_RESET));
|
||||
|
||||
if (fMessenger->SendMessage(&request, &reply) == B_OK)
|
||||
reply.FindInt8("status", &bt_status);
|
||||
|
||||
return bt_status;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
ResetLocalDeviceAddOn::GetActionOnRemoteDescription()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ResetLocalDeviceAddOn::TakeActionOnRemote(LocalDevice* lDevice, RemoteDevice* rDevice)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
ResetLocalDeviceAddOn::GetOverridenPropertiesDescription()
|
||||
{
|
||||
// Example usage:
|
||||
//return "Replace the max count of SCO packets";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
BMessage*
|
||||
ResetLocalDeviceAddOn::OverridenProperties(LocalDevice* lDevice, const char* property)
|
||||
{
|
||||
// Example usage:
|
||||
//BMessage* newProperties = new BMessage();
|
||||
//newProperties->AddInt8("max_sco", 10);
|
||||
//return newProperties;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
INSTANTIATE_LOCAL_DEVICE_ADDON(ResetLocalDeviceAddOn);
|
||||
EXPORT_LOCAL_DEVICE_ADDON;
|
26
src/add-ons/bluetooth/ResetLocalDevice/ResetLocalDevice.h
Normal file
26
src/add-ons/bluetooth/ResetLocalDevice/ResetLocalDevice.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef RESET_LOCAL_DEVICE_ADDON_H
|
||||
#define RESET_LOCAL_DEVICE_ADDON_H
|
||||
|
||||
#include <bluetooth/LocalDeviceAddOn.h>
|
||||
|
||||
class ResetLocalDeviceAddOn : public LocalDeviceAddOn {
|
||||
|
||||
public:
|
||||
ResetLocalDeviceAddOn();
|
||||
|
||||
const char* GetName();
|
||||
status_t InitCheck(LocalDevice* lDevice);
|
||||
|
||||
const char* GetActionDescription();
|
||||
status_t TakeAction(LocalDevice* lDevice);
|
||||
|
||||
const char* GetActionOnRemoteDescription();
|
||||
status_t TakeActionOnRemote(LocalDevice* lDevice, RemoteDevice* rDevice);
|
||||
|
||||
const char* GetOverridenPropertiesDescription();
|
||||
BMessage* OverridenProperties(LocalDevice* lDevice, const char* property);
|
||||
private:
|
||||
status_t fCheck;
|
||||
};
|
||||
|
||||
#endif // RESET_LOCAL_DEVICE_ADDON_H
|
Loading…
Reference in New Issue
Block a user