2008-07-03 00:01:02 +04:00
|
|
|
/*
|
|
|
|
* 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>
|
2009-04-25 22:40:00 +04:00
|
|
|
#include <View.h>
|
2008-07-03 00:01:02 +04:00
|
|
|
|
|
|
|
namespace Bluetooth {
|
|
|
|
|
2009-07-10 18:19:17 +04:00
|
|
|
#define UNKNOWN_CLASS_OF_DEVICE 0x000000
|
2008-12-14 02:41:32 +03:00
|
|
|
|
2008-07-03 00:01:02 +04:00
|
|
|
class DeviceClass {
|
|
|
|
|
2008-08-03 01:15:02 +04:00
|
|
|
public:
|
2009-04-25 22:40:00 +04:00
|
|
|
|
|
|
|
static const uint8 PixelsForIcon = 32;
|
|
|
|
static const uint8 IconInsets = 5;
|
|
|
|
|
2008-12-14 02:41:32 +03:00
|
|
|
DeviceClass(uint8 record[3])
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
2008-12-14 02:41:32 +03:00
|
|
|
SetRecord(record);
|
2008-08-03 01:15:02 +04:00
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2008-12-14 02:41:32 +03:00
|
|
|
|
2009-07-10 18:19:17 +04:00
|
|
|
DeviceClass(uint8 major, uint8 minor, uint16 service)
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
2009-07-10 18:19:17 +04:00
|
|
|
SetRecord(major, minor, service);
|
2008-08-03 01:15:02 +04:00
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
|
|
|
|
2008-12-14 02:41:32 +03:00
|
|
|
DeviceClass(void)
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
2009-07-10 18:19:17 +04:00
|
|
|
fRecord = UNKNOWN_CLASS_OF_DEVICE;
|
2008-08-03 01:15:02 +04:00
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2008-12-14 02:41:32 +03:00
|
|
|
void SetRecord(uint8 record[3])
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
2009-07-10 18:19:17 +04:00
|
|
|
fRecord = record[0]|record[1]<<8|record[2]<<16;
|
2008-08-03 01:15:02 +04:00
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2009-07-10 18:19:17 +04:00
|
|
|
void SetRecord(uint8 major, uint8 minor, uint16 service)
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
2009-07-10 18:19:17 +04:00
|
|
|
fRecord = (minor & 0x3F) << 2;
|
|
|
|
fRecord |= (major & 0x1F) << 8;
|
|
|
|
fRecord |= (service & 0x7FF) << 13;
|
2008-12-14 02:41:32 +03:00
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2009-07-10 18:19:17 +04:00
|
|
|
|
|
|
|
uint16 ServiceClass()
|
2008-12-14 02:41:32 +03:00
|
|
|
{
|
2009-07-10 18:19:17 +04:00
|
|
|
return (fRecord & 0x00FFE000) >> 13;
|
2008-08-03 01:15:02 +04:00
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2009-07-10 18:19:17 +04:00
|
|
|
uint8 MajorDeviceClass()
|
2008-12-14 02:41:32 +03:00
|
|
|
{
|
2009-07-10 18:19:17 +04:00
|
|
|
return (fRecord & 0x00001F00) >> 8;
|
2008-12-14 02:41:32 +03:00
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2009-07-10 18:19:17 +04:00
|
|
|
uint8 MinorDeviceClass()
|
|
|
|
{
|
|
|
|
return (fRecord & 0x000000FF) >> 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 Record()
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
2009-07-10 18:19:17 +04:00
|
|
|
return fRecord;
|
2008-08-03 01:15:02 +04:00
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2008-12-14 02:41:32 +03:00
|
|
|
bool IsUnknownDeviceClass()
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
2009-07-10 18:19:17 +04:00
|
|
|
return (fRecord == UNKNOWN_CLASS_OF_DEVICE);
|
2008-08-03 01:15:02 +04:00
|
|
|
}
|
2008-12-14 02:41:32 +03:00
|
|
|
|
|
|
|
void GetServiceClass(BString&);
|
|
|
|
void GetMajorDeviceClass(BString&);
|
|
|
|
void GetMinorDeviceClass(BString&);
|
2008-12-14 19:22:22 +03:00
|
|
|
|
|
|
|
void DumpDeviceClass(BString&);
|
2009-04-25 22:40:00 +04:00
|
|
|
|
|
|
|
void Draw(BView* view, const BPoint& point);
|
2008-12-14 19:22:22 +03:00
|
|
|
|
2008-08-03 01:15:02 +04:00
|
|
|
private:
|
2009-07-10 18:19:17 +04:00
|
|
|
uint32 fRecord;
|
2008-12-14 02:41:32 +03:00
|
|
|
|
2008-07-03 00:01:02 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef _BT_USE_EXPLICIT_NAMESPACE
|
|
|
|
using Bluetooth::DeviceClass;
|
|
|
|
#endif
|
|
|
|
|
2008-08-03 01:15:02 +04:00
|
|
|
#endif // _DEVICE_CLASS_H
|