haiku/headers/os/bluetooth/DeviceClass.h
Oliver Ruiz Dorantes 515e878c43 Add method to dump all DeviceClass information in one single string
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28814 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-12-14 16:22:22 +00:00

83 lines
1.2 KiB
C++

/*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _DEVICE_CLASS_H
#define _DEVICE_CLASS_H
#include <String.h>
namespace Bluetooth {
#define UNKNOWN_CLASS_OF_DEVICE 0x00
class DeviceClass {
public:
DeviceClass(uint8 record[3])
{
SetRecord(record);
}
DeviceClass(uint32 record)
{
SetRecord(record);
}
DeviceClass(void)
{
this->record = UNKNOWN_CLASS_OF_DEVICE;
}
void SetRecord(uint8 record[3])
{
this->record = record[0]|record[1]<<8|record[2]<<16;
}
void SetRecord(uint32 record)
{
this->record = record;
}
uint GetServiceClass()
{
return (record & 0x00FFE000) >> 13;
}
uint GetMajorDeviceClass()
{
return (record & 0x00001F00) >> 8;
}
uint GetMinorDeviceClass()
{
return (record & 0x000000FF) >> 2;
}
bool IsUnknownDeviceClass()
{
return (record == UNKNOWN_CLASS_OF_DEVICE);
}
void GetServiceClass(BString&);
void GetMajorDeviceClass(BString&);
void GetMinorDeviceClass(BString&);
void DumpDeviceClass(BString&);
private:
uint32 record;
};
}
#ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::DeviceClass;
#endif
#endif // _DEVICE_CLASS_H