btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / bin / bt_dev_info.cpp
blob789832def2007abaa7f449e7ae6f2c946eb55550
1 /*
2 * Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
6 #include <stdio.h>
7 #include <stdlib.h>
9 #include <bluetooth/LocalDevice.h>
10 #include <bluetooth/bdaddrUtils.h>
13 static void
14 DumpInfo(LocalDevice* device)
16 printf("[LocalDevice] %s\t%s\n", (device->GetFriendlyName()).String(),
17 bdaddrUtils::ToString(device->GetBluetoothAddress()));
19 BString classString;
20 DeviceClass cod = device->GetDeviceClass();
22 cod.GetServiceClass(classString);
23 classString << " |";
24 cod.GetMajorDeviceClass(classString);
25 classString << " |";
26 cod.GetMinorDeviceClass(classString);
27 printf("\t\t%s: \n", classString.String());
32 static status_t
33 LocalDeviceError(status_t status)
35 fprintf(stderr,"No Device/s found");
37 return status;
41 int
42 main(int argc, char *argv[])
44 if (argc == 2) {
45 // device specified
46 LocalDevice* ld = LocalDevice::GetLocalDevice(atoi(argv[0]));
47 if (ld == NULL)
48 return LocalDeviceError(ENODEV);
50 DumpInfo(ld);
52 } else if (argc == 1) {
53 // show all devices
54 LocalDevice* ld = NULL;
56 printf("Listing %ld Bluetooth Local Devices ...\n",
57 LocalDevice::GetLocalDeviceCount());
58 for (uint32 index = 0 ; index < LocalDevice::GetLocalDeviceCount() ; index++) {
60 ld = LocalDevice::GetLocalDevice();
61 if (ld == NULL)
62 return LocalDeviceError(ENODEV);
63 DumpInfo(ld);
66 return B_OK;
68 } else {
69 fprintf(stderr,"Usage: bt_dev_info [device]\n");
70 return B_ERROR;