1c3053cacSOliver Ruiz Dorantes #include "ResetLocalDevice.h"
2c3053cacSOliver Ruiz Dorantes
3c3053cacSOliver Ruiz Dorantes #include <Messenger.h>
4c3053cacSOliver Ruiz Dorantes
5c3053cacSOliver Ruiz Dorantes #include <bluetooth/bluetooth_error.h>
6c3053cacSOliver Ruiz Dorantes #include <bluetooth/HCI/btHCI_command.h>
7c3053cacSOliver Ruiz Dorantes #include <bluetooth/HCI/btHCI_event.h>
8c3053cacSOliver Ruiz Dorantes
9c3053cacSOliver Ruiz Dorantes #include <bluetoothserver_p.h>
10c3053cacSOliver Ruiz Dorantes #include <CommandManager.h>
11c3053cacSOliver Ruiz Dorantes
12c3053cacSOliver Ruiz Dorantes
ResetLocalDeviceAddOn()13c3053cacSOliver Ruiz Dorantes ResetLocalDeviceAddOn::ResetLocalDeviceAddOn()
14c3053cacSOliver Ruiz Dorantes {
15c3053cacSOliver Ruiz Dorantes
16c3053cacSOliver Ruiz Dorantes }
17c3053cacSOliver Ruiz Dorantes
18c3053cacSOliver Ruiz Dorantes
19c3053cacSOliver Ruiz Dorantes const char*
GetName()20c3053cacSOliver Ruiz Dorantes ResetLocalDeviceAddOn::GetName()
21c3053cacSOliver Ruiz Dorantes {
22c3053cacSOliver Ruiz Dorantes return "Reset LocalDevice";
23c3053cacSOliver Ruiz Dorantes }
24c3053cacSOliver Ruiz Dorantes
25c3053cacSOliver Ruiz Dorantes
26c3053cacSOliver Ruiz Dorantes status_t
InitCheck(LocalDevice * lDevice)27c3053cacSOliver Ruiz Dorantes ResetLocalDeviceAddOn::InitCheck(LocalDevice* lDevice)
28c3053cacSOliver Ruiz Dorantes {
29c3053cacSOliver Ruiz Dorantes // you can perform a Reset in all Devices
30c3053cacSOliver Ruiz Dorantes fCheck = B_OK;
31c3053cacSOliver Ruiz Dorantes return fCheck;
32c3053cacSOliver Ruiz Dorantes }
33c3053cacSOliver Ruiz Dorantes
34c3053cacSOliver Ruiz Dorantes
35c3053cacSOliver Ruiz Dorantes const char*
GetActionDescription()36c3053cacSOliver Ruiz Dorantes ResetLocalDeviceAddOn::GetActionDescription()
37c3053cacSOliver Ruiz Dorantes {
38c3053cacSOliver Ruiz Dorantes return "Perform a Reset command to the LocalDevice";
39c3053cacSOliver Ruiz Dorantes }
40c3053cacSOliver Ruiz Dorantes
41c3053cacSOliver Ruiz Dorantes
42c3053cacSOliver Ruiz Dorantes status_t
TakeAction(LocalDevice * lDevice)43c3053cacSOliver Ruiz Dorantes ResetLocalDeviceAddOn::TakeAction(LocalDevice* lDevice)
44c3053cacSOliver Ruiz Dorantes {
45*9a597aaeSOliver Ruiz Dorantes int8 btStatus = BT_ERROR;
46c3053cacSOliver Ruiz Dorantes
47c3053cacSOliver Ruiz Dorantes BMessenger* fMessenger = new BMessenger(BLUETOOTH_SIGNATURE);
48c3053cacSOliver Ruiz Dorantes
49c3053cacSOliver Ruiz Dorantes if (fMessenger == NULL || !fMessenger->IsValid())
50c3053cacSOliver Ruiz Dorantes return B_ERROR;
51c3053cacSOliver Ruiz Dorantes
52c3053cacSOliver Ruiz Dorantes BluetoothCommand<> Reset(OGF_CONTROL_BASEBAND, OCF_RESET);
53c3053cacSOliver Ruiz Dorantes
54c3053cacSOliver Ruiz Dorantes BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST);
55c3053cacSOliver Ruiz Dorantes BMessage reply;
56c3053cacSOliver Ruiz Dorantes
57*9a597aaeSOliver Ruiz Dorantes request.AddInt32("hci_id", lDevice->ID());
58c3053cacSOliver Ruiz Dorantes request.AddData("raw command", B_ANY_TYPE, Reset.Data(), Reset.Size());
59c3053cacSOliver Ruiz Dorantes request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE);
60c3053cacSOliver Ruiz Dorantes request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_RESET));
61c3053cacSOliver Ruiz Dorantes
62c3053cacSOliver Ruiz Dorantes if (fMessenger->SendMessage(&request, &reply) == B_OK)
63*9a597aaeSOliver Ruiz Dorantes reply.FindInt8("status", &btStatus);
64c3053cacSOliver Ruiz Dorantes
65*9a597aaeSOliver Ruiz Dorantes return btStatus;
66c3053cacSOliver Ruiz Dorantes }
67c3053cacSOliver Ruiz Dorantes
68c3053cacSOliver Ruiz Dorantes
69c3053cacSOliver Ruiz Dorantes const char*
GetActionOnRemoteDescription()70c3053cacSOliver Ruiz Dorantes ResetLocalDeviceAddOn::GetActionOnRemoteDescription()
71c3053cacSOliver Ruiz Dorantes {
72c3053cacSOliver Ruiz Dorantes return NULL;
73c3053cacSOliver Ruiz Dorantes }
74c3053cacSOliver Ruiz Dorantes
75c3053cacSOliver Ruiz Dorantes
76c3053cacSOliver Ruiz Dorantes status_t
TakeActionOnRemote(LocalDevice * lDevice,RemoteDevice * rDevice)77c3053cacSOliver Ruiz Dorantes ResetLocalDeviceAddOn::TakeActionOnRemote(LocalDevice* lDevice, RemoteDevice* rDevice)
78c3053cacSOliver Ruiz Dorantes {
79c3053cacSOliver Ruiz Dorantes return B_NOT_SUPPORTED;
80c3053cacSOliver Ruiz Dorantes }
81c3053cacSOliver Ruiz Dorantes
82c3053cacSOliver Ruiz Dorantes
83c3053cacSOliver Ruiz Dorantes const char*
GetOverridenPropertiesDescription()84c3053cacSOliver Ruiz Dorantes ResetLocalDeviceAddOn::GetOverridenPropertiesDescription()
85c3053cacSOliver Ruiz Dorantes {
86c3053cacSOliver Ruiz Dorantes // Example usage:
87c3053cacSOliver Ruiz Dorantes //return "Replace the max count of SCO packets";
88c3053cacSOliver Ruiz Dorantes return NULL;
89c3053cacSOliver Ruiz Dorantes }
90c3053cacSOliver Ruiz Dorantes
91c3053cacSOliver Ruiz Dorantes
92c3053cacSOliver Ruiz Dorantes BMessage*
OverridenProperties(LocalDevice * lDevice,const char * property)93c3053cacSOliver Ruiz Dorantes ResetLocalDeviceAddOn::OverridenProperties(LocalDevice* lDevice, const char* property)
94c3053cacSOliver Ruiz Dorantes {
95c3053cacSOliver Ruiz Dorantes // Example usage:
96c3053cacSOliver Ruiz Dorantes //BMessage* newProperties = new BMessage();
97c3053cacSOliver Ruiz Dorantes //newProperties->AddInt8("max_sco", 10);
98c3053cacSOliver Ruiz Dorantes //return newProperties;
99c3053cacSOliver Ruiz Dorantes
100c3053cacSOliver Ruiz Dorantes return NULL;
101c3053cacSOliver Ruiz Dorantes }
102c3053cacSOliver Ruiz Dorantes
103c3053cacSOliver Ruiz Dorantes INSTANTIATE_LOCAL_DEVICE_ADDON(ResetLocalDeviceAddOn);
104c3053cacSOliver Ruiz Dorantes EXPORT_LOCAL_DEVICE_ADDON;
105