From c1990799c00e361eb4b93b77932433fda077c535 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Sat, 13 Dec 2008 23:47:10 +0000 Subject: [PATCH] - Show the class of device(for local and discovered ones). - Listeners do not need to inform about the LocalDevice handling to the Discovery Agent anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28810 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/bt_dev_info.cpp | 24 +++++++++++++++++------- src/bin/bt_discovery.cpp | 20 +++++++++++++------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/bin/bt_dev_info.cpp b/src/bin/bt_dev_info.cpp index 2c5aae661d..dace3cc16e 100644 --- a/src/bin/bt_dev_info.cpp +++ b/src/bin/bt_dev_info.cpp @@ -13,11 +13,22 @@ static void -DumpInfo(LocalDevice &device) +DumpInfo(LocalDevice* device) { - printf("[LocalDevice] %s\t%s\n", (device.GetFriendlyName()).String(), - bdaddrUtils::ToString(device.GetBluetoothAddress())); + printf("[LocalDevice] %s\t%s\n", (device->GetFriendlyName()).String(), + bdaddrUtils::ToString(device->GetBluetoothAddress())); + BString classString; + DeviceClass cod = device->GetDeviceClass(); + + cod.GetServiceClass(classString); + classString << " |"; + cod.GetMajorDeviceClass(classString); + classString << " |"; + cod.GetMinorDeviceClass(classString); + printf("\t\t%s: \n", classString.String()); + + printf("Discovery %ld\n", device->SetDiscoverable(3)); } static status_t @@ -32,26 +43,25 @@ LocalDeviceError(status_t status) int main(int argc, char *argv[]) { - if(argc == 2) { + if (argc == 2) { // device specified LocalDevice* ld = LocalDevice::GetLocalDevice(atoi(argv[0])); if (ld == NULL) return LocalDeviceError(ENODEV); - DumpInfo(*ld); + DumpInfo(ld); } else if (argc == 1) { // show all devices LocalDevice* ld = NULL; printf("Listing %ld Bluetooth Local Devices ...\n", LocalDevice::GetLocalDeviceCount()); - for (uint32 index = 0 ; index < LocalDevice::GetLocalDeviceCount() ; index++) { ld = LocalDevice::GetLocalDevice(); if (ld == NULL) return LocalDeviceError(ENODEV); - DumpInfo(*ld); + DumpInfo(ld); } diff --git a/src/bin/bt_discovery.cpp b/src/bin/bt_discovery.cpp index 1ceead9cd1..a0b05c7a85 100644 --- a/src/bin/bt_discovery.cpp +++ b/src/bin/bt_discovery.cpp @@ -1,8 +1,6 @@ /* * Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ #include @@ -11,27 +9,35 @@ #include #include +#include #include #include - thread_id mainThread; class simpleDiscoveryListener : public DiscoveryListener { public: -simpleDiscoveryListener(LocalDevice *device) : DiscoveryListener() +simpleDiscoveryListener() : DiscoveryListener() { - /* TODO: Should not be needed */ - SetLocalDeviceOwner(device); + } void DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod) { + BString classString; + printf("\t%s: Device %s discovered.\n",__FUNCTION__, bdaddrUtils::ToString(btDevice->GetBluetoothAddress())); + + cod.GetServiceClass(classString); + classString << " |"; + cod.GetMajorDeviceClass(classString); + classString << " |"; + cod.GetMinorDeviceClass(classString); + printf("\t\t%s: \n", classString.String()); } @@ -69,7 +75,7 @@ DumpInfo(LocalDevice* device) (device->GetFriendlyName()).String(), bdaddrUtils::ToString(device->GetBluetoothAddress())); - simpleDiscoveryListener* dListener = new simpleDiscoveryListener(device); + simpleDiscoveryListener* dListener = new simpleDiscoveryListener(); dAgent->StartInquiry(BT_GIAC, dListener);