- Some refactoring on the event handling

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36335 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2010-04-17 20:10:47 +00:00
parent b9d586e9d9
commit 2db900d8f1
2 changed files with 298 additions and 236 deletions
+289 -226
View File
@@ -95,6 +95,160 @@ LocalDeviceImpl::Unregister()
#pragma mark - Event handling methods -
#endif
template<typename T, typename Header>
inline T*
JumpEventHeader(Header* event)
{
return (T*)(event + 1);
}
void
LocalDeviceImpl::HandleUnexpectedEvent(struct hci_event_header* event)
{
// Events here might have not been initated by us
// TODO: ML mark as handled pass a reply by parameter and reply in common
switch (event->ecode) {
case HCI_EVENT_HARDWARE_ERROR:
HardwareError(
JumpEventHeader<struct hci_ev_hardware_error>(event));
break;
case HCI_EVENT_CONN_REQUEST:
ConnectionRequest(
JumpEventHeader<struct hci_ev_conn_request>(event), NULL);
break;
case HCI_EVENT_CONN_COMPLETE:
// should belong to a request? can be sporadic or initiated by us
ConnectionComplete(
JumpEventHeader<struct hci_ev_conn_complete>(event), NULL);
break;
case HCI_EVENT_PIN_CODE_REQ:
PinCodeRequest(
JumpEventHeader<struct hci_ev_pin_code_req>(event), NULL);
break;
}
}
void
LocalDeviceImpl::HandleExpectedRequest(struct hci_event_header* event, BMessage* request)
{
// we are waiting for a reply
switch (event->ecode) {
case HCI_EVENT_INQUIRY_COMPLETE:
InquiryComplete(JumpEventHeader<uint8>(event), request);
break;
case HCI_EVENT_INQUIRY_RESULT:
InquiryResult(JumpEventHeader<uint8>(event), request);
break;
case HCI_EVENT_DISCONNECTION_COMPLETE:
// should belong to a request? can be sporadic or initiated by us¿?...
DisconnectionComplete(
JumpEventHeader<struct hci_ev_disconnection_complete_reply>(event),
request);
break;
case HCI_EVENT_AUTH_COMPLETE:
break;
case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE:
RemoteNameRequestComplete(
JumpEventHeader<struct hci_ev_remote_name_request_complete_reply>
(event), request);
break;
case HCI_EVENT_ENCRYPT_CHANGE:
break;
case HCI_EVENT_CHANGE_CONN_LINK_KEY_COMPLETE:
break;
case HCI_EVENT_MASTER_LINK_KEY_COMPL:
break;
case HCI_EVENT_RMT_FEATURES:
break;
case HCI_EVENT_RMT_VERSION:
break;
case HCI_EVENT_QOS_SETUP_COMPLETE:
break;
case HCI_EVENT_FLUSH_OCCUR:
break;
case HCI_EVENT_ROLE_CHANGE:
RoleChange(JumpEventHeader<struct hci_ev_role_change>(event), request);
break;
case HCI_EVENT_NUM_COMP_PKTS:
break;
case HCI_EVENT_MODE_CHANGE:
break;
case HCI_EVENT_RETURN_LINK_KEYS:
break;
case HCI_EVENT_LINK_KEY_REQ:
break;
case HCI_EVENT_LINK_KEY_NOTIFY:
LinkKeyNotify(JumpEventHeader<struct hci_ev_link_key_notify>
(event), request);
break;
case HCI_EVENT_LOOPBACK_COMMAND:
break;
case HCI_EVENT_DATA_BUFFER_OVERFLOW:
break;
case HCI_EVENT_MAX_SLOT_CHANGE:
MaxSlotChange(JumpEventHeader<struct hci_ev_max_slot_change>(event),
request);
break;
case HCI_EVENT_READ_CLOCK_OFFSET_COMPL:
break;
case HCI_EVENT_CON_PKT_TYPE_CHANGED:
break;
case HCI_EVENT_QOS_VIOLATION:
break;
case HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE:
PageScanRepetitionModeChange(
JumpEventHeader<struct hci_ev_page_scan_rep_mode_change>(event),
request);
break;
case HCI_EVENT_FLOW_SPECIFICATION:
break;
case HCI_EVENT_INQUIRY_RESULT_WITH_RSSI:
break;
case HCI_EVENT_REMOTE_EXTENDED_FEATURES:
break;
case HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETED:
break;
case HCI_EVENT_SYNCHRONOUS_CONNECTION_CHANGED:
break;
}
}
void
LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
{
@@ -105,180 +259,70 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
}
printf("### \n");
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"Incomming %s event\n",
BluetoothEvent(event->ecode));
BMessage* request = NULL;
int32 eventIndexLocation;
// Events here might have not been initated by us
// TODO: ML mark as handled pass a reply by parameter and reply in common
// Check if it is a requested one
switch (event->ecode) {
case HCI_EVENT_HARDWARE_ERROR:
HardwareError((struct hci_ev_hardware_error*)(event + 1));
return;
case HCI_EVENT_CMD_COMPLETE:
{
struct hci_ev_cmd_complete* commandComplete
= JumpEventHeader<struct hci_ev_cmd_complete>(event);
case HCI_EVENT_CONN_REQUEST:
ConnectionRequest((struct hci_ev_conn_request*)(event + 1), NULL);
return;
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"Incomming CommandComplete for %s\n",
BluetoothCommandOpcode(commandComplete->opcode));
case HCI_EVENT_CONN_COMPLETE:
// should belong to a request? can be sporadic or initiated by us¿?...
ConnectionComplete((struct hci_ev_conn_complete*)(event + 1), NULL);
return;
request = FindPetition(event->ecode, commandComplete->opcode,
&eventIndexLocation);
case HCI_EVENT_PIN_CODE_REQ:
PinCodeRequest((struct hci_ev_pin_code_req*)(event + 1), NULL);
return;
if (request != NULL)
CommandComplete(commandComplete, request, eventIndexLocation);
break;
}
case HCI_EVENT_CMD_STATUS:
{
struct hci_ev_cmd_status* commandStatus
= JumpEventHeader<struct hci_ev_cmd_status>(event);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"Incomming CommandStatus for %s\n",
BluetoothCommandOpcode(commandStatus->opcode));
request = FindPetition(event->ecode, commandStatus->opcode,
&eventIndexLocation);
if (request != NULL)
CommandStatus(commandStatus, request, eventIndexLocation);
break;
}
default:
// lets go on
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"Incomming %s event\n",
BluetoothEvent(event->ecode));
request = FindPetition(event->ecode);
if (request != NULL)
HandleExpectedRequest(event, request);
break;
}
BMessage* request = NULL;
int32 eventIndexLocation;
// Check if it is a requested one
if (event->ecode == HCI_EVENT_CMD_COMPLETE) {
request = FindPetition(event->ecode, ((struct hci_ev_cmd_complete*)
(event + 1))->opcode, &eventIndexLocation);
} else if (event->ecode == HCI_EVENT_CMD_STATUS) {
request = FindPetition(event->ecode, ((struct hci_ev_cmd_status*)
(event + 1))->opcode, &eventIndexLocation);
} else {
request = FindPetition(event->ecode);
}
if (request == NULL) {
if (request == NULL)
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"Event %x could not be understood or delivered\n", event->ecode);
return;
}
"Event %s could not be understood or delivered\n",
BluetoothEvent(event->ecode));
// we are waiting for a reply
switch (event->ecode) {
case HCI_EVENT_INQUIRY_COMPLETE:
InquiryComplete((uint8*)(event + 1), request);
break;
case HCI_EVENT_INQUIRY_RESULT:
InquiryResult((uint8*)(event + 1), request);
break;
case HCI_EVENT_DISCONNECTION_COMPLETE:
// should belong to a request? can be sporadic or initiated by us¿?...
DisconnectionComplete((struct hci_ev_disconnection_complete_reply*)
(event + 1), request);
break;
case HCI_EVENT_AUTH_COMPLETE:
break;
case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE:
RemoteNameRequestComplete((struct hci_ev_remote_name_request_complete_reply*)
(event + 1), request);
break;
case HCI_EVENT_ENCRYPT_CHANGE:
break;
case HCI_EVENT_CHANGE_CONN_LINK_KEY_COMPLETE:
break;
case HCI_EVENT_MASTER_LINK_KEY_COMPL:
break;
case HCI_EVENT_RMT_FEATURES:
break;
case HCI_EVENT_RMT_VERSION:
break;
case HCI_EVENT_QOS_SETUP_COMPLETE:
break;
case HCI_EVENT_CMD_COMPLETE:
CommandComplete((struct hci_ev_cmd_complete*)(event + 1),
request, eventIndexLocation);
break;
case HCI_EVENT_CMD_STATUS:
CommandStatus((struct hci_ev_cmd_status*)(event + 1), request,
eventIndexLocation);
break;
case HCI_EVENT_FLUSH_OCCUR:
break;
case HCI_EVENT_ROLE_CHANGE:
RoleChange((struct hci_ev_role_change*)(event + 1), request,
eventIndexLocation);
break;
case HCI_EVENT_NUM_COMP_PKTS:
break;
case HCI_EVENT_MODE_CHANGE:
break;
case HCI_EVENT_RETURN_LINK_KEYS:
break;
case HCI_EVENT_LINK_KEY_REQ:
break;
case HCI_EVENT_LINK_KEY_NOTIFY:
LinkKeyNotify((struct hci_ev_link_key_notify*)(event + 1),
request, eventIndexLocation);
break;
case HCI_EVENT_LOOPBACK_COMMAND:
break;
case HCI_EVENT_DATA_BUFFER_OVERFLOW:
break;
case HCI_EVENT_MAX_SLOT_CHANGE:
MaxSlotChange((struct hci_ev_max_slot_change*)(event + 1), request,
eventIndexLocation);
break;
case HCI_EVENT_READ_CLOCK_OFFSET_COMPL:
break;
case HCI_EVENT_CON_PKT_TYPE_CHANGED:
break;
case HCI_EVENT_QOS_VIOLATION:
break;
case HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE:
PageScanRepetitionModeChange((struct hci_ev_page_scan_rep_mode_change*)
(event+1), request, eventIndexLocation);
break;
case HCI_EVENT_FLOW_SPECIFICATION:
break;
case HCI_EVENT_INQUIRY_RESULT_WITH_RSSI:
break;
case HCI_EVENT_REMOTE_EXTENDED_FEATURES:
break;
case HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETED:
break;
case HCI_EVENT_SYNCHRONOUS_CONNECTION_CHANGED:
break;
}
HandleUnexpectedEvent(event);
}
#if 0
#pragma mark -
#endif
void
LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
BMessage* request,
@@ -293,14 +337,16 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
if (request->IsSourceWaiting() == false)
Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) for %s\n",__FUNCTION__,
event->ncmd, BluetoothCommandOpcode(opcodeExpected));
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) for %s\n",
__FUNCTION__, event->ncmd, BluetoothCommandOpcode(opcodeExpected));
switch ((uint16)opcodeExpected) {
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
= JumpEventHeader<struct hci_rp_read_loc_version,
struct hci_ev_cmd_complete>(event);
if (version->status == BT_OK) {
@@ -322,7 +368,8 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
}
Output::Instance()->Postf(BLACKBOARD_KIT, "Reply for Local Version %x\n", version->status);
Output::Instance()->Postf(BLACKBOARD_KIT,
"Reply for Local Version %x\n", version->status);
reply.AddInt8("status", version->status);
printf("Sending reply ... %ld\n", request->SendReply(&reply));
@@ -336,7 +383,8 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
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);
= JumpEventHeader<struct hci_rp_read_loc_features,
struct hci_ev_cmd_complete>(event);
if (features->status == BT_OK) {
@@ -370,7 +418,8 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
}
Output::Instance()->Postf(BLACKBOARD_KIT, "Reply for Local Features %x\n", features->status);
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));
@@ -383,7 +432,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
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
= JumpEventHeader<struct hci_rp_read_buffer_size,
struct hci_ev_cmd_complete>(event);
if (buffer->status == BT_OK) {
@@ -401,8 +452,8 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
}
Output::Instance()->Postf(BLACKBOARD_KIT, "Reply for Read Buffer Size %x\n",
buffer->status);
Output::Instance()->Postf(BLACKBOARD_KIT,
"Reply for Read Buffer Size %x\n", buffer->status);
reply.AddInt8("status", buffer->status);
@@ -416,15 +467,18 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
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
= JumpEventHeader<struct hci_rp_read_bd_addr,
struct hci_ev_cmd_complete>(event);
if (readbdaddr->status == BT_OK) {
reply.AddData("bdaddr", B_ANY_TYPE, &readbdaddr->bdaddr, sizeof(bdaddr_t));
Output::Instance()->Post("Positive reply for getAddress\n", BLACKBOARD_KIT);
} else {
Output::Instance()->Post("Negative reply for getAddress\n", BLACKBOARD_KIT);
reply.AddData("bdaddr", B_ANY_TYPE, &readbdaddr->bdaddr,
sizeof(bdaddr_t));
}
Output::Instance()->Postf(BLACKBOARD_KIT,
"Read bdaddr status = %x\n", readbdaddr->status);
reply.AddInt8("status", readbdaddr->status);
printf("Sending reply ... %ld\n", request->SendReply(&reply));
reply.PrintToStream();
@@ -437,15 +491,19 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
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
= JumpEventHeader<struct hci_read_dev_class_reply,
struct hci_ev_cmd_complete>(event);
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,
"Read DeviceClass status = %x DeviceClass = [%x][%x][%x]\n", classDev->status,
classDev->dev_class[0], classDev->dev_class[1], classDev->dev_class[2]);
"Read DeviceClass status = %x DeviceClass = [%x][%x][%x]\n",
classDev->status, classDev->dev_class[0],
classDev->dev_class[1], classDev->dev_class[2]);
reply.AddInt8("status", classDev->status);
@@ -459,16 +517,18 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
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
= JumpEventHeader<struct hci_rp_read_local_name,
struct hci_ev_cmd_complete>(event);
if (readLocalName->status == BT_OK) {
reply.AddString("friendlyname", (const char*)readLocalName->local_name );
Output::Instance()->Post("Positive reply for friendly name\n", BLACKBOARD_KIT);
} else {
Output::Instance()->Post("Negative reply for friendly name\n", BLACKBOARD_KIT);
reply.AddString("friendlyname", (const char*)readLocalName->local_name);
}
Output::Instance()->Postf(BLACKBOARD_KIT, "Friendly name status %x\n",
readLocalName->status);
reply.AddInt8("status", readLocalName->status);
printf("Sending reply ... %ld\n", request->SendReply(&reply));
reply.PrintToStream();
@@ -483,11 +543,8 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
uint8* statusReply = (uint8*)(event + 1);
// TODO: This reply has to match the BDADDR of the outgoing message
if (*statusReply == BT_OK) {
Output::Instance()->Post("Positive reply for pincode accept\n", BLACKBOARD_KIT);
} else {
Output::Instance()->Post("Negative reply for pincode accept\n", BLACKBOARD_KIT);
}
Output::Instance()->Postf(BLACKBOARD_KIT, "pincode accept status %x\n",
*statusReply);
reply.AddInt8("status", *statusReply);
printf("Sending reply ... %ld\n", request->SendReply(&reply));
@@ -505,11 +562,8 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
// 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 {
Output::Instance()->Post("Negative reply for pincode reject\n", BLACKBOARD_KIT);
}
Output::Instance()->Postf(BLACKBOARD_KIT, "pincode reject status %x\n",
*statusReply);
reply.AddInt8("status", *statusReply);
printf("Sending reply ... %ld\n",request->SendReply(&reply));
@@ -529,7 +583,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
reply.AddInt8("status", *(uint8*)(event + 1));
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);
@@ -555,8 +609,9 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques
// Handle command complete information
request->FindInt16("opcodeExpected", index, &opcodeExpected);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) %x for %s\n",__FUNCTION__,
event->ncmd, event->status, BluetoothCommandOpcode(event->opcode));
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) %x for %s\n",
__FUNCTION__, event->ncmd, event->status,
BluetoothCommandOpcode(event->opcode));
if (request->IsSourceWaiting() == false)
Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);
@@ -567,11 +622,8 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques
{
reply.what = BT_MSG_INQUIRY_STARTED;
if (event->status == BT_OK) {
Output::Instance()->Post("Positive reply for inquiry status\n", BLACKBOARD_KIT);
} else {
Output::Instance()->Post("Negative reply for inquiry status\n", BLACKBOARD_KIT);
}
Output::Instance()->Postf(BLACKBOARD_KIT,
"Inquiry status %x\n", event->status);
reply.AddInt8("status", event->status);
printf("Sending reply ... %ld\n", request->SendReply(&reply));
@@ -588,7 +640,8 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS,
PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST));
} else {
Output::Instance()->Post("Wrong Command Status for remote friendly name\n", BLACKBOARD_KIT);
Output::Instance()->Postf(BLACKBOARD_KIT,
"Command Status for remote friendly name %x\n", event->status);
reply.AddInt8("status", event->status);
printf("Sending reply ... %ld\n", request->SendReply(&reply));
@@ -652,7 +705,8 @@ LocalDeviceImpl::InquiryComplete(uint8* status, BMessage* request)
void
LocalDeviceImpl::RemoteNameRequestComplete(
struct hci_ev_remote_name_request_complete_reply* remotename, BMessage* request)
struct hci_ev_remote_name_request_complete_reply* remotename,
BMessage* request)
{
BMessage reply;
@@ -662,9 +716,11 @@ LocalDeviceImpl::RemoteNameRequestComplete(
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),
bdaddrUtils::ToString(remotename->bdaddr), BluetoothError(remotename->status));
bdaddrUtils::ToString(remotename->bdaddr),
BluetoothError(remotename->status));
printf("Sending reply ... %ld\n", request->SendReply(&reply));
reply.PrintToStream();
@@ -691,7 +747,8 @@ LocalDeviceImpl::ConnectionRequest(struct hci_ev_conn_request* event, BMessage*
BMessage* newrequest = new BMessage;
newrequest->AddInt16("eventExpected", HCI_EVENT_CMD_STATUS);
newrequest->AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL, OCF_ACCEPT_CONN_REQ));
newrequest->AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL,
OCF_ACCEPT_CONN_REQ));
newrequest->AddInt16("eventExpected", HCI_EVENT_PIN_CODE_REQ);
newrequest->AddInt16("eventExpected", HCI_EVENT_ROLE_CHANGE);
@@ -705,7 +762,7 @@ LocalDeviceImpl::ConnectionRequest(struct hci_ev_conn_request* event, BMessage*
if ((fHCIDelegate)->IssueCommand(command, size) == B_ERROR) {
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"Command issue error for ConnAccept\n");
// remove the request ¿?
// remove the request?
} else {
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"Command issue for ConnAccept\n");
@@ -743,11 +800,11 @@ LocalDeviceImpl::DisconnectionComplete(struct hci_ev_disconnection_complete_repl
{
Output::Instance()->Post("Disconnected\n", BLACKBOARD_KIT);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Handle=%#x, reason=%x status=%x\n",
__FUNCTION__, event->handle, event->reason, event->status);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"%s: Handle=%#x, reason=%x status=%x\n", __FUNCTION__, event->handle,
event->reason, event->status);
ClearWantedEvent(request);
}
@@ -760,46 +817,50 @@ LocalDeviceImpl::PinCodeRequest(struct hci_ev_pin_code_req* event, BMessage* req
void
LocalDeviceImpl::RoleChange(hci_ev_role_change* event, BMessage* request, int32 index)
LocalDeviceImpl::RoleChange(hci_ev_role_change* event, BMessage* request)
{
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Address %s role=%d status=%d\n",
__FUNCTION__, bdaddrUtils::ToString(event->bdaddr), event->role, event->status);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"%s: Address %s role=%d status=%d\n", __FUNCTION__,
bdaddrUtils::ToString(event->bdaddr), event->role, event->status);
}
void
LocalDeviceImpl::PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_change* event,
BMessage* request, int32 index)
BMessage* request)
{
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Address %s type=%d\n",
__FUNCTION__, bdaddrUtils::ToString(event->bdaddr), event->page_scan_rep_mode);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"%s: Address %s type=%d\n", __FUNCTION__,
bdaddrUtils::ToString(event->bdaddr), event->page_scan_rep_mode);
}
void
LocalDeviceImpl::LinkKeyNotify(hci_ev_link_key_notify* event,
BMessage* request, int32 index)
BMessage* request)
{
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Address %s, key=%s, type=%d\n",
__FUNCTION__, bdaddrUtils::ToString(event->bdaddr),
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"%s: Address %s, key=%s, type=%d\n", __FUNCTION__,
bdaddrUtils::ToString(event->bdaddr),
LinkKeyUtils::ToString(event->link_key), event->key_type);
}
void
LocalDeviceImpl::MaxSlotChange(struct hci_ev_max_slot_change* event,
BMessage* request, int32 index)
BMessage* request)
{
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Handle=%#x, max slots=%d\n",
__FUNCTION__, event->handle, event->lmp_max_slots);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"%s: Handle=%#x, max slots=%d\n", __FUNCTION__,
event->handle, event->lmp_max_slots);
}
void
LocalDeviceImpl::HardwareError(struct hci_ev_hardware_error* event)
{
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: hardware code=%#x\n",
__FUNCTION__, event->hardware_code);
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
"%s: hardware code=%#x\n", __FUNCTION__, event->hardware_code);
}
@@ -821,9 +882,11 @@ LocalDeviceImpl::ProcessSimpleRequest(BMessage* request)
// LEAK: is command buffer freed within the Message?
if (((HCITransportAccessor*)fHCIDelegate)->IssueCommand(command, size)
== B_ERROR) {
// TODO: - Reply the request with error!
// - Remove the just added request
(Output::Instance()->Post("## ERROR Command issue, REMOVING!\n", BLACKBOARD_KIT));
// TODO:
// Reply the request with error!
// Remove the just added request
(Output::Instance()->Post("## ERROR Command issue, REMOVING!\n",
BLACKBOARD_KIT));
ClearWantedEvent(request);
} else {