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>
|
|
|
|
|
|
|
|
namespace Bluetooth {
|
|
|
|
|
2008-12-14 02:41:32 +03:00
|
|
|
#define UNKNOWN_CLASS_OF_DEVICE 0x00
|
|
|
|
|
|
|
|
|
2008-07-03 00:01:02 +04:00
|
|
|
class DeviceClass {
|
|
|
|
|
2008-08-03 01:15:02 +04:00
|
|
|
public:
|
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
|
|
|
|
|
|
|
DeviceClass(uint32 record)
|
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
|
|
|
DeviceClass(void)
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
2008-12-14 02:41:32 +03:00
|
|
|
this->record = 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
|
|
|
{
|
2008-12-14 02:41:32 +03:00
|
|
|
this->record = record[0]|record[1]<<8|record[2]<<16;
|
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(uint32 record)
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
2008-12-14 02:41:32 +03:00
|
|
|
this->record = record;
|
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2008-12-14 02:41:32 +03:00
|
|
|
uint GetServiceClass()
|
|
|
|
{
|
|
|
|
return (record & 0x00FFE000) >> 13;
|
2008-08-03 01:15:02 +04:00
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2008-12-14 02:41:32 +03:00
|
|
|
uint GetMajorDeviceClass()
|
|
|
|
{
|
|
|
|
return (record & 0x00001F00) >> 8;
|
|
|
|
}
|
2008-07-03 00:01:02 +04:00
|
|
|
|
2008-12-14 02:41:32 +03:00
|
|
|
uint GetMinorDeviceClass()
|
2008-08-03 01:15:02 +04:00
|
|
|
{
|
|
|
|
return (record & 0x000000FF) >> 2;
|
|
|
|
}
|
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
|
|
|
{
|
2008-12-14 02:41:32 +03:00
|
|
|
return (record == 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&);
|
|
|
|
|
2008-08-03 01:15:02 +04:00
|
|
|
private:
|
2008-12-14 02:41:32 +03:00
|
|
|
uint32 record;
|
|
|
|
|
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
|