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