WIP... Updating Bluetooth.
* Some bugfixes. * added scan mode read. * inactivated some printout for now. Was a lot of noice in terminal
This commit is contained in:
parent
9089ab06bd
commit
7a74a5df45
@ -115,11 +115,17 @@ struct hci_command_header {
|
||||
} __attribute__ ((packed));
|
||||
#define OCF_WRITE_PG_TIMEOUT 0x0018
|
||||
|
||||
#define OCF_READ_SCAN_ENABLE 0x0019
|
||||
struct hci_read_scan_enable {
|
||||
uint8 status;
|
||||
uint8 enable;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define OCF_WRITE_SCAN_ENABLE 0x001A
|
||||
#define HCI_SCAN_DISABLED 0x00
|
||||
#define HCI_SCAN_INQUIRY 0x01
|
||||
#define HCI_SCAN_PAGE 0x02
|
||||
#define HCI_SCAN_INQUIRY_PAGE 0x03
|
||||
#define HCI_SCAN_INQUIRY 0x01 //Page Scan disabled
|
||||
#define HCI_SCAN_PAGE 0x02 //Inquiry Scan disabled
|
||||
#define HCI_SCAN_INQUIRY_PAGE 0x03 //All enabled
|
||||
struct hci_write_scan_enable {
|
||||
uint8 scan;
|
||||
} __attribute__ ((packed));
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||
* Copyright 2008 Mika Lindqvist
|
||||
* Copyright 2012 Fredrik Modéen [firstname]@[lastname].se
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _COMMAND_MANAGER_H
|
||||
@ -104,6 +105,7 @@ SingleParameterCommandRequest(uint8 ofg, uint8 ocf, PARAMETERTYPE parameter,
|
||||
/* CONTROL BASEBAND */
|
||||
void* buildReset(size_t* outsize);
|
||||
void* buildReadLocalName(size_t* outsize);
|
||||
void* buildReadScan(size_t* outsize);
|
||||
void* buildWriteScan(uint8 scanmode, size_t* outsize);
|
||||
void* buildReadClassOfDevice(size_t* outsize);
|
||||
|
||||
|
@ -106,6 +106,13 @@ void* buildReadClassOfDevice(size_t* outsize)
|
||||
}
|
||||
|
||||
|
||||
void* buildReadScan(size_t* outsize)
|
||||
{
|
||||
return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_SCAN_ENABLE,
|
||||
NULL, 0, outsize);
|
||||
}
|
||||
|
||||
|
||||
void* buildWriteScan(uint8 scanmode, size_t* outsize)
|
||||
{
|
||||
struct hci_write_scan_enable* param;
|
||||
@ -118,7 +125,6 @@ void* buildWriteScan(uint8 scanmode, size_t* outsize)
|
||||
}
|
||||
|
||||
return command;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||
* Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com
|
||||
* Copyright 2012 Fredrik Modéen, [firstname]@[lastname]
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -147,9 +148,29 @@ LocalDevice::GetProperty(const char* property, uint32* value)
|
||||
|
||||
int
|
||||
LocalDevice::GetDiscoverable()
|
||||
{
|
||||
{
|
||||
if (fMessenger == NULL)
|
||||
return -1;
|
||||
|
||||
size_t size;
|
||||
void* command = buildReadScan(&size);
|
||||
if (command == NULL)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST);
|
||||
request.AddInt32("hci_id", fHid);
|
||||
request.AddData("raw command", B_ANY_TYPE, command, size);
|
||||
request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE);
|
||||
request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND,
|
||||
OCF_READ_SCAN_ENABLE));
|
||||
|
||||
int8 discoverable;
|
||||
BMessage reply;
|
||||
if (fMessenger->SendMessage(&request, &reply) == B_OK
|
||||
&& reply.FindInt8("scan_enable", &discoverable) == B_OK)
|
||||
return discoverable;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -184,7 +205,6 @@ LocalDevice::SetDiscoverable(int mode)
|
||||
return bt_status;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return B_ERROR;
|
||||
|
@ -30,13 +30,7 @@
|
||||
#define B_TRANSLATION_CONTEXT "Settings view"
|
||||
|
||||
static const int32 kMsgSetConnectionPolicy = 'sCpo';
|
||||
|
||||
static const int32 kMsgSetDeviceClassDesktop = 'sDCd';
|
||||
static const int32 kMsgSetDeviceClassServer = 'sDCs';
|
||||
static const int32 kMsgSetDeviceClassLaptop = 'sDCl';
|
||||
static const int32 kMsgSetDeviceClassHandheld = 'sDCh';
|
||||
static const int32 kMsgSetDeviceClassSmartPhone = 'sDCp';
|
||||
|
||||
static const int32 kMsgSetDeviceClass = 'sDC0';
|
||||
static const int32 kMsgSetInquiryTime = 'afEa';
|
||||
static const int32 kMsgLocalSwitched = 'lDsW';
|
||||
|
||||
@ -108,7 +102,6 @@ BluetoothSettingsView::BluetoothSettingsView(const char* name)
|
||||
|
||||
.SetInsets(10, 10, 10, 10)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -136,9 +129,6 @@ BluetoothSettingsView::AttachedToWindow()
|
||||
void
|
||||
BluetoothSettingsView::MessageReceived(BMessage* message)
|
||||
{
|
||||
|
||||
DeviceClass devClass;
|
||||
|
||||
switch (message->what) {
|
||||
case kMsgLocalSwitched:
|
||||
{
|
||||
@ -151,44 +141,29 @@ BluetoothSettingsView::MessageReceived(BMessage* message)
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case kMsgSetDeviceClassDesktop:
|
||||
/*
|
||||
To be fixed :)
|
||||
case kMsgSetConnectionPolicy:
|
||||
{
|
||||
devClass.SetRecord(1, 1, 0x72);
|
||||
if (ActiveLocalDevice != NULL)
|
||||
ActiveLocalDevice->SetDeviceClass(devClass);
|
||||
//uint8 Policy;
|
||||
//if (message->FindInt8("Policy", (int8*)&Policy) == B_OK)
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgSetDeviceClassServer:
|
||||
|
||||
case kMsgSetInquiryTime:
|
||||
{
|
||||
devClass.SetRecord(1, 2, 0x72);
|
||||
if (ActiveLocalDevice != NULL)
|
||||
ActiveLocalDevice->SetDeviceClass(devClass);
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
case kMsgSetDeviceClassLaptop:
|
||||
case kMsgSetDeviceClass:
|
||||
{
|
||||
devClass.SetRecord(1, 3, 0x72);
|
||||
if (ActiveLocalDevice != NULL)
|
||||
ActiveLocalDevice->SetDeviceClass(devClass);
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgSetDeviceClassHandheld:
|
||||
{
|
||||
devClass.SetRecord(1, 4, 0x72);
|
||||
if (ActiveLocalDevice != NULL)
|
||||
ActiveLocalDevice->SetDeviceClass(devClass);
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgSetDeviceClassSmartPhone:
|
||||
{
|
||||
devClass.SetRecord(2, 3, 0x72);
|
||||
if (ActiveLocalDevice != NULL)
|
||||
ActiveLocalDevice->SetDeviceClass(devClass);
|
||||
uint8 deviceClass;
|
||||
if (message->FindInt8("DeviceClass", (int8*)&deviceClass) == B_OK) {
|
||||
if (deviceClass == 5)
|
||||
_SetDeviceClass(2, 3, 0x72);
|
||||
else
|
||||
_SetDeviceClass(1, deviceClass, 0x72);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -202,6 +177,22 @@ BluetoothSettingsView::MessageReceived(BMessage* message)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BluetoothSettingsView::_SetDeviceClass(uint8 major, uint8 minor, uint16 service)
|
||||
{
|
||||
bool haveRun = true;
|
||||
|
||||
DeviceClass devClass;
|
||||
devClass.SetRecord(major, minor, service);
|
||||
if (ActiveLocalDevice != NULL)
|
||||
ActiveLocalDevice->SetDeviceClass(devClass);
|
||||
else
|
||||
haveRun = false;
|
||||
|
||||
return haveRun;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BluetoothSettingsView::_BuildConnectionPolicy()
|
||||
{
|
||||
@ -216,46 +207,50 @@ BluetoothSettingsView::_BuildConnectionPolicy()
|
||||
fPolicyMenu->AddItem(item);
|
||||
|
||||
message = new BMessage(kMsgSetConnectionPolicy);
|
||||
message->AddBool("Policy", 2);
|
||||
message->AddInt8("Policy", 2);
|
||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kTrustedLabel), message);
|
||||
fPolicyMenu->AddItem(item);
|
||||
|
||||
message = new BMessage(kMsgSetConnectionPolicy);
|
||||
message->AddBool("Policy", 3);
|
||||
message->AddInt8("Policy", 3);
|
||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kAlwaysLabel), NULL);
|
||||
fPolicyMenu->AddItem(item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BluetoothSettingsView::_BuildClassMenu()
|
||||
{
|
||||
|
||||
BMessage* message = NULL;
|
||||
BMenuItem* item = NULL;
|
||||
|
||||
fClassMenu = new BPopUpMenu(B_TRANSLATE("Identify us as..."));
|
||||
BMessage* message;
|
||||
|
||||
message = new BMessage(kMsgSetDeviceClassDesktop);
|
||||
BMenuItem* item
|
||||
= new BMenuItem(B_TRANSLATE_NOCOLLECT(kDesktopLabel), message);
|
||||
message = new BMessage(kMsgSetDeviceClass);
|
||||
message->AddInt8("DeviceClass", 1);
|
||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kDesktopLabel), message);
|
||||
fClassMenu->AddItem(item);
|
||||
|
||||
message = new BMessage(kMsgSetDeviceClassServer);
|
||||
message = new BMessage(kMsgSetDeviceClass);
|
||||
message->AddInt8("DeviceClass", 2);
|
||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kServerLabel), message);
|
||||
fClassMenu->AddItem(item);
|
||||
|
||||
message = new BMessage(kMsgSetDeviceClassLaptop);
|
||||
message = new BMessage(kMsgSetDeviceClass);
|
||||
message->AddInt8("DeviceClass", 3);
|
||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kLaptopLabel), message);
|
||||
fClassMenu->AddItem(item);
|
||||
|
||||
message = new BMessage(kMsgSetDeviceClassHandheld);
|
||||
message = new BMessage(kMsgSetDeviceClass);
|
||||
message->AddInt8("DeviceClass", 4);
|
||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kHandheldLabel), message);
|
||||
fClassMenu->AddItem(item);
|
||||
|
||||
message = new BMessage(kMsgSetDeviceClassSmartPhone);
|
||||
message = new BMessage(kMsgSetDeviceClass);
|
||||
message->AddInt8("DeviceClass", 5);
|
||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kPhoneLabel), message);
|
||||
fClassMenu->AddItem(item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,6 +28,8 @@ private:
|
||||
void _BuildConnectionPolicy();
|
||||
void _BuildClassMenu();
|
||||
void _BuildLocalDevicesMenu();
|
||||
bool _SetDeviceClass(uint8 major, uint8 minor
|
||||
, uint16 service);
|
||||
|
||||
protected:
|
||||
float fDivider;
|
||||
|
@ -41,8 +41,7 @@ ExtendedLocalDeviceView::ExtendedLocalDeviceView(BRect frame,
|
||||
fAuthentication = new BCheckBox(iDontCare, "Authenticate",
|
||||
B_TRANSLATE("Authenticate"), new BMessage(SET_AUTHENTICATION));
|
||||
|
||||
fDiscoverable->SetEnabled(false);
|
||||
fVisible->SetEnabled(false);
|
||||
SetEnabled(false);
|
||||
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||
.Add(fDeviceView)
|
||||
@ -56,7 +55,6 @@ ExtendedLocalDeviceView::ExtendedLocalDeviceView(BRect frame,
|
||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(0))
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -69,10 +67,24 @@ ExtendedLocalDeviceView::~ExtendedLocalDeviceView(void)
|
||||
void
|
||||
ExtendedLocalDeviceView::SetLocalDevice(LocalDevice* lDevice)
|
||||
{
|
||||
printf("ExtendedLocalDeviceView::SetLocalDevice\n");
|
||||
if (lDevice != NULL) {
|
||||
fDevice = lDevice;
|
||||
SetName(lDevice->GetFriendlyName().String());
|
||||
fDeviceView->SetBluetoothDevice(lDevice);
|
||||
|
||||
ClearDevice();
|
||||
|
||||
int value = fDevice->GetDiscoverable();
|
||||
printf("ExtendedLocalDeviceView::SetLocalDevice value = %d\n", value);
|
||||
if (value == 1)
|
||||
fDiscoverable->SetValue(true);
|
||||
else if (value == 2)
|
||||
fVisible->SetValue(true);
|
||||
else if (value == 3) {
|
||||
fDiscoverable->SetValue(true);
|
||||
fVisible->SetValue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,6 +92,7 @@ ExtendedLocalDeviceView::SetLocalDevice(LocalDevice* lDevice)
|
||||
void
|
||||
ExtendedLocalDeviceView::AttachedToWindow()
|
||||
{
|
||||
printf("ExtendedLocalDeviceView::AttachedToWindow\n");
|
||||
fDiscoverable->SetTarget(this);
|
||||
fVisible->SetTarget(this);
|
||||
fAuthentication->SetTarget(this);
|
||||
@ -89,13 +102,20 @@ ExtendedLocalDeviceView::AttachedToWindow()
|
||||
void
|
||||
ExtendedLocalDeviceView::SetTarget(BHandler* target)
|
||||
{
|
||||
|
||||
printf("ExtendedLocalDeviceView::SetTarget\n");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ExtendedLocalDeviceView::MessageReceived(BMessage* message)
|
||||
{
|
||||
printf("ExtendedLocalDeviceView::MessageReceived\n");
|
||||
|
||||
if (fDevice == NULL) {
|
||||
printf("ExtendedLocalDeviceView::Device missing\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (message->WasDropped()) {
|
||||
|
||||
}
|
||||
@ -116,12 +136,14 @@ ExtendedLocalDeviceView::MessageReceived(BMessage* message)
|
||||
|
||||
if (fVisible->Value())
|
||||
fScanMode |= 2;
|
||||
|
||||
if (fDevice != NULL)
|
||||
fDevice->SetDiscoverable(fScanMode);
|
||||
|
||||
break;
|
||||
case SET_AUTHENTICATION:
|
||||
fDevice->SetAuthentication(fAuthentication->Value());
|
||||
if (fDevice != NULL)
|
||||
fDevice->SetAuthentication(fAuthentication->Value());
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -134,5 +156,20 @@ ExtendedLocalDeviceView::MessageReceived(BMessage* message)
|
||||
void
|
||||
ExtendedLocalDeviceView::SetEnabled(bool value)
|
||||
{
|
||||
printf("ExtendedLocalDeviceView::SetEnabled\n");
|
||||
|
||||
fVisible->SetEnabled(value);
|
||||
fAuthentication->SetEnabled(value);
|
||||
fDiscoverable->SetEnabled(value);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ExtendedLocalDeviceView::ClearDevice()
|
||||
{
|
||||
printf("ExtendedLocalDeviceView::ClearDevice\n");
|
||||
|
||||
fVisible->SetValue(false);
|
||||
fAuthentication->SetValue(false);
|
||||
fDiscoverable->SetValue(false);
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
virtual void AttachedToWindow();
|
||||
virtual void SetTarget(BHandler* target);
|
||||
virtual void SetEnabled(bool value);
|
||||
void ClearDevice();
|
||||
|
||||
protected:
|
||||
LocalDevice* fDevice;
|
||||
|
@ -246,8 +246,8 @@ void BluetoothServer::MessageReceived(BMessage* message)
|
||||
if (status != B_WOULD_BLOCK) {
|
||||
reply.AddInt32("status", status);
|
||||
message->SendReply(&reply);
|
||||
printf("Sending reply message for->\n");
|
||||
message->PrintToStream();
|
||||
// printf("Sending reply message for->\n");
|
||||
// message->PrintToStream();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,13 @@ HCITransportAccessor::IssueCommand(raw_command rc, size_t size)
|
||||
{
|
||||
if (Id() < 0 || fDescriptor < 0)
|
||||
return B_ERROR;
|
||||
|
||||
/*
|
||||
printf("### Command going: len = %ld\n", size);
|
||||
for (uint16 index = 0 ; index < size; index++ ) {
|
||||
printf("%x:",((uint8*)rc)[index]);
|
||||
}
|
||||
printf("### \n");
|
||||
|
||||
*/
|
||||
|
||||
return ioctl(fDescriptor, ISSUE_BT_COMMAND, rc, size);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ LocalDeviceHandler::AddWantedEvent(BMessage* msg)
|
||||
{
|
||||
fEventsWanted.Lock();
|
||||
// TODO: review why it is needed to replicate the msg
|
||||
printf("Adding request... %p\n", msg);
|
||||
// printf("Adding request... %p\n", msg);
|
||||
fEventsWanted.AddMessage(msg);
|
||||
fEventsWanted.Unlock();
|
||||
}
|
||||
@ -134,6 +134,7 @@ finish:
|
||||
BMessage*
|
||||
LocalDeviceHandler::FindPetition(uint16 event, uint16 opcode, int32* indexFound)
|
||||
{
|
||||
//debug data
|
||||
int16 eventFound;
|
||||
int16 opcodeFound;
|
||||
int32 eventIndex;
|
||||
@ -142,29 +143,29 @@ LocalDeviceHandler::FindPetition(uint16 event, uint16 opcode, int32* indexFound)
|
||||
// for each Petition
|
||||
for (int32 index = 0 ; index < fEventsWanted.CountMessages() ; index++) {
|
||||
BMessage* msg = fEventsWanted.FindMessage(index);
|
||||
printf("%s:Petition %ld ... of %ld msg #%p\n", __FUNCTION__, index,
|
||||
fEventsWanted.CountMessages(), msg);
|
||||
msg->PrintToStream();
|
||||
// printf("%s:Petition %ld ... of %ld msg #%p\n", __FUNCTION__, index,
|
||||
// fEventsWanted.CountMessages(), msg);
|
||||
// msg->PrintToStream();
|
||||
eventIndex = 0;
|
||||
|
||||
// for each Event
|
||||
while (msg->FindInt16("eventExpected", eventIndex, &eventFound) == B_OK ) {
|
||||
if (eventFound == event) {
|
||||
|
||||
printf("%s:Event %d found@%ld...", __FUNCTION__, event, eventIndex);
|
||||
// printf("%s:Event %d found@%ld...", __FUNCTION__, event, eventIndex);
|
||||
// there is an opcode specified..
|
||||
if (msg->FindInt16("opcodeExpected", eventIndex, &opcodeFound)
|
||||
== B_OK) {
|
||||
// ensure the opcode
|
||||
if ((uint16)opcodeFound != opcode) {
|
||||
printf("%s:opcode does not match %d\n",
|
||||
__FUNCTION__, opcode);
|
||||
// printf("%s:opcode does not match %d\n",
|
||||
// __FUNCTION__, opcode);
|
||||
eventIndex++;
|
||||
continue;
|
||||
}
|
||||
printf("Opcode matches %d\n", opcode);
|
||||
// printf("Opcode matches %d\n", opcode);
|
||||
} else {
|
||||
printf("No opcode specified\n");
|
||||
// printf("No opcode specified\n");
|
||||
}
|
||||
|
||||
fEventsWanted.Unlock();
|
||||
@ -175,7 +176,7 @@ LocalDeviceHandler::FindPetition(uint16 event, uint16 opcode, int32* indexFound)
|
||||
eventIndex++;
|
||||
}
|
||||
}
|
||||
printf("%s:Event %d not found\n", __FUNCTION__, event);
|
||||
// printf("%s:Event %d not found\n", __FUNCTION__, event);
|
||||
|
||||
fEventsWanted.Unlock();
|
||||
return NULL;
|
||||
|
@ -266,13 +266,14 @@ LocalDeviceImpl::HandleExpectedRequest(struct hci_event_header* event,
|
||||
void
|
||||
LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
|
||||
{
|
||||
/*
|
||||
|
||||
printf("### Incoming event: len = %d\n", event->elen);
|
||||
for (int16 index = 0; index < event->elen + 2; index++) {
|
||||
printf("%x:", ((uint8*)event)[index]);
|
||||
}
|
||||
printf("### \n");
|
||||
|
||||
*/
|
||||
BMessage* request = NULL;
|
||||
int32 eventIndexLocation;
|
||||
|
||||
@ -344,6 +345,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
|
||||
int16 opcodeExpected;
|
||||
BMessage reply;
|
||||
status_t status;
|
||||
|
||||
// Handle command complete information
|
||||
request->FindInt16("opcodeExpected", index, &opcodeExpected);
|
||||
@ -383,8 +385,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
"Reply for Local Version %x\n", version->status);
|
||||
|
||||
reply.AddInt8("status", version->status);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
@ -407,8 +410,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
|
||||
reply.AddInt8("status", pageTimeout->status);
|
||||
reply.AddInt32("result", pageTimeout->page_timeout);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
@ -457,8 +461,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
"Reply for Local Features %x\n", features->status);
|
||||
|
||||
reply.AddInt8("status", features->status);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
@ -492,8 +497,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
|
||||
|
||||
reply.AddInt8("status", buffer->status);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
@ -515,8 +521,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
"Read bdaddr status = %x\n", readbdaddr->status);
|
||||
|
||||
reply.AddInt8("status", readbdaddr->status);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
@ -542,8 +549,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
|
||||
|
||||
reply.AddInt8("status", classDev->status);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
@ -565,8 +573,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
readLocalName->status);
|
||||
|
||||
reply.AddInt8("status", readLocalName->status);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
@ -582,8 +591,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
*statusReply);
|
||||
|
||||
reply.AddInt8("status", *statusReply);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request/*, HCI_EVENT_CMD_COMPLETE, opcodeExpected*/);
|
||||
@ -600,8 +610,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
*statusReply);
|
||||
|
||||
reply.AddInt8("status", *statusReply);
|
||||
printf("Sending reply ... %ld\n",request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request, HCI_EVENT_CMD_COMPLETE, opcodeExpected);
|
||||
@ -620,8 +631,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
linkKeyRetrieval->max_num_keys, linkKeyRetrieval->num_keys_read);
|
||||
|
||||
reply.AddInt8("status", linkKeyRetrieval->status);
|
||||
printf("Sending reply ... %ld\n",request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
ClearWantedEvent(request);
|
||||
break;
|
||||
@ -642,6 +654,30 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
break;
|
||||
}
|
||||
|
||||
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_SCAN_ENABLE):
|
||||
{
|
||||
struct hci_read_scan_enable* scanEnable
|
||||
= JumpEventHeader<struct hci_read_scan_enable,
|
||||
struct hci_ev_cmd_complete>(event);
|
||||
|
||||
if (scanEnable->status == BT_OK) {
|
||||
fProperties->AddInt8("scan_enable", scanEnable->enable);
|
||||
|
||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()), "enable = %x\n",
|
||||
scanEnable->enable);
|
||||
}
|
||||
|
||||
reply.AddInt8("status", scanEnable->status);
|
||||
reply.AddInt8("scan_enable", scanEnable->enable);
|
||||
status = request->SendReply(&reply);
|
||||
printf("Sending reply. scan_enable = %d\n", scanEnable->enable);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
break;
|
||||
}
|
||||
|
||||
// place here all CC that just replies a uint8 status
|
||||
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_RESET):
|
||||
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE):
|
||||
@ -657,7 +693,8 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s for %s status %x\n",
|
||||
__FUNCTION__, BluetoothCommandOpcode(opcodeExpected), *(uint8*)(event + 1));
|
||||
|
||||
request->SendReply(&reply);
|
||||
status = request->SendReply(&reply);
|
||||
printf("Sending reply write ... %ld\n", status);
|
||||
|
||||
ClearWantedEvent(request);
|
||||
break;
|
||||
@ -678,6 +715,7 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event,
|
||||
|
||||
int16 opcodeExpected;
|
||||
BMessage reply;
|
||||
status_t status;
|
||||
|
||||
// Handle command complete information
|
||||
request->FindInt16("opcodeExpected", index, &opcodeExpected);
|
||||
@ -695,8 +733,9 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event,
|
||||
"Inquiry status %x\n", event->status);
|
||||
|
||||
reply.AddInt8("status", event->status);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS,
|
||||
PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY));
|
||||
@ -713,8 +752,9 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event,
|
||||
"Command Status for remote friendly name %x\n", event->status);
|
||||
|
||||
reply.AddInt8("status", event->status);
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status = request->SendReply(&reply);
|
||||
//printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS, opcodeExpected);
|
||||
}
|
||||
@ -770,7 +810,8 @@ LocalDeviceImpl::InquiryResult(uint8* numberOfResponses, BMessage* request)
|
||||
info++;
|
||||
}
|
||||
|
||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, request->SendReply(&reply));
|
||||
status_t status = request->SendReply(&reply);
|
||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, status);
|
||||
}
|
||||
|
||||
|
||||
@ -780,7 +821,8 @@ LocalDeviceImpl::InquiryComplete(uint8* status, BMessage* request)
|
||||
BMessage reply(BT_MSG_INQUIRY_COMPLETED);
|
||||
|
||||
reply.AddInt8("status", *status);
|
||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, request->SendReply(&reply));
|
||||
status_t stat = request->SendReply(&reply);
|
||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, stat);
|
||||
|
||||
ClearWantedEvent(request);
|
||||
}
|
||||
@ -805,8 +847,9 @@ LocalDeviceImpl::RemoteNameRequestComplete(
|
||||
bdaddrUtils::ToString(remotename->bdaddr),
|
||||
BluetoothError(remotename->status));
|
||||
|
||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||
reply.PrintToStream();
|
||||
status_t status = request->SendReply(&reply);
|
||||
printf("Sending reply ... %ld\n", status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
@ -877,7 +920,8 @@ LocalDeviceImpl::ConnectionComplete(struct hci_ev_conn_complete* event,
|
||||
|
||||
} else {
|
||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
|
||||
"%s: failed with error %s\n", __FUNCTION__, BluetoothError(event->status));
|
||||
"%s: failed with error %s\n", __FUNCTION__,
|
||||
BluetoothError(event->status));
|
||||
}
|
||||
|
||||
// it was expected
|
||||
@ -888,8 +932,9 @@ LocalDeviceImpl::ConnectionComplete(struct hci_ev_conn_complete* event,
|
||||
if (event->status == BT_OK)
|
||||
reply.AddInt16("handle", event->handle);
|
||||
|
||||
request->SendReply(&reply);
|
||||
reply.PrintToStream();
|
||||
status_t status = request->SendReply(&reply);
|
||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
ClearWantedEvent(request);
|
||||
@ -910,8 +955,9 @@ LocalDeviceImpl::DisconnectionComplete(
|
||||
BMessage reply;
|
||||
reply.AddInt8("status", event->status);
|
||||
|
||||
request->SendReply(&reply);
|
||||
reply.PrintToStream();
|
||||
status_t status = request->SendReply(&reply);
|
||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, status);
|
||||
// debug reply.PrintToStream();
|
||||
|
||||
ClearWantedEvent(request);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user