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