- 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
This commit is contained in:
+17
-7
@@ -13,11 +13,22 @@
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DumpInfo(LocalDevice &device)
|
DumpInfo(LocalDevice* device)
|
||||||
{
|
{
|
||||||
printf("[LocalDevice] %s\t%s\n", (device.GetFriendlyName()).String(),
|
printf("[LocalDevice] %s\t%s\n", (device->GetFriendlyName()).String(),
|
||||||
bdaddrUtils::ToString(device.GetBluetoothAddress()));
|
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
|
static status_t
|
||||||
@@ -32,26 +43,25 @@ LocalDeviceError(status_t status)
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if(argc == 2) {
|
if (argc == 2) {
|
||||||
// device specified
|
// device specified
|
||||||
LocalDevice* ld = LocalDevice::GetLocalDevice(atoi(argv[0]));
|
LocalDevice* ld = LocalDevice::GetLocalDevice(atoi(argv[0]));
|
||||||
if (ld == NULL)
|
if (ld == NULL)
|
||||||
return LocalDeviceError(ENODEV);
|
return LocalDeviceError(ENODEV);
|
||||||
|
|
||||||
DumpInfo(*ld);
|
DumpInfo(ld);
|
||||||
|
|
||||||
} else if (argc == 1) {
|
} else if (argc == 1) {
|
||||||
// show all devices
|
// show all devices
|
||||||
LocalDevice* ld = NULL;
|
LocalDevice* ld = NULL;
|
||||||
|
|
||||||
printf("Listing %ld Bluetooth Local Devices ...\n", LocalDevice::GetLocalDeviceCount());
|
printf("Listing %ld Bluetooth Local Devices ...\n", LocalDevice::GetLocalDeviceCount());
|
||||||
|
|
||||||
for (uint32 index = 0 ; index < LocalDevice::GetLocalDeviceCount() ; index++) {
|
for (uint32 index = 0 ; index < LocalDevice::GetLocalDeviceCount() ; index++) {
|
||||||
|
|
||||||
ld = LocalDevice::GetLocalDevice();
|
ld = LocalDevice::GetLocalDevice();
|
||||||
if (ld == NULL)
|
if (ld == NULL)
|
||||||
return LocalDeviceError(ENODEV);
|
return LocalDeviceError(ENODEV);
|
||||||
DumpInfo(*ld);
|
DumpInfo(ld);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
* Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_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 <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -11,27 +9,35 @@
|
|||||||
#include <bluetooth/LocalDevice.h>
|
#include <bluetooth/LocalDevice.h>
|
||||||
#include <bluetooth/bdaddrUtils.h>
|
#include <bluetooth/bdaddrUtils.h>
|
||||||
|
|
||||||
|
#include <bluetooth/DeviceClass.h>
|
||||||
#include <bluetooth/DiscoveryAgent.h>
|
#include <bluetooth/DiscoveryAgent.h>
|
||||||
#include <bluetooth/DiscoveryListener.h>
|
#include <bluetooth/DiscoveryListener.h>
|
||||||
|
|
||||||
|
|
||||||
thread_id mainThread;
|
thread_id mainThread;
|
||||||
|
|
||||||
class simpleDiscoveryListener : public DiscoveryListener {
|
class simpleDiscoveryListener : public DiscoveryListener {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
simpleDiscoveryListener(LocalDevice *device) : DiscoveryListener()
|
simpleDiscoveryListener() : DiscoveryListener()
|
||||||
{
|
{
|
||||||
/* TODO: Should not be needed */
|
|
||||||
SetLocalDeviceOwner(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod)
|
DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod)
|
||||||
{
|
{
|
||||||
|
BString classString;
|
||||||
|
|
||||||
printf("\t%s: Device %s discovered.\n",__FUNCTION__, bdaddrUtils::ToString(btDevice->GetBluetoothAddress()));
|
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(),
|
(device->GetFriendlyName()).String(),
|
||||||
bdaddrUtils::ToString(device->GetBluetoothAddress()));
|
bdaddrUtils::ToString(device->GetBluetoothAddress()));
|
||||||
|
|
||||||
simpleDiscoveryListener* dListener = new simpleDiscoveryListener(device);
|
simpleDiscoveryListener* dListener = new simpleDiscoveryListener();
|
||||||
|
|
||||||
dAgent->StartInquiry(BT_GIAC, dListener);
|
dAgent->StartInquiry(BT_GIAC, dListener);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user