- Fix creating BPath with empty string

- Add handling of local features to know about the role and encryption capabilities



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36024 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2010-04-02 11:15:10 +00:00
parent 2168c373a2
commit ecd60ae87e
3 changed files with 117 additions and 69 deletions
+9 -6
View File
@@ -162,15 +162,16 @@ void BluetoothServer::MessageReceived(BMessage* message)
case BT_MSG_ADD_DEVICE: case BT_MSG_ADD_DEVICE:
{ {
BString str; BString str;
BPath path(str.String());
message->FindString("name", &str); message->FindString("name", &str);
Output::Instance()->Postf(BLACKBOARD_GENERAL, Output::Instance()->Postf(BLACKBOARD_GENERAL,
"Requested LocalDevice %s\n", str.String()); "Requested LocalDevice %s\n", str.String());
LocalDeviceImpl* lDeviceImpl = BPath path(str.String());
LocalDeviceImpl::CreateTransportAccessor(&path);
LocalDeviceImpl* lDeviceImpl
= LocalDeviceImpl::CreateTransportAccessor(&path);
if (lDeviceImpl->GetID() >= 0) { if (lDeviceImpl->GetID() >= 0) {
fLocalDevicesList.AddItem(lDeviceImpl); fLocalDevicesList.AddItem(lDeviceImpl);
@@ -300,6 +301,8 @@ BluetoothServer::LocateLocalDeviceImpl(hci_id hid)
status_t status_t
BluetoothServer::HandleLocalDevicesCount(BMessage* message, BMessage* reply) BluetoothServer::HandleLocalDevicesCount(BMessage* message, BMessage* reply)
{ {
Output::Instance()->Post("Count Requested\n", BLACKBOARD_KIT);
return reply->AddInt32("count", fLocalDevicesList.CountItems()); return reply->AddInt32("count", fLocalDevicesList.CountItems());
} }
@@ -415,9 +418,9 @@ BluetoothServer::HandleSimpleRequest(BMessage* message, BMessage* reply)
status_t status_t
BluetoothServer::HandleGetProperty(BMessage* message, BMessage* reply) BluetoothServer::HandleGetProperty(BMessage* message, BMessage* reply)
{ {
/* User side will look for the reply in a result field and will // User side will look for the reply in a result field and will
* not care about status fields, therefore we return OK in all cases // not care about status fields, therefore we return OK in all cases
*/
LocalDeviceImpl* lDeviceImpl = LocateDelegateFromMessage(message); LocalDeviceImpl* lDeviceImpl = LocateDelegateFromMessage(message);
if (lDeviceImpl == NULL) { if (lDeviceImpl == NULL) {
return B_ERROR; return B_ERROR;
@@ -23,8 +23,8 @@ HCITransportAccessor::HCITransportAccessor(BPath* path) : HCIDelegate(path)
printf("%s: hid retrieved %lx status=%ld\n", __FUNCTION__, printf("%s: hid retrieved %lx status=%ld\n", __FUNCTION__,
fIdentifier, status); fIdentifier, status);
} else { } else {
printf("%s: Device driver could not be opened %ld\n", __FUNCTION__, printf("%s: Device driver %s could not be opened %ld\n", __FUNCTION__,
fIdentifier); path->Path(), fIdentifier);
fIdentifier = B_ERROR; fIdentifier = B_ERROR;
} }
@@ -59,10 +59,10 @@ printf("### \n");
} }
status_t status_t
HCITransportAccessor::Launch() { HCITransportAccessor::Launch() {
uint32 dummy; uint32 dummy;
return ioctl(fDescriptor, BT_UP, &dummy, sizeof(uint32)); return ioctl(fDescriptor, BT_UP, &dummy, sizeof(uint32));
} }
+104 -59
View File
@@ -76,15 +76,17 @@ LocalDeviceImpl::~LocalDeviceImpl()
} }
void void
LocalDeviceImpl::Unregister() LocalDeviceImpl::Unregister()
{ {
BMessage* msg = new BMessage(BT_MSG_REMOVE_DEVICE); BMessage* msg = new BMessage(BT_MSG_REMOVE_DEVICE);
msg->AddInt32("hci_id", fHCIDelegate->Id()); msg->AddInt32("hci_id", fHCIDelegate->Id());
Output::Instance()->Postf(BLACKBOARD_DEVICEMANAGER, "Unregistering %x\n", fHCIDelegate->Id()); Output::Instance()->Postf(BLACKBOARD_DEVICEMANAGER, "Unregistering %x\n",
fHCIDelegate->Id());
be_app_messenger.SendMessage(msg); be_app_messenger.SendMessage(msg);
} }
@@ -98,32 +100,32 @@ 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");
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"Incomming %s event\n", Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"Incomming %s event\n",
BluetoothEvent(event->ecode)); BluetoothEvent(event->ecode));
// Events here might have not been initated by us // Events here might have not been initated by us
// TODO: ML mark as handled pass a reply by parameter and reply in common // TODO: ML mark as handled pass a reply by parameter and reply in common
switch (event->ecode) { switch (event->ecode) {
case HCI_EVENT_HARDWARE_ERROR: case HCI_EVENT_HARDWARE_ERROR:
HardwareError((struct hci_ev_hardware_error*)(event+1)); HardwareError((struct hci_ev_hardware_error*)(event + 1));
return; return;
case HCI_EVENT_CONN_REQUEST: case HCI_EVENT_CONN_REQUEST:
ConnectionRequest((struct hci_ev_conn_request*)(event+1), NULL); ConnectionRequest((struct hci_ev_conn_request*)(event + 1), NULL);
return; return;
case HCI_EVENT_CONN_COMPLETE: case HCI_EVENT_CONN_COMPLETE:
// should belong to a request? can be sporadic or initiated by us¿?... // should belong to a request? can be sporadic or initiated by us¿?...
ConnectionComplete((struct hci_ev_conn_complete*)(event+1), NULL); ConnectionComplete((struct hci_ev_conn_complete*)(event + 1), NULL);
return; return;
case HCI_EVENT_PIN_CODE_REQ: case HCI_EVENT_PIN_CODE_REQ:
PinCodeRequest((struct hci_ev_pin_code_req*)(event+1), NULL); PinCodeRequest((struct hci_ev_pin_code_req*)(event + 1), NULL);
return; return;
default: default:
@@ -137,12 +139,12 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
// Check if it is a requested one // Check if it is a requested one
if (event->ecode == HCI_EVENT_CMD_COMPLETE) { if (event->ecode == HCI_EVENT_CMD_COMPLETE) {
request = FindPetition(event->ecode, ((struct hci_ev_cmd_complete*) request = FindPetition(event->ecode, ((struct hci_ev_cmd_complete*)
(event+1))->opcode, &eventIndexLocation); (event + 1))->opcode, &eventIndexLocation);
} else if (event->ecode == HCI_EVENT_CMD_STATUS) { } else if (event->ecode == HCI_EVENT_CMD_STATUS) {
request = FindPetition(event->ecode, ((struct hci_ev_cmd_status*) request = FindPetition(event->ecode, ((struct hci_ev_cmd_status*)
(event+1))->opcode, &eventIndexLocation); (event + 1))->opcode, &eventIndexLocation);
} else { } else {
request = FindPetition(event->ecode); request = FindPetition(event->ecode);
@@ -157,17 +159,17 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
// we are waiting for a reply // we are waiting for a reply
switch (event->ecode) { switch (event->ecode) {
case HCI_EVENT_INQUIRY_COMPLETE: case HCI_EVENT_INQUIRY_COMPLETE:
InquiryComplete((uint8*)(event+1), request); InquiryComplete((uint8*)(event + 1), request);
break; break;
case HCI_EVENT_INQUIRY_RESULT: case HCI_EVENT_INQUIRY_RESULT:
InquiryResult((uint8*)(event+1), request); InquiryResult((uint8*)(event + 1), request);
break; break;
case HCI_EVENT_DISCONNECTION_COMPLETE: case HCI_EVENT_DISCONNECTION_COMPLETE:
// should belong to a request? can be sporadic or initiated by us¿?... // should belong to a request? can be sporadic or initiated by us¿?...
DisconnectionComplete((struct hci_ev_disconnection_complete_reply*) DisconnectionComplete((struct hci_ev_disconnection_complete_reply*)
(event+1), request); (event + 1), request);
break; break;
case HCI_EVENT_AUTH_COMPLETE: case HCI_EVENT_AUTH_COMPLETE:
@@ -175,7 +177,7 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE: case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE:
RemoteNameRequestComplete((struct hci_ev_remote_name_request_complete_reply*) RemoteNameRequestComplete((struct hci_ev_remote_name_request_complete_reply*)
(event+1), request); (event + 1), request);
break; break;
case HCI_EVENT_ENCRYPT_CHANGE: case HCI_EVENT_ENCRYPT_CHANGE:
@@ -197,12 +199,12 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
break; break;
case HCI_EVENT_CMD_COMPLETE: case HCI_EVENT_CMD_COMPLETE:
CommandComplete((struct hci_ev_cmd_complete*)(event+1), CommandComplete((struct hci_ev_cmd_complete*)(event + 1),
request, eventIndexLocation); request, eventIndexLocation);
break; break;
case HCI_EVENT_CMD_STATUS: case HCI_EVENT_CMD_STATUS:
CommandStatus((struct hci_ev_cmd_status*)(event+1), request, CommandStatus((struct hci_ev_cmd_status*)(event + 1), request,
eventIndexLocation); eventIndexLocation);
break; break;
@@ -210,7 +212,7 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
break; break;
case HCI_EVENT_ROLE_CHANGE: case HCI_EVENT_ROLE_CHANGE:
RoleChange((struct hci_ev_role_change*)(event+1), request, RoleChange((struct hci_ev_role_change*)(event + 1), request,
eventIndexLocation); eventIndexLocation);
break; break;
@@ -227,7 +229,7 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
break; break;
case HCI_EVENT_LINK_KEY_NOTIFY: case HCI_EVENT_LINK_KEY_NOTIFY:
LinkKeyNotify((struct hci_ev_link_key_notify*)(event+1), LinkKeyNotify((struct hci_ev_link_key_notify*)(event + 1),
request, eventIndexLocation); request, eventIndexLocation);
break; break;
@@ -238,7 +240,7 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
break; break;
case HCI_EVENT_MAX_SLOT_CHANGE: case HCI_EVENT_MAX_SLOT_CHANGE:
MaxSlotChange((struct hci_ev_max_slot_change*)(event+1), request, MaxSlotChange((struct hci_ev_max_slot_change*)(event + 1), request,
eventIndexLocation); eventIndexLocation);
break; break;
@@ -278,10 +280,11 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
void void
LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request, LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
int32 index) { BMessage* request,
int32 index) {
int16 opcodeExpected; int16 opcodeExpected;
BMessage reply; BMessage reply;
// Handle command complete information // Handle command complete information
@@ -297,7 +300,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_VERSION): case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_VERSION):
{ {
struct hci_rp_read_loc_version* version = (struct hci_rp_read_loc_version*)(event+1); struct hci_rp_read_loc_version* version = (struct hci_rp_read_loc_version*)(event + 1);
if (version->status == BT_OK) { if (version->status == BT_OK) {
@@ -327,12 +330,60 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
// This request is not gonna be used anymore // This request is not gonna be used anymore
ClearWantedEvent(request); ClearWantedEvent(request);
break;
}
case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_FEATURES):
{
struct hci_rp_read_loc_features* features
= (struct hci_rp_read_loc_features*)(event + 1);
if (features->status == BT_OK) {
if (!IsPropertyAvailable("features")) {
fProperties->AddData("features", B_ANY_TYPE, &features->features, 8);
uint16 packetType = HCI_DM1 | HCI_DH1 | HCI_HV1;
bool roleSwitch = (features->features[0] & LMP_RSWITCH) != 0;
bool encryptCapable = (features->features[0] & LMP_ENCRYPT) != 0;
if (features->features[0] & LMP_3SLOT)
packetType |= (HCI_DM3 | HCI_DH3);
if (features->features[0] & LMP_5SLOT)
packetType |= (HCI_DM5 | HCI_DH5);
if (features->features[1] & LMP_HV2)
packetType |= (HCI_HV2);
if (features->features[1] & LMP_HV3)
packetType |= (HCI_HV3);
fProperties->AddInt16("packet_type", packetType);
fProperties->AddBool("role_switch_capable", roleSwitch);
fProperties->AddBool("encrypt_capable", encryptCapable);
Output::Instance()->Postf(BLACKBOARD_KIT,
"Packet type %x role switch %d encrypt %d\n",
packetType, roleSwitch, encryptCapable);
}
}
Output::Instance()->Postf(BLACKBOARD_KIT, "Reply for Local Features %x\n", features->status);
reply.AddInt8("status", features->status);
printf("Sending reply ... %ld\n", request->SendReply(&reply));
reply.PrintToStream();
// This request is not gonna be used anymore
ClearWantedEvent(request);
break;
} }
break;
case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE): case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE):
{ {
struct hci_rp_read_buffer_size* buffer = (struct hci_rp_read_buffer_size*)(event+1); struct hci_rp_read_buffer_size* buffer = (struct hci_rp_read_buffer_size*)(event + 1);
if (buffer->status == BT_OK) { if (buffer->status == BT_OK) {
@@ -365,7 +416,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR): case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR):
{ {
struct hci_rp_read_bd_addr* readbdaddr = (struct hci_rp_read_bd_addr*)(event+1); struct hci_rp_read_bd_addr* readbdaddr = (struct hci_rp_read_bd_addr*)(event + 1);
if (readbdaddr->status == BT_OK) { if (readbdaddr->status == BT_OK) {
reply.AddData("bdaddr", B_ANY_TYPE, &readbdaddr->bdaddr, sizeof(bdaddr_t)); reply.AddData("bdaddr", B_ANY_TYPE, &readbdaddr->bdaddr, sizeof(bdaddr_t));
@@ -386,13 +437,13 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_CLASS_OF_DEV): case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_CLASS_OF_DEV):
{ {
struct hci_read_dev_class_reply* classDev = (struct hci_read_dev_class_reply*)(event+1); struct hci_read_dev_class_reply* classDev = (struct hci_read_dev_class_reply*)(event + 1);
if (classDev->status == BT_OK) { if (classDev->status == BT_OK) {
reply.AddData("devclass", B_ANY_TYPE, &classDev->dev_class, sizeof(classDev->dev_class)); reply.AddData("devclass", B_ANY_TYPE, &classDev->dev_class, sizeof(classDev->dev_class));
} }
Output::Instance()->Postf(BLACKBOARD_KIT, Output::Instance()->Postf(BLACKBOARD_KIT,
"Read DeviceClass status = %x DeviceClass = [%x][%x][%x]\n", classDev->status, "Read DeviceClass status = %x DeviceClass = [%x][%x][%x]\n", classDev->status,
classDev->dev_class[0], classDev->dev_class[1], classDev->dev_class[2]); classDev->dev_class[0], classDev->dev_class[1], classDev->dev_class[2]);
@@ -408,7 +459,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME): case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME):
{ {
struct hci_rp_read_local_name* readLocalName = (struct hci_rp_read_local_name*)(event+1); struct hci_rp_read_local_name* readLocalName = (struct hci_rp_read_local_name*)(event + 1);
if (readLocalName->status == BT_OK) { if (readLocalName->status == BT_OK) {
reply.AddString("friendlyname", (const char*)readLocalName->local_name ); reply.AddString("friendlyname", (const char*)readLocalName->local_name );
@@ -429,9 +480,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_PIN_CODE_REPLY): case PACK_OPCODE(OGF_LINK_CONTROL, OCF_PIN_CODE_REPLY):
{ {
uint8* statusReply = (uint8*)(event+1); uint8* statusReply = (uint8*)(event + 1);
//TODO: This reply has to match the BDADDR of the outgoing message // TODO: This reply has to match the BDADDR of the outgoing message
if (*statusReply == BT_OK) { if (*statusReply == BT_OK) {
Output::Instance()->Post("Positive reply for pincode accept\n", BLACKBOARD_KIT); Output::Instance()->Post("Positive reply for pincode accept\n", BLACKBOARD_KIT);
} else { } else {
@@ -450,10 +501,10 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_PIN_CODE_NEG_REPLY): case PACK_OPCODE(OGF_LINK_CONTROL, OCF_PIN_CODE_NEG_REPLY):
{ {
uint8* statusReply = (uint8*)(event+1); uint8* statusReply = (uint8*)(event + 1);
//TODO: This reply might to match the BDADDR of the outgoing message
// xxx:FindPetition should be expanded....
// TODO: This reply might to match the BDADDR of the outgoing message
// => FindPetition should be expanded....
if (*statusReply == BT_OK) { if (*statusReply == BT_OK) {
Output::Instance()->Post("Positive reply for pincode reject\n", BLACKBOARD_KIT); Output::Instance()->Post("Positive reply for pincode reject\n", BLACKBOARD_KIT);
} else { } else {
@@ -475,7 +526,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_CLASS_OF_DEV): case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_CLASS_OF_DEV):
case PACK_OPCODE(OGF_VENDOR_CMD, OCF_WRITE_BCM2035_BDADDR): case PACK_OPCODE(OGF_VENDOR_CMD, OCF_WRITE_BCM2035_BDADDR):
{ {
reply.AddInt8("status", *(uint8*)(event+1)); reply.AddInt8("status", *(uint8*)(event + 1));
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));
@@ -496,9 +547,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
void void
LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* request, LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* request,
int32 index) { int32 index) {
int16 opcodeExpected; int16 opcodeExpected;
BMessage reply; BMessage reply;
// Handle command complete information // Handle command complete information
@@ -533,11 +584,10 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST): case PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST):
{ {
if (event->status==BT_OK) { if (event->status == BT_OK) {
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS, ClearWantedEvent(request, HCI_EVENT_CMD_STATUS,
PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST)); PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST));
} } else {
else {
Output::Instance()->Post("Wrong Command Status for remote friendly name\n", BLACKBOARD_KIT); Output::Instance()->Post("Wrong Command Status for remote friendly name\n", BLACKBOARD_KIT);
reply.AddInt8("status", event->status); reply.AddInt8("status", event->status);
@@ -578,8 +628,8 @@ LocalDeviceImpl::InquiryResult(uint8* numberOfResponses, BMessage* request)
BMessage reply(BT_MSG_INQUIRY_DEVICE); BMessage reply(BT_MSG_INQUIRY_DEVICE);
// skipping here the number of responses // skipping here the number of responses
reply.AddData("info", B_ANY_TYPE, numberOfResponses + 1 reply.AddData("info", B_ANY_TYPE, numberOfResponses + 1,
, (*numberOfResponses) * sizeof(struct inquiry_info) ); (*numberOfResponses) * sizeof(struct inquiry_info) );
reply.AddInt8("count", *numberOfResponses); reply.AddInt8("count", *numberOfResponses);
@@ -613,7 +663,7 @@ LocalDeviceImpl::RemoteNameRequestComplete(
reply.AddInt8("status", remotename->status); reply.AddInt8("status", remotename->status);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s for %s with status %s\n", Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s for %s with status %s\n",
BluetoothEvent(HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE), BluetoothEvent(HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE),
bdaddrUtils::ToString(remotename->bdaddr), BluetoothError(remotename->status)); bdaddrUtils::ToString(remotename->bdaddr), BluetoothError(remotename->status));
printf("Sending reply ... %ld\n", request->SendReply(&reply)); printf("Sending reply ... %ld\n", request->SendReply(&reply));
@@ -634,7 +684,7 @@ LocalDeviceImpl::ConnectionRequest(struct hci_ev_conn_request* event, BMessage*
"Connection Incoming type %x from %s...\n", "Connection Incoming type %x from %s...\n",
event->link_type, bdaddrUtils::ToString(event->bdaddr)); event->link_type, bdaddrUtils::ToString(event->bdaddr));
/* TODO: add a possible request in the queue */ // TODO: add a possible request in the queue
if (true) { // Check Preferences if we are to accept this connection if (true) { // Check Preferences if we are to accept this connection
command = buildAcceptConnectionRequest(event->bdaddr, 0x01 /*slave*/, &size); command = buildAcceptConnectionRequest(event->bdaddr, 0x01 /*slave*/, &size);
@@ -669,13 +719,12 @@ LocalDeviceImpl::ConnectionComplete(struct hci_ev_conn_complete* event, BMessage
{ {
if (event->status == BT_OK) { if (event->status == BT_OK) {
uint8 cod[3] = {0,0,0}; uint8 cod[3] = {0, 0, 0};
ConnectionIncoming* iConnection = new ConnectionIncoming( ConnectionIncoming* iConnection = new ConnectionIncoming(
new RemoteDevice(event->bdaddr, cod)); new RemoteDevice(event->bdaddr, cod));
iConnection->Show(); iConnection->Show();
Output::Instance()->Postf(BLACKBOARD_LD(GetID()), Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"%s: Address %s handle=%#x type=%d encrypt=%d\n", __FUNCTION__, "%s: Address %s handle=%#x type=%d encrypt=%d\n", __FUNCTION__,
bdaddrUtils::ToString(event->bdaddr), event->handle, bdaddrUtils::ToString(event->bdaddr), event->handle,
@@ -686,8 +735,6 @@ LocalDeviceImpl::ConnectionComplete(struct hci_ev_conn_complete* event, BMessage
"%s: failed with status %#x\n", __FUNCTION__, event->status); "%s: failed with status %#x\n", __FUNCTION__, event->status);
} }
} }
@@ -716,7 +763,7 @@ void
LocalDeviceImpl::RoleChange(hci_ev_role_change* event, BMessage* request, int32 index) LocalDeviceImpl::RoleChange(hci_ev_role_change* event, BMessage* request, int32 index)
{ {
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Address %s role=%d status=%d\n", Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Address %s role=%d status=%d\n",
__FUNCTION__, bdaddrUtils::ToString(event->bdaddr), event->role, event->status); __FUNCTION__, bdaddrUtils::ToString(event->bdaddr), event->role, event->status);
} }
@@ -730,7 +777,7 @@ LocalDeviceImpl::PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_c
void void
LocalDeviceImpl::LinkKeyNotify(hci_ev_link_key_notify *event, LocalDeviceImpl::LinkKeyNotify(hci_ev_link_key_notify* event,
BMessage* request, int32 index) BMessage* request, int32 index)
{ {
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Address %s, key=%s, type=%d\n", Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Address %s, key=%s, type=%d\n",
@@ -740,21 +787,19 @@ LocalDeviceImpl::LinkKeyNotify(hci_ev_link_key_notify *event,
void void
LocalDeviceImpl::MaxSlotChange(struct hci_ev_max_slot_change *event, LocalDeviceImpl::MaxSlotChange(struct hci_ev_max_slot_change* event,
BMessage *request, int32 index) BMessage* request, int32 index)
{ {
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Handle=%#x, max slots=%d\n", Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Handle=%#x, max slots=%d\n",
__FUNCTION__, event->handle, event->lmp_max_slots); __FUNCTION__, event->handle, event->lmp_max_slots);
} }
void void
LocalDeviceImpl::HardwareError(struct hci_ev_hardware_error* event) LocalDeviceImpl::HardwareError(struct hci_ev_hardware_error* event)
{ {
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: hardware code=%#x\n", Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: hardware code=%#x\n",
__FUNCTION__, event->hardware_code); __FUNCTION__, event->hardware_code);
} }
@@ -774,13 +819,13 @@ LocalDeviceImpl::ProcessSimpleRequest(BMessage* request)
AddWantedEvent(request); AddWantedEvent(request);
// LEAK: is command buffer freed within the Message? // LEAK: is command buffer freed within the Message?
if (((HCITransportAccessor*)fHCIDelegate)->IssueCommand(command, size) if (((HCITransportAccessor*)fHCIDelegate)->IssueCommand(command, size)
== B_ERROR) { == B_ERROR) {
// TODO: - Reply the request with error! // TODO: - Reply the request with error!
// - Remove the just added request // - Remove the just added request
(Output::Instance()->Post("## ERROR Command issue, REMOVING!\n", BLACKBOARD_KIT)); (Output::Instance()->Post("## ERROR Command issue, REMOVING!\n", BLACKBOARD_KIT));
ClearWantedEvent(request); ClearWantedEvent(request);
} else { } else {
return B_OK; return B_OK;
} }