- 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:
@@ -162,15 +162,16 @@ void BluetoothServer::MessageReceived(BMessage* message)
|
||||
case BT_MSG_ADD_DEVICE:
|
||||
{
|
||||
BString str;
|
||||
BPath path(str.String());
|
||||
|
||||
message->FindString("name", &str);
|
||||
|
||||
Output::Instance()->Postf(BLACKBOARD_GENERAL,
|
||||
"Requested LocalDevice %s\n", str.String());
|
||||
|
||||
LocalDeviceImpl* lDeviceImpl =
|
||||
LocalDeviceImpl::CreateTransportAccessor(&path);
|
||||
BPath path(str.String());
|
||||
|
||||
LocalDeviceImpl* lDeviceImpl
|
||||
= LocalDeviceImpl::CreateTransportAccessor(&path);
|
||||
|
||||
if (lDeviceImpl->GetID() >= 0) {
|
||||
fLocalDevicesList.AddItem(lDeviceImpl);
|
||||
@@ -300,6 +301,8 @@ BluetoothServer::LocateLocalDeviceImpl(hci_id hid)
|
||||
status_t
|
||||
BluetoothServer::HandleLocalDevicesCount(BMessage* message, BMessage* reply)
|
||||
{
|
||||
Output::Instance()->Post("Count Requested\n", BLACKBOARD_KIT);
|
||||
|
||||
return reply->AddInt32("count", fLocalDevicesList.CountItems());
|
||||
}
|
||||
|
||||
@@ -415,9 +418,9 @@ BluetoothServer::HandleSimpleRequest(BMessage* message, BMessage* reply)
|
||||
status_t
|
||||
BluetoothServer::HandleGetProperty(BMessage* message, BMessage* reply)
|
||||
{
|
||||
/* 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
|
||||
*/
|
||||
// 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
|
||||
|
||||
LocalDeviceImpl* lDeviceImpl = LocateDelegateFromMessage(message);
|
||||
if (lDeviceImpl == NULL) {
|
||||
return B_ERROR;
|
||||
|
||||
@@ -23,8 +23,8 @@ HCITransportAccessor::HCITransportAccessor(BPath* path) : HCIDelegate(path)
|
||||
printf("%s: hid retrieved %lx status=%ld\n", __FUNCTION__,
|
||||
fIdentifier, status);
|
||||
} else {
|
||||
printf("%s: Device driver could not be opened %ld\n", __FUNCTION__,
|
||||
fIdentifier);
|
||||
printf("%s: Device driver %s could not be opened %ld\n", __FUNCTION__,
|
||||
path->Path(), fIdentifier);
|
||||
fIdentifier = B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ LocalDeviceImpl::~LocalDeviceImpl()
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LocalDeviceImpl::Unregister()
|
||||
{
|
||||
@@ -83,7 +84,8 @@ LocalDeviceImpl::Unregister()
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -278,7 +280,8 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
|
||||
|
||||
|
||||
void
|
||||
LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request,
|
||||
LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
|
||||
BMessage* request,
|
||||
int32 index) {
|
||||
|
||||
int16 opcodeExpected;
|
||||
@@ -327,8 +330,56 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
|
||||
|
||||
// This request is not gonna be used anymore
|
||||
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;
|
||||
}
|
||||
|
||||
case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE):
|
||||
{
|
||||
@@ -451,9 +502,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
|
||||
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_PIN_CODE_NEG_REPLY):
|
||||
{
|
||||
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) {
|
||||
Output::Instance()->Post("Positive reply for pincode reject\n", BLACKBOARD_KIT);
|
||||
} else {
|
||||
@@ -536,8 +587,7 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques
|
||||
if (event->status == BT_OK) {
|
||||
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS,
|
||||
PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Output::Instance()->Post("Wrong Command Status for remote friendly name\n", BLACKBOARD_KIT);
|
||||
|
||||
reply.AddInt8("status", event->status);
|
||||
@@ -578,8 +628,8 @@ LocalDeviceImpl::InquiryResult(uint8* numberOfResponses, BMessage* request)
|
||||
BMessage reply(BT_MSG_INQUIRY_DEVICE);
|
||||
|
||||
// skipping here the number of responses
|
||||
reply.AddData("info", B_ANY_TYPE, numberOfResponses + 1
|
||||
, (*numberOfResponses) * sizeof(struct inquiry_info) );
|
||||
reply.AddData("info", B_ANY_TYPE, numberOfResponses + 1,
|
||||
(*numberOfResponses) * sizeof(struct inquiry_info) );
|
||||
|
||||
reply.AddInt8("count", *numberOfResponses);
|
||||
|
||||
@@ -634,7 +684,7 @@ LocalDeviceImpl::ConnectionRequest(struct hci_ev_conn_request* event, BMessage*
|
||||
"Connection Incoming type %x from %s...\n",
|
||||
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
|
||||
|
||||
command = buildAcceptConnectionRequest(event->bdaddr, 0x01 /*slave*/, &size);
|
||||
@@ -675,7 +725,6 @@ LocalDeviceImpl::ConnectionComplete(struct hci_ev_conn_complete* event, BMessage
|
||||
new RemoteDevice(event->bdaddr, cod));
|
||||
iConnection->Show();
|
||||
|
||||
|
||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
|
||||
"%s: Address %s handle=%#x type=%d encrypt=%d\n", __FUNCTION__,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -751,10 +798,8 @@ LocalDeviceImpl::MaxSlotChange(struct hci_ev_max_slot_change *event,
|
||||
void
|
||||
LocalDeviceImpl::HardwareError(struct hci_ev_hardware_error* event)
|
||||
{
|
||||
|
||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: hardware code=%#x\n",
|
||||
__FUNCTION__, event->hardware_code);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user