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
13ResetLocalDeviceAddOn::ResetLocalDeviceAddOn()
14{
15
16}
17
18
19const char*
20ResetLocalDeviceAddOn::GetName()
21{
22	return "Reset LocalDevice";
23}
24
25
26status_t
27ResetLocalDeviceAddOn::InitCheck(LocalDevice* lDevice)
28{
29	// you can perform a Reset in all Devices
30	fCheck = B_OK;
31	return fCheck;
32}
33
34
35const char*
36ResetLocalDeviceAddOn::GetActionDescription()
37{
38	return "Perform a Reset command to the LocalDevice";
39}
40
41
42status_t
43ResetLocalDeviceAddOn::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
69const char*
70ResetLocalDeviceAddOn::GetActionOnRemoteDescription()
71{
72	return NULL;
73}
74
75
76status_t
77ResetLocalDeviceAddOn::TakeActionOnRemote(LocalDevice* lDevice, RemoteDevice* rDevice)
78{
79	return B_NOT_SUPPORTED;
80}
81
82
83const char*
84ResetLocalDeviceAddOn::GetOverridenPropertiesDescription()
85{
86	// Example usage:
87	//return "Replace the max count of SCO packets";
88	return NULL;
89}
90
91
92BMessage*
93ResetLocalDeviceAddOn::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
103INSTANTIATE_LOCAL_DEVICE_ADDON(ResetLocalDeviceAddOn);
104EXPORT_LOCAL_DEVICE_ADDON;
105