Code & text output cleaning

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24317 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2008-03-09 00:04:16 +00:00
parent d1893d6468
commit 009fac9906
11 changed files with 88 additions and 114 deletions
+1 -13
View File
@@ -63,19 +63,7 @@ BPortNot::loop()
Output::Instance()->Post("Wrong type frame code", BLACKBOARD_GENERAL);
continue;
}
#if 0
for (int i=0 ; i<ssize ; i++ ) {
printf("%x:",((uint8*)hdr)[i]);
}
printf("$\n");
for (int i=0 ; i<ssize ; i++) {
printf("%c",((uint8*)hdr)[i]);
}
printf("$\n");
#endif
ld = ourapp->LocateLocalDeviceImpl(GET_PORTCODE_HID(code));
if (ld == NULL) {
Output::Instance()->Post("LocalDevice could not be fetched", BLACKBOARD_EVENTS);
+5 -54
View File
@@ -158,7 +158,7 @@ void BluetoothServer::MessageReceived(BMessage *message)
break;
/* Handle if the bluetooth preferences is running */
/* Handle if the bluetooth preferences is running?? */
case B_SOME_APP_LAUNCHED:
{
const char *signature;
@@ -178,7 +178,8 @@ void BluetoothServer::MessageReceived(BMessage *message)
break;
}
/* Can we reply right now? */
// Can we reply right now?
// TOD: review this condition
if (status != B_WOULD_BLOCK) {
reply.AddInt32("status", status);
message->SendReply(&reply);
@@ -391,50 +392,6 @@ BluetoothServer::sdp_server_Thread(void* data)
#if 0
void BluetoothServer::DevicesWatching(void) {
BDirectory* hdoses;
BEntry entrada;
BPath path;
//status_t err;
int fd1 = -1;
// only cheks the actual driver which we have
hdoses = new BDirectory("/dev/bus/bluetooth/h2/");
// hdoses = new BDirectory("/dev/bus/bluetooth/h3/...");
// hdoses = new BDirectory("/dev/bus/bluetooth/h4/...");
Output::Instance()->Post("Exploring present devices ...\n",1);
while (hdoses->GetNextEntry(&entrada,true) == B_OK) {
Output::Instance()->Post((char*)path.Path(), 1);
entrada.GetPath(&path);
if (entrada.IsDirectory()) {
Output::Instance()->Post((char*)path.Path(),1);
BDirectory* driver_directory = new BDirectory(path.Path());
BEntry driver_entry;
syslog(LOG_ALERT, "Bluetooth driver %s\n",path.Path());
fprintf(stderr, "Bluetooth driver %s\n",path.Path());
while (driver_directory->GetNextEntry(&driver_entry,true) == B_OK) {
Output::Instance()->Post((char*)path.Path(),1);
driver_entry.GetPath(&path);
fd1 = open(path.Path(), O_RDWR);
// TODO: Watching all folders under and set some kind of internal structure that hold all
// LocalDevices.
// devloop = new DeviceLooper();
// devloop->StartMonitoringDevice("bus/bluetooth/h2");
if (fd1 < 0) {
syslog(LOG_ALERT,BT "Error opening device %s\n",path.Path());
fprintf(stderr, "Error opening device %s\n",path.Path());
}
else
{
struct {
size_t size;
struct hci_command_header header;
@@ -468,7 +425,7 @@ void BluetoothServer::DevicesWatching(void) {
cm1.header.clen = 0;
ioctl(fd1, ISSUE_BT_COMMAND, &cm1, sizeof(cm1));
/*cm1.size = sizeof(struct hci_command_header);
cm1.size = sizeof(struct hci_command_header);
cm1.header.opcode = B_HOST_TO_LENDIAN_INT16(hci_opcode_pack(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME));
cm1.header.clen = 0;
ioctl(fd1, ISSUE_BT_COMMAND, &cm1, sizeof(cm1));
@@ -487,6 +444,7 @@ void BluetoothServer::DevicesWatching(void) {
cm2.body.num_rsp = 8;
cm2.header.clen = 5;
ioctl(fd1, ISSUE_BT_COMMAND, &cm2, sizeof(cm1));
snooze(60*1000*1000);*/
cm3.size = sizeof(struct hci_command_header)+sizeof(struct hci_remote_name_request);
cm3.header.opcode = B_HOST_TO_LENDIAN_INT16(hci_opcode_pack(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST));
@@ -518,14 +476,7 @@ void BluetoothServer::DevicesWatching(void) {
ioctl(fd1, ISSUE_BT_COMMAND, &cm4, sizeof(cm4));
*/
}
}
}
}
syslog(LOG_ALERT,BT "All devices registered\n");
fprintf(stderr, "Waiting with opened devices\n");
}
#endif
void
+15 -3
View File
@@ -47,7 +47,11 @@ inline void* buildCommand(uint8 ogf, uint8 ocf, void** param, size_t psize, size
}
/* CONTROL BASEBAND */
#if 0
#pragma mark - CONTROL BASEBAND -
#endif
void* buildReset(size_t* outsize)
{
return buildCommand(OGF_CONTROL_BASEBAND, OCF_RESET, NULL, 0, outsize);
@@ -60,7 +64,11 @@ void* buildReadLocalName(size_t* outsize)
}
/* LINK CONTROL */
#if 0
#pragma mark - LINK CONTROL -
#endif
void* buildRemoteNameRequest(bdaddr_t bdaddr,uint8 pscan_rep_mode, uint16 clock_offset, size_t* outsize)
{
@@ -96,7 +104,11 @@ void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize)
}
/* OGF_INFORMATIONAL_PARAM */
#if 0
#pragma mark - INFORMATIONAL_PARAM -
#endif
void* buildReadBufferSize(size_t* outsize)
{
return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE, NULL, 0, outsize);
+1 -1
View File
@@ -22,4 +22,4 @@ void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize);
void* buildReadBufferSize(size_t* outsize);
void* buildReadBdAddr(size_t* outsize);
#endif
#endif
@@ -1,3 +1,10 @@
/*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#include "HCIControllerAccessor.h"
@@ -1,4 +1,11 @@
/* */
/*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#ifndef _HCICONTROLLER_ACCESSOR_H_
#define _HCICONTROLLER_ACCESSOR_H_
+9 -3
View File
@@ -1,3 +1,10 @@
/*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#ifndef _HCIDELEGATE_H_
#define _HCIDELEGATE_H_
@@ -20,14 +27,13 @@ class HCIDelegate {
status_t status;
fFD = open (path->Path(), O_RDWR);
printf("## fdesc %d\n", fFD);
if (fFD > 0) {
// find out which ID was assigned
status = ioctl(fFD, GET_HCI_ID, &fHID, 0);
printf("## id fdesc %ld ### %ld\n", fHID, status);
printf("%s: hid retrieved %ld status=%ld\n", __FUNCTION__, fHID, status);
}
else {
printf("%s: Device driver could not be opened %ld\n", __FUNCTION__, fHID);
fHID = B_ERROR;
}
+10 -3
View File
@@ -1,3 +1,10 @@
/*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#include <String.h>
@@ -17,11 +24,11 @@ HCITransportAccessor::IssueCommand(raw_command rc, size_t size)
if (GetID() < 0 || fFD < 0)
return B_ERROR;
printf("Command going: len = %d\n", size);
for (int16 index = 0 ; index < size; index++ ) {
printf("### Command going: len = %ld\n", size);
for (uint16 index = 0 ; index < size; index++ ) {
printf("%x:",((uint8*)rc)[index]);
}
printf("\n");
printf("### \n");
return ioctl(fFD, ISSUE_BT_COMMAND, rc, size);
+7 -1
View File
@@ -1,4 +1,10 @@
/* */
/*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#ifndef _HCITRANSPORT_ACCESSOR_H_
#define _HCITRANSPORT_ACCESSOR_H_
+3 -2
View File
@@ -110,9 +110,10 @@ LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event = 0, uint16 opc
}
bail: */
fEventsWanted.Unlock();
fEventsWanted.RemoveMessage(msg);
fEventsWanted.Unlock();
}
+22 -33
View File
@@ -15,9 +15,14 @@
#include <bluetooth/bluetooth_error.h>
#include <bluetooth/HCI/btHCI_event.h>
#include <stdio.h>
#if 0
#pragma mark - Class methods -
#endif
// Factory methods
LocalDeviceImpl*
LocalDeviceImpl::CreateControllerAccessor(BPath* path)
@@ -49,27 +54,33 @@ LocalDeviceImpl::LocalDeviceImpl(HCIDelegate* hd) : LocalDeviceHandler(hd)
}
#if 0
#pragma mark - Class methods -
#pragma mark - Event handling methods -
#endif
void
LocalDeviceImpl::HandleEvent(struct hci_event_header* event)
{
// Check if it was a non requested events
printf("### Event comming: len = %d\n", event->elen);
for (int16 index = 0 ; index < event->elen + 2; index++ ) {
printf("%x:",((uint8*)event)[index]);
}
printf("### \n");
// Events here might have not been initated by us
switch (event->ecode) {
case HCI_EVENT_HARDWARE_ERROR:
//HardwareError(event);
return;
case HCI_EVENT_CONN_REQUEST:
break;
default:
// lets go on
break;
}
printf("Event comming: len = %d\n", event->elen);
for (int16 index = 0 ; index < event->elen + 2; index++ ) {
printf("%x:",((uint8*)event)[index]);
}
printf("\n");
BMessage* request = NULL;
@@ -101,10 +112,7 @@ printf("\n");
case HCI_EVENT_CONN_COMPLETE:
break;
case HCI_EVENT_CONN_REQUEST:
break;
case HCI_EVENT_DISCONNECTION_COMPLETE:
break;
@@ -216,15 +224,9 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, BMessage* re
// Handle command complete information
request->FindInt16("opcodeExpected", 0 /*REVIEW!*/, &opcodeExpected);
printf("Command complete ...%p\n",event);
for (int16 index = 0 ; index < 10; index++ ) {
printf("%x:",((uint8*)event)[index]);
}
printf("\n");
if (request->IsSourceWaiting() == false)
Output::Instance()->Post("nobody waiting\n", BLACKBOARD_KIT);
Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);
switch (opcodeExpected) {
@@ -232,14 +234,7 @@ printf("\n");
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);
printf("read bdaddr ...%p\n", readbdaddr);
for (int16 index = 0 ; index < 10; index++ ) {
printf("%x:",((uint8*)readbdaddr)[index]);
}
printf("\n");
if (readbdaddr->status == BT_OK) {
@@ -266,12 +261,6 @@ printf("\n");
{
struct hci_rp_read_local_name* readLocalName = (struct hci_rp_read_local_name*)(event+1);
printf("read bdaddr ...%p\n", readLocalName);
for (int16 index = 0 ; index < 10; index++ ) {
printf("%x:",((uint8*)readLocalName)[index]);
}
printf("\n");
reply.AddInt8("status", readLocalName->status);
if (readLocalName->status == BT_OK) {