mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 18:56:49 +01:00
620b8b6e4c
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30336 a95241bf-73f2-0310-859d-f6bbb57e9c96
73 lines
1.5 KiB
C++
73 lines
1.5 KiB
C++
/*
|
|
* Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
|
* All rights reserved. Distributed under the terms of the MIT License.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <bluetooth/LocalDevice.h>
|
|
#include <bluetooth/bdaddrUtils.h>
|
|
|
|
|
|
static void
|
|
DumpInfo(LocalDevice* device)
|
|
{
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
static status_t
|
|
LocalDeviceError(status_t status)
|
|
{
|
|
fprintf(stderr,"No Device/s found");
|
|
|
|
return status;
|
|
}
|
|
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
if (argc == 2) {
|
|
// device specified
|
|
LocalDevice* ld = LocalDevice::GetLocalDevice(atoi(argv[0]));
|
|
if (ld == NULL)
|
|
return LocalDeviceError(ENODEV);
|
|
|
|
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);
|
|
}
|
|
|
|
return B_OK;
|
|
|
|
} else {
|
|
fprintf(stderr,"Usage: bt_dev_info [device]\n");
|
|
return B_ERROR;
|
|
}
|
|
}
|