Mika Lindqvist & me
- Add Handling for MaxSlotChange - Many Styling and consistency - Debug output improved git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29682 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
* Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||||
*
|
* Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "BluetoothServer.h"
|
#include "BluetoothServer.h"
|
||||||
|
|
||||||
#include "LocalDeviceImpl.h"
|
#include "LocalDeviceImpl.h"
|
||||||
@@ -13,8 +12,9 @@
|
|||||||
#include "Output.h"
|
#include "Output.h"
|
||||||
|
|
||||||
#include <bluetooth/bdaddrUtils.h>
|
#include <bluetooth/bdaddrUtils.h>
|
||||||
#include <bluetooth/RemoteDevice.h>
|
|
||||||
#include <bluetooth/bluetooth_error.h>
|
#include <bluetooth/bluetooth_error.h>
|
||||||
|
#include <bluetooth/LinkKeyUtils.h>
|
||||||
|
#include <bluetooth/RemoteDevice.h>
|
||||||
#include <bluetooth/HCI/btHCI_event.h>
|
#include <bluetooth/HCI/btHCI_event.h>
|
||||||
|
|
||||||
#include <bluetoothserver_p.h>
|
#include <bluetoothserver_p.h>
|
||||||
@@ -33,24 +33,24 @@
|
|||||||
LocalDeviceImpl*
|
LocalDeviceImpl*
|
||||||
LocalDeviceImpl::CreateControllerAccessor(BPath* path)
|
LocalDeviceImpl::CreateControllerAccessor(BPath* path)
|
||||||
{
|
{
|
||||||
HCIDelegate* hd = new HCIControllerAccessor(path);
|
HCIDelegate* hd = new HCIControllerAccessor(path);
|
||||||
|
|
||||||
if ( hd != NULL)
|
if (hd != NULL)
|
||||||
return new LocalDeviceImpl(hd);
|
return new LocalDeviceImpl(hd);
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LocalDeviceImpl*
|
LocalDeviceImpl*
|
||||||
LocalDeviceImpl::CreateTransportAccessor(BPath* path)
|
LocalDeviceImpl::CreateTransportAccessor(BPath* path)
|
||||||
{
|
{
|
||||||
HCIDelegate* hd = new HCITransportAccessor(path);
|
HCIDelegate* hd = new HCITransportAccessor(path);
|
||||||
|
|
||||||
if ( hd != NULL)
|
if (hd != NULL)
|
||||||
return new LocalDeviceImpl(hd);
|
return new LocalDeviceImpl(hd);
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -67,28 +67,32 @@ 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");
|
||||||
|
|
||||||
// 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(event);
|
//HardwareError(event);
|
||||||
return;
|
return;
|
||||||
|
break;
|
||||||
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;
|
||||||
|
break;
|
||||||
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;
|
||||||
|
break;
|
||||||
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;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// lets go on
|
// lets go on
|
||||||
break;
|
break;
|
||||||
@@ -97,53 +101,48 @@ printf("### \n");
|
|||||||
BMessage* request = NULL;
|
BMessage* request = NULL;
|
||||||
int32 eventIndexLocation;
|
int32 eventIndexLocation;
|
||||||
|
|
||||||
// Check if its 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*)
|
||||||
(Output::Instance()->Postf(BLACKBOARD_LD(GetID()), "Command Complete, n commands %d\n",
|
(event+1))->opcode, &eventIndexLocation);
|
||||||
((struct hci_ev_cmd_complete*)event)->ncmd));
|
|
||||||
*/
|
|
||||||
request = FindPetition(event->ecode, ((struct hci_ev_cmd_complete*)(event+1))->opcode,
|
|
||||||
&eventIndexLocation);
|
|
||||||
|
|
||||||
} else if ( event->ecode == HCI_EVENT_CMD_STATUS ) {
|
} else if (event->ecode == HCI_EVENT_CMD_STATUS) {
|
||||||
|
|
||||||
/*(Output::Instance()->Postf(BLACKBOARD_LD(GetID()), "Command Status, n commands %d status %x\n",
|
request = FindPetition(event->ecode, ((struct hci_ev_cmd_status*)
|
||||||
((struct hci_ev_cmd_status*)event)->ncmd,
|
(event+1))->opcode, &eventIndexLocation);
|
||||||
((struct hci_ev_cmd_status*)event)->status ));
|
|
||||||
*/
|
|
||||||
request = FindPetition(event->ecode, ((struct hci_ev_cmd_status*)(event+1))->opcode,
|
|
||||||
&eventIndexLocation);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
request = FindPetition(event->ecode);
|
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);
|
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
|
||||||
|
"Event %x could not be understood or delivered\n", event->ecode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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*)(event+1), request);
|
DisconnectionComplete((struct hci_ev_disconnection_complete_reply*)
|
||||||
|
(event+1), request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_AUTH_COMPLETE:
|
case HCI_EVENT_AUTH_COMPLETE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE:
|
case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE:
|
||||||
RemoteNameRequestComplete((struct hci_ev_remote_name_request_complete_reply*)(event+1), request);
|
RemoteNameRequestComplete((struct hci_ev_remote_name_request_complete_reply*)
|
||||||
|
(event+1), request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_ENCRYPT_CHANGE:
|
case HCI_EVENT_ENCRYPT_CHANGE:
|
||||||
@@ -165,18 +164,21 @@ printf("### \n");
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_CMD_COMPLETE:
|
case HCI_EVENT_CMD_COMPLETE:
|
||||||
CommandComplete((struct hci_ev_cmd_complete*)(event+1), request, eventIndexLocation);
|
CommandComplete((struct hci_ev_cmd_complete*)(event+1),
|
||||||
|
request, eventIndexLocation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_CMD_STATUS:
|
case HCI_EVENT_CMD_STATUS:
|
||||||
CommandStatus((struct hci_ev_cmd_status*)(event+1), request, eventIndexLocation);
|
CommandStatus((struct hci_ev_cmd_status*)(event+1), request,
|
||||||
|
eventIndexLocation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_FLUSH_OCCUR:
|
case HCI_EVENT_FLUSH_OCCUR:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_ROLE_CHANGE:
|
case HCI_EVENT_ROLE_CHANGE:
|
||||||
RoleChange((struct hci_ev_role_change*)(event+1), request, eventIndexLocation);
|
RoleChange((struct hci_ev_role_change*)(event+1), request,
|
||||||
|
eventIndexLocation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_NUM_COMP_PKTS:
|
case HCI_EVENT_NUM_COMP_PKTS:
|
||||||
@@ -192,7 +194,8 @@ printf("### \n");
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_LINK_KEY_NOTIFY:
|
case HCI_EVENT_LINK_KEY_NOTIFY:
|
||||||
LinkKeyNotify((struct hci_ev_link_key_notify*)(event+1), request, eventIndexLocation);
|
LinkKeyNotify((struct hci_ev_link_key_notify*)(event+1),
|
||||||
|
request, eventIndexLocation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_LOOPBACK_COMMAND:
|
case HCI_EVENT_LOOPBACK_COMMAND:
|
||||||
@@ -202,6 +205,9 @@ printf("### \n");
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_MAX_SLOT_CHANGE:
|
case HCI_EVENT_MAX_SLOT_CHANGE:
|
||||||
|
MaxSlotChange((struct hci_ev_max_slot_change*)(event+1), request,
|
||||||
|
eventIndexLocation);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_READ_CLOCK_OFFSET_COMPL:
|
case HCI_EVENT_READ_CLOCK_OFFSET_COMPL:
|
||||||
@@ -214,7 +220,8 @@ printf("### \n");
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE:
|
case HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE:
|
||||||
PageScanRepetitionModeChange((struct hci_ev_page_scan_rep_mode_change*)(event+1), request, eventIndexLocation);
|
PageScanRepetitionModeChange((struct hci_ev_page_scan_rep_mode_change*)
|
||||||
|
(event+1), request, eventIndexLocation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_FLOW_SPECIFICATION:
|
case HCI_EVENT_FLOW_SPECIFICATION:
|
||||||
@@ -238,32 +245,29 @@ printf("### \n");
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request, int32 index) {
|
LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request,
|
||||||
|
int32 index) {
|
||||||
|
|
||||||
int16 opcodeExpected;
|
int16 opcodeExpected;
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
|
|
||||||
// Handle command complete information
|
// Handle command complete information
|
||||||
request->FindInt16("opcodeExpected", index, &opcodeExpected);
|
request->FindInt16("opcodeExpected", index, &opcodeExpected);
|
||||||
|
|
||||||
|
|
||||||
if (request->IsSourceWaiting() == false)
|
if (request->IsSourceWaiting() == false)
|
||||||
Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);
|
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,GetCommand(opcodeExpected));
|
||||||
|
|
||||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) for %s\n",__FUNCTION__, event->ncmd,GetCommand(opcodeExpected));
|
switch ((uint16)opcodeExpected) {
|
||||||
switch ((uint16)opcodeExpected) {
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
reply.AddInt8("status", version->status);
|
|
||||||
|
|
||||||
if (version->status == BT_OK) {
|
if (version->status == BT_OK) {
|
||||||
|
|
||||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
|
||||||
reply.PrintToStream();
|
|
||||||
|
|
||||||
if (!IsPropertyAvailable("hci_version"))
|
if (!IsPropertyAvailable("hci_version"))
|
||||||
fProperties->AddInt8("hci_version", version->hci_version);
|
fProperties->AddInt8("hci_version", version->hci_version);
|
||||||
@@ -280,25 +284,24 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
|
|||||||
if (!IsPropertyAvailable("manufacturer"))
|
if (!IsPropertyAvailable("manufacturer"))
|
||||||
fProperties->AddInt16("manufacturer", version->manufacturer);
|
fProperties->AddInt16("manufacturer", version->manufacturer);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
|
||||||
|
|
||||||
// This request is not gonna be used anymore
|
reply.AddInt8("status", version->status);
|
||||||
ClearWantedEvent(request);
|
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||||
}
|
reply.PrintToStream();
|
||||||
break;
|
|
||||||
|
|
||||||
case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE):
|
// This request is not gonna be used anymore
|
||||||
{
|
ClearWantedEvent(request);
|
||||||
struct hci_rp_read_buffer_size* buffer = (struct hci_rp_read_buffer_size*)(event+1);
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
reply.AddInt8("status", buffer->status);
|
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);
|
||||||
|
|
||||||
if (buffer->status == BT_OK) {
|
if (buffer->status == BT_OK) {
|
||||||
|
|
||||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
|
||||||
reply.PrintToStream();
|
|
||||||
|
|
||||||
if (!IsPropertyAvailable("acl_mtu"))
|
if (!IsPropertyAvailable("acl_mtu"))
|
||||||
fProperties->AddInt16("acl_mtu", buffer->acl_mtu);
|
fProperties->AddInt16("acl_mtu", buffer->acl_mtu);
|
||||||
@@ -312,167 +315,128 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
|
|||||||
if (!IsPropertyAvailable("sco_max_pkt"))
|
if (!IsPropertyAvailable("sco_max_pkt"))
|
||||||
fProperties->AddInt16("sco_max_pkt", buffer->sco_max_pkt);
|
fProperties->AddInt16("sco_max_pkt", buffer->sco_max_pkt);
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
// This request is not gonna be used anymore
|
reply.AddInt8("status", buffer->status);
|
||||||
ClearWantedEvent(request);
|
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||||
}
|
reply.PrintToStream();
|
||||||
break;
|
|
||||||
|
|
||||||
case PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR):
|
// This request is not gonna be used anymore
|
||||||
{
|
ClearWantedEvent(request);
|
||||||
struct hci_rp_read_bd_addr* readbdaddr = (struct hci_rp_read_bd_addr*)(event+1);
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
if (readbdaddr->status == BT_OK) {
|
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);
|
||||||
|
|
||||||
reply.AddData("bdaddr", B_ANY_TYPE, &readbdaddr->bdaddr, sizeof(bdaddr_t));
|
if (readbdaddr->status == BT_OK) {
|
||||||
reply.AddInt8("status", readbdaddr->status);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
printf("Sending reply ... %ld\n",request->SendReply(&reply));
|
reply.AddInt8("status", readbdaddr->status);
|
||||||
reply.PrintToStream();
|
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||||
|
reply.PrintToStream();
|
||||||
|
|
||||||
Output::Instance()->Post("Positive reply for getAddress\n", BLACKBOARD_KIT);
|
// This request is not gonna be used anymore
|
||||||
|
ClearWantedEvent(request);
|
||||||
} else {
|
}
|
||||||
reply.AddInt8("status", readbdaddr->status);
|
break;
|
||||||
request->SendReply(&reply);
|
|
||||||
Output::Instance()->Post("Negative reply for getAddress\n", BLACKBOARD_KIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This request is not gonna be used anymore
|
|
||||||
ClearWantedEvent(request);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
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));
|
||||||
|
Output::Instance()->Post("Positive reply for getDeviceClass\n", BLACKBOARD_KIT);
|
||||||
|
|
||||||
reply.AddData("devclass", B_ANY_TYPE, &classDev->dev_class, sizeof(classDev->dev_class));
|
} else {
|
||||||
reply.AddInt8("status", classDev->status);
|
Output::Instance()->Post("Negative reply for getDeviceClass\n", BLACKBOARD_KIT);
|
||||||
|
}
|
||||||
|
|
||||||
printf("Sending reply ... %ld\n",request->SendReply(&reply));
|
reply.AddInt8("status", classDev->status);
|
||||||
reply.PrintToStream();
|
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||||
|
reply.PrintToStream();
|
||||||
|
|
||||||
Output::Instance()->Post("Positive reply for getDeviceClass\n", BLACKBOARD_KIT);
|
// This request is not gonna be used anymore
|
||||||
|
ClearWantedEvent(request);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
} else {
|
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME):
|
||||||
reply.AddInt8("status", classDev->status);
|
{
|
||||||
request->SendReply(&reply);
|
struct hci_rp_read_local_name* readLocalName = (struct hci_rp_read_local_name*)(event+1);
|
||||||
Output::Instance()->Post("Negative reply for getDeviceClass\n", BLACKBOARD_KIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This request is not gonna be used anymore
|
if (readLocalName->status == BT_OK) {
|
||||||
ClearWantedEvent(request);
|
reply.AddString("friendlyname", (const char*)readLocalName->local_name );
|
||||||
}
|
Output::Instance()->Post("Positive reply for friendly name\n", BLACKBOARD_KIT);
|
||||||
break;
|
|
||||||
|
|
||||||
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME):
|
} else {
|
||||||
{
|
Output::Instance()->Post("Negative reply for friendly name\n", BLACKBOARD_KIT);
|
||||||
struct hci_rp_read_local_name* readLocalName = (struct hci_rp_read_local_name*)(event+1);
|
}
|
||||||
|
|
||||||
reply.AddInt8("status", readLocalName->status);
|
reply.AddInt8("status", readLocalName->status);
|
||||||
|
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||||
|
reply.PrintToStream();
|
||||||
|
|
||||||
if (readLocalName->status == BT_OK) {
|
// This request is not gonna be used anymore
|
||||||
|
ClearWantedEvent(request);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
reply.AddString("friendlyname", (const char*)readLocalName->local_name );
|
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_PIN_CODE_REPLY):
|
||||||
Output::Instance()->Post("Positive reply for friendly name\n", BLACKBOARD_KIT);
|
{
|
||||||
|
uint8* statusReply = (uint8*)(event+1);
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Output::Instance()->Post("Negative reply for friendly name\n", BLACKBOARD_KIT);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE):
|
|
||||||
{
|
|
||||||
uint8* statusReply = (uint8*)(event+1);
|
|
||||||
|
|
||||||
reply.AddInt8("status", *statusReply);
|
|
||||||
|
|
||||||
if (*statusReply == BT_OK) {
|
|
||||||
|
|
||||||
Output::Instance()->Post("Positive reply for scanmode\n", BLACKBOARD_KIT);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Output::Instance()->Post("Negative reply for scanmode\n", BLACKBOARD_KIT);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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_LINK_CONTROL, OCF_PIN_CODE_REPLY):
|
|
||||||
{
|
|
||||||
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
|
||||||
reply.AddInt8("status", *statusReply);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
if (*statusReply == BT_OK) {
|
reply.AddInt8("status", *statusReply);
|
||||||
|
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||||
|
reply.PrintToStream();
|
||||||
|
|
||||||
Output::Instance()->Post("Positive reply for pincode accept\n", BLACKBOARD_KIT);
|
// This request is not gonna be used anymore
|
||||||
|
ClearWantedEvent(request);
|
||||||
} else {
|
}
|
||||||
|
break;
|
||||||
Output::Instance()->Post("Negative reply for pincode accept\n", BLACKBOARD_KIT);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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_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
|
//TODO: This reply might to match the BDADDR of the outgoing message
|
||||||
// xxx:FindPetition should be expanded....
|
// xxx:FindPetition should be expanded....
|
||||||
reply.AddInt8("status", *statusReply);
|
|
||||||
|
|
||||||
if (*statusReply == BT_OK) {
|
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()->Post("Positive reply for pincode reject\n", BLACKBOARD_KIT);
|
reply.AddInt8("status", *statusReply);
|
||||||
|
printf("Sending reply ... %ld\n",request->SendReply(&reply));
|
||||||
|
reply.PrintToStream();
|
||||||
|
|
||||||
} else {
|
// This request is not gonna be used anymore
|
||||||
|
ClearWantedEvent(request);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
Output::Instance()->Post("Negative reply for pincode reject\n", BLACKBOARD_KIT);
|
// place here all CC that just replies a uint8 status
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Sending reply ... %ld\n",request->SendReply(&reply));
|
|
||||||
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_RESET):
|
||||||
case PACK_OPCODE(OGF_VENDOR_CMD, OCF_WRITE_BCM2035_BDADDR):
|
case PACK_OPCODE(OGF_VENDOR_CMD, OCF_WRITE_BCM2035_BDADDR):
|
||||||
|
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE):
|
||||||
{
|
{
|
||||||
reply.AddInt8("status", *(uint8*)(event+1));
|
reply.AddInt8("status", *(uint8*)(event+1));
|
||||||
|
|
||||||
@@ -486,81 +450,84 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Output::Instance()->Post("Command Complete not handled\n", BLACKBOARD_KIT);
|
Output::Instance()->Post("Command Complete not handled\n", BLACKBOARD_KIT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* request, int32 index) {
|
LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* request,
|
||||||
|
int32 index) {
|
||||||
|
|
||||||
int16 opcodeExpected;
|
int16 opcodeExpected;
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
|
|
||||||
Output::Instance()->Post(__FUNCTION__, BLACKBOARD_LD(GetID()));
|
|
||||||
Output::Instance()->Post("\n", BLACKBOARD_LD(GetID()));
|
|
||||||
|
|
||||||
// Handle command complete information
|
// Handle command complete information
|
||||||
request->FindInt16("opcodeExpected", index, &opcodeExpected);
|
request->FindInt16("opcodeExpected", index, &opcodeExpected);
|
||||||
|
|
||||||
|
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) for %s\n",__FUNCTION__,
|
||||||
|
event->ncmd,GetCommand(opcodeExpected));
|
||||||
|
|
||||||
if (request->IsSourceWaiting() == false)
|
if (request->IsSourceWaiting() == false)
|
||||||
Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);
|
Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);
|
||||||
|
|
||||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) for command %s\n",__FUNCTION__, event->ncmd,GetCommand(opcodeExpected));
|
switch (opcodeExpected) {
|
||||||
|
|
||||||
switch (opcodeExpected) {
|
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY):
|
||||||
|
{
|
||||||
|
reply.what = BT_MSG_INQUIRY_STARTED;
|
||||||
|
|
||||||
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY):
|
if (event->status == BT_OK) {
|
||||||
{
|
Output::Instance()->Post("Positive reply for inquiry status\n", BLACKBOARD_KIT);
|
||||||
reply.what = BT_MSG_INQUIRY_STARTED;
|
} else {
|
||||||
reply.AddInt8("status", event->status);
|
Output::Instance()->Post("Negative reply for inquiry status\n", BLACKBOARD_KIT);
|
||||||
|
}
|
||||||
|
|
||||||
if (event->status == BT_OK) {
|
reply.AddInt8("status", event->status);
|
||||||
Output::Instance()->Post("Positive reply for inquiry status\n", BLACKBOARD_KIT);
|
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||||
} else {
|
reply.PrintToStream();
|
||||||
Output::Instance()->Post("Negative reply for inquiry status\n", BLACKBOARD_KIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS,
|
||||||
reply.PrintToStream();
|
PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY));
|
||||||
|
}
|
||||||
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS, PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY));
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
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, PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST));
|
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS,
|
||||||
|
PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BMessage reply;
|
Output::Instance()->Post("Wrong Command Status for remote friendly name\n", BLACKBOARD_KIT);
|
||||||
reply.AddInt8("status", event->status);
|
|
||||||
Output::Instance()->Post("Negative reply for remote friendly name\n", BLACKBOARD_KIT);
|
reply.AddInt8("status", event->status);
|
||||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||||
ClearWantedEvent(request);
|
reply.PrintToStream();
|
||||||
}
|
|
||||||
|
ClearWantedEvent(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_ACCEPT_CONN_REQ):
|
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_ACCEPT_CONN_REQ):
|
||||||
{
|
{
|
||||||
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS, PACK_OPCODE(OGF_LINK_CONTROL, OCF_ACCEPT_CONN_REQ));
|
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS,
|
||||||
|
PACK_OPCODE(OGF_LINK_CONTROL, OCF_ACCEPT_CONN_REQ));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_REJECT_CONN_REQ):
|
case PACK_OPCODE(OGF_LINK_CONTROL, OCF_REJECT_CONN_REQ):
|
||||||
{
|
{
|
||||||
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS, PACK_OPCODE(OGF_LINK_CONTROL, OCF_REJECT_CONN_REQ));
|
ClearWantedEvent(request, HCI_EVENT_CMD_STATUS,
|
||||||
|
PACK_OPCODE(OGF_LINK_CONTROL, OCF_REJECT_CONN_REQ));
|
||||||
}
|
}
|
||||||
break;*/
|
break;*/
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Output::Instance()->Post("Command Status not handled\n", BLACKBOARD_KIT);
|
Output::Instance()->Post("Command Status not handled\n", BLACKBOARD_KIT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,11 +540,13 @@ LocalDeviceImpl::InquiryResult(uint8* numberOfResponses, BMessage* request)
|
|||||||
|
|
||||||
BMessage reply(BT_MSG_INQUIRY_DEVICE);
|
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 // skipping here the number of responses
|
reply.AddInt8("count", *numberOfResponses);
|
||||||
, (*numberOfResponses) * sizeof(struct inquiry_info) );
|
|
||||||
|
|
||||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, request->SendReply(&reply));
|
printf("%s: Sending reply ... %ld\n",__FUNCTION__, request->SendReply(&reply));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,38 +557,32 @@ 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));
|
||||||
|
|
||||||
|
ClearWantedEvent(request);
|
||||||
printf("%s: Sending reply ... %ld\n",__FUNCTION__, request->SendReply(&reply));
|
|
||||||
// (request->ReturnAddress()).SendMessage(&reply);
|
|
||||||
|
|
||||||
ClearWantedEvent(request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceImpl::RemoteNameRequestComplete(struct hci_ev_remote_name_request_complete_reply* remotename, BMessage* request)
|
LocalDeviceImpl::RemoteNameRequestComplete(
|
||||||
|
struct hci_ev_remote_name_request_complete_reply* remotename, BMessage* request)
|
||||||
{
|
{
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
|
|
||||||
|
if (remotename->status == BT_OK) {
|
||||||
|
|
||||||
|
reply.AddString("friendlyname", (const char*)remotename->remote_name );
|
||||||
|
Output::Instance()->Post("Positive reply for remote friendly name\n", BLACKBOARD_KIT);
|
||||||
|
} else {
|
||||||
|
Output::Instance()->Post("Negative reply for remote friendly name\n", BLACKBOARD_KIT);
|
||||||
|
}
|
||||||
|
|
||||||
reply.AddInt8("status", remotename->status);
|
reply.AddInt8("status", remotename->status);
|
||||||
|
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
||||||
if (remotename->status == BT_OK) {
|
reply.PrintToStream();
|
||||||
|
|
||||||
reply.AddString("friendlyname", (const char*)remotename->remote_name );
|
|
||||||
Output::Instance()->Post("Positive reply for remote friendly name\n", BLACKBOARD_KIT);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Output::Instance()->Post("Negative reply for remote friendly name\n", BLACKBOARD_KIT);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Sending reply ... %ld\n", request->SendReply(&reply));
|
|
||||||
reply.PrintToStream();
|
|
||||||
|
|
||||||
// This request is not gonna be used anymore
|
// This request is not gonna be used anymore
|
||||||
ClearWantedEvent(request);
|
ClearWantedEvent(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -629,12 +592,14 @@ LocalDeviceImpl::ConnectionRequest(struct hci_ev_conn_request* event, BMessage*
|
|||||||
size_t size;
|
size_t size;
|
||||||
void* command;
|
void* command;
|
||||||
|
|
||||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()), "Connection Incoming type %x from %s...\n", event->link_type, bdaddrUtils::ToString(event->bdaddr));
|
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
|
||||||
|
"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
|
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);
|
||||||
|
|
||||||
BMessage* newrequest = new BMessage;
|
BMessage* newrequest = new BMessage;
|
||||||
newrequest->AddInt16("eventExpected", HCI_EVENT_CMD_STATUS);
|
newrequest->AddInt16("eventExpected", HCI_EVENT_CMD_STATUS);
|
||||||
@@ -644,20 +609,20 @@ LocalDeviceImpl::ConnectionRequest(struct hci_ev_conn_request* event, BMessage*
|
|||||||
newrequest->AddInt16("eventExpected", HCI_EVENT_ROLE_CHANGE);
|
newrequest->AddInt16("eventExpected", HCI_EVENT_ROLE_CHANGE);
|
||||||
newrequest->AddInt16("eventExpected", HCI_EVENT_LINK_KEY_NOTIFY);
|
newrequest->AddInt16("eventExpected", HCI_EVENT_LINK_KEY_NOTIFY);
|
||||||
newrequest->AddInt16("eventExpected", HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE);
|
newrequest->AddInt16("eventExpected", HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE);
|
||||||
|
//newrequest->AddInt16("eventExpected", HCI_EVENT_MAX_SLOT_CHANGE);
|
||||||
|
//newrequest->AddInt16("eventExpected", HCI_EVENT_DISCONNECTION_COMPLETE);
|
||||||
|
|
||||||
AddWantedEvent(newrequest);
|
AddWantedEvent(newrequest);
|
||||||
|
|
||||||
if ((fHCIDelegate)->IssueCommand(command, size) == B_ERROR) {
|
if ((fHCIDelegate)->IssueCommand(command, size) == B_ERROR) {
|
||||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()), "Command issue error for ConnAccpq\n");
|
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
|
||||||
// remove the request
|
"Command issue error for ConnAccept\n");
|
||||||
|
// remove the request ¿?
|
||||||
}
|
} else {
|
||||||
else {
|
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
|
||||||
Output::Instance()->Postf(BLACKBOARD_LD(GetID()), "Command issue for ConnAccpq\n");
|
"Command issue for ConnAccept\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -668,13 +633,19 @@ 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(new RemoteDevice(event->bdaddr, cod));
|
ConnectionIncoming* iConnection = new ConnectionIncoming(
|
||||||
|
new RemoteDevice(event->bdaddr, cod));
|
||||||
iConnection->Show();
|
iConnection->Show();
|
||||||
printf("%s: Address %s handle=%#x type=%d encrypt=%d\n", __FUNCTION__, bdaddrUtils::ToString(event->bdaddr), event->handle,
|
|
||||||
event->link_type, event->encrypt_mode);
|
|
||||||
|
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
|
||||||
|
"%s: Address %s handle=%#x type=%d encrypt=%d\n", __FUNCTION__,
|
||||||
|
bdaddrUtils::ToString(event->bdaddr), event->handle,
|
||||||
|
event->link_type, event->encrypt_mode);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("%s: failed with status %#x\n", __FUNCTION__, event->status);
|
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),
|
||||||
|
"%s: failed with status %#x\n", __FUNCTION__, event->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -683,41 +654,59 @@ LocalDeviceImpl::ConnectionComplete(struct hci_ev_conn_complete* event, BMessage
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceImpl::DisconnectionComplete(struct hci_ev_disconnection_complete_reply* event, BMessage * request)
|
LocalDeviceImpl::DisconnectionComplete(struct hci_ev_disconnection_complete_reply* event, BMessage* request)
|
||||||
{
|
{
|
||||||
Output::Instance()->Post("Disconnected\n", BLACKBOARD_KIT);
|
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);
|
||||||
|
|
||||||
|
ClearWantedEvent(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceImpl::PinCodeRequest(struct hci_ev_pin_code_req* event, BMessage* request)
|
LocalDeviceImpl::PinCodeRequest(struct hci_ev_pin_code_req* event, BMessage* request)
|
||||||
{
|
{
|
||||||
|
|
||||||
PincodeWindow* iPincode = new PincodeWindow(event->bdaddr, GetID());
|
PincodeWindow* iPincode = new PincodeWindow(event->bdaddr, GetID());
|
||||||
iPincode->Show();
|
iPincode->Show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceImpl::RoleChange(hci_ev_role_change *event, BMessage* request, int32 index)
|
LocalDeviceImpl::RoleChange(hci_ev_role_change *event, BMessage* request, int32 index)
|
||||||
{
|
{
|
||||||
printf("%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)
|
|
||||||
{
|
|
||||||
printf("%s: Address %s type=%d\n", __FUNCTION__, bdaddrUtils::ToString(event->bdaddr), event->page_scan_rep_mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalDeviceImpl::LinkKeyNotify(hci_ev_link_key_notify *event, BMessage* request, int32 index)
|
LocalDeviceImpl::PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_change* event,
|
||||||
|
BMessage* request, int32 index)
|
||||||
{
|
{
|
||||||
|
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Address %s type=%d\n",
|
||||||
|
__FUNCTION__, bdaddrUtils::ToString(event->bdaddr), event->page_scan_rep_mode);
|
||||||
|
}
|
||||||
|
|
||||||
printf("%s: Address %s [----] type=%d\n", __FUNCTION__, bdaddrUtils::ToString(event->bdaddr), event->key_type);
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LocalDeviceImpl::LinkKeyNotify(hci_ev_link_key_notify *event,
|
||||||
|
BMessage* request, int32 index)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s: Handle=%#x, max slots=%d\n",
|
||||||
|
__FUNCTION__, event->handle, event->lmp_max_slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -732,22 +721,22 @@ LocalDeviceImpl::ProcessSimpleRequest(BMessage* request)
|
|||||||
ssize_t size;
|
ssize_t size;
|
||||||
void* command = NULL;
|
void* command = NULL;
|
||||||
|
|
||||||
if (request->FindData("raw command", B_ANY_TYPE, 0, (const void **)&command, &size) == B_OK) {
|
if (request->FindData("raw command", B_ANY_TYPE, 0,
|
||||||
|
(const void **)&command, &size) == B_OK) {
|
||||||
|
|
||||||
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) == B_ERROR) {
|
if (((HCITransportAccessor*)fHCIDelegate)->IssueCommand(command, size)
|
||||||
|
== 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("Command issue error\n", BLACKBOARD_KIT));
|
(Output::Instance()->Post("Command issue error\n", BLACKBOARD_KIT));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
(Output::Instance()->Post("No command specified for simple request\n",
|
||||||
(Output::Instance()->Post("No command specified for simple request\n", BLACKBOARD_KIT));
|
BLACKBOARD_KIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ public:
|
|||||||
void RoleChange(struct hci_ev_role_change* event, BMessage* request, int32 index);
|
void RoleChange(struct hci_ev_role_change* event, BMessage* request, int32 index);
|
||||||
void LinkKeyNotify(struct hci_ev_link_key_notify* event, BMessage* request, int32 index);
|
void LinkKeyNotify(struct hci_ev_link_key_notify* event, BMessage* request, int32 index);
|
||||||
void PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_change* event, BMessage* request, int32 index);
|
void PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_change* event, BMessage* request, int32 index);
|
||||||
|
void MaxSlotChange(struct hci_ev_max_slot_change *event, BMessage *request, int32 index);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user