Open Lighting Architecture  Latest Git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
ola::rdm::UID Class Reference
RDM » UID

Detailed Description

Represents a RDM UID.

UIDs are 6 bytes, the first two bytes are the manufacturer code and the last 4 bytes are the device id. UIDs are written as:

XXXX:YYYYYYYY

Public Types

enum  { LENGTH = 6 }
 
enum  { UID_SIZE = LENGTH }
 

Public Member Functions

 UID (uint16_t esta_id, uint32_t device_id)
 Constructs a new UID. More...
 
 UID (uint64_t uid)
 Constructs a new UID from a uint64_t. More...
 
 UID (const UID &uid)
 Copy constructor. More...
 
 UID (const uint8_t *data)
 Construct a new UID from binary data. More...
 
UIDoperator= (const UID &other)
 Assignment operator.
 
bool operator== (const UID &other) const
 Equality operator. More...
 
bool operator!= (const UID &other) const
 Inequality operator. More...
 
bool operator> (const UID &other) const
 Greater than. More...
 
bool operator< (const UID &other) const
 Less than. More...
 
bool operator>= (const UID &other) const
 Greater than or equal to. More...
 
bool operator<= (const UID &other) const
 Less than or equal to. More...
 
uint16_t ManufacturerId () const
 The manufacturer ID for this UID. More...
 
uint32_t DeviceId () const
 The device ID for this UID. More...
 
bool IsBroadcast () const
 Check if this UID is a broadcast or vendorcast UID. More...
 
bool DirectedToUID (const UID &uid) const
 Check if this UID matches against another. More...
 
uint64_t ToUInt64 () const
 Convert a UID to a uint64_t. More...
 
std::string ToString () const
 Convert a UID to a human readable string. More...
 
bool Pack (uint8_t *buffer, unsigned int length) const
 Write the binary representation of the UID to memory. More...
 

Static Public Member Functions

static UID AllDevices ()
 Returns a UID that matches all devices (ffff:ffffffff). More...
 
static UID VendorcastAddress (uint16_t esta_id)
 Returns a UID that matches all devices for a particular manufacturer. More...
 
static UID VendorcastAddress (UID uid)
 Returns a UID that matches all devices for a particular manufacturer. More...
 
static UIDFromString (const std::string &uid)
 Return a new UID from a string. More...
 

Static Public Attributes

static const uint16_t ALL_MANUFACTURERS = 0xffff
 The value for the 'all manufacturers' id.
 
static const uint32_t ALL_DEVICES = 0xffffffff
 The value for the 'all devices' id.
 

Friends

std::ostream & operator<< (std::ostream &out, const UID &uid)
 A helper function to write a UID to an ostream. More...
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

The size of a UID.

Enumerator
UID_SIZE 

The size of a UID in binary form

Constructor & Destructor Documentation

◆ UID() [1/4]

ola::rdm::UID::UID ( uint16_t  esta_id,
uint32_t  device_id 
)
inline

Constructs a new UID.

Parameters
esta_idthe ESTA (manufacturer ID).
device_idthe device ID.

◆ UID() [2/4]

ola::rdm::UID::UID ( uint64_t  uid)
inlineexplicit

Constructs a new UID from a uint64_t.

Parameters
uida uint64_t in the form 0x0000XXXXYYYYYYYY.

◆ UID() [3/4]

ola::rdm::UID::UID ( const UID uid)
inline

Copy constructor.

Parameters
uidthe UID to copy.

◆ UID() [4/4]

ola::rdm::UID::UID ( const uint8_t *  data)
inlineexplicit

Construct a new UID from binary data.

Parameters
dataa pointer to the memory containing the UID data. The data should be most significant byte first.

Member Function Documentation

◆ AllDevices()

static UID ola::rdm::UID::AllDevices ( )
inlinestatic

Returns a UID that matches all devices (ffff:ffffffff).

Returns
a UID(0xffff, 0xffffffff).

◆ DeviceId()

uint32_t ola::rdm::UID::DeviceId ( ) const
inline

The device ID for this UID.

Returns
the device id for this UID.

◆ DirectedToUID()

bool ola::rdm::UID::DirectedToUID ( const UID uid) const
inline

Check if this UID matches against another.

Parameters
uidthe UID to check against
Returns
true if the UIDs are equal or if this UID is a broadcast UID and the uid argument falls within the broadcast range.

This is useful to determine if a responder should reply to a message.

Example
UID uid(0x7a70, 1);
uid.DirectedToUID(uid); // always true.
UID broadcast_uid(UID::AllDevices());
broadcast_uid.DirectedToUID(uid); // true
UID vendorcast_uid(UID::VendorcastAddress(0x7a70));
vendorcast_uid.DirectedToUID(uid); // true
UID other_vendorcast_uid(UID::VendorcastAddress(0x0808));
other_vendorcast_uid.DirectedToUID(uid); // false

◆ FromString()

UID * ola::rdm::UID::FromString ( const std::string &  uid)
static

Return a new UID from a string.

Parameters
uidthe UID as a string i.e. XXXX:YYYYYYYY.
Returns
a new UID object, or NULL if the string is not a valid UID. Ownership of the new UID object is transferred to the caller.

◆ IsBroadcast()

bool ola::rdm::UID::IsBroadcast ( ) const
inline

Check if this UID is a broadcast or vendorcast UID.

Returns
true if the device id is 0xffffffff.

◆ ManufacturerId()

uint16_t ola::rdm::UID::ManufacturerId ( ) const
inline

The manufacturer ID for this UID.

Returns
the manufacturer id for this UID.

◆ operator!=()

bool ola::rdm::UID::operator!= ( const UID other) const
inline

Inequality operator.

Parameters
otherthe UID to compare to.

◆ operator<()

bool ola::rdm::UID::operator< ( const UID other) const
inline

Less than.

Parameters
otherthe UID to compare to.

◆ operator<=()

bool ola::rdm::UID::operator<= ( const UID other) const
inline

Less than or equal to.

Parameters
otherthe UID to compare to.

◆ operator==()

bool ola::rdm::UID::operator== ( const UID other) const
inline

Equality operator.

Parameters
otherthe UID to compare to.

◆ operator>()

bool ola::rdm::UID::operator> ( const UID other) const
inline

Greater than.

Parameters
otherthe UID to compare to.

◆ operator>=()

bool ola::rdm::UID::operator>= ( const UID other) const
inline

Greater than or equal to.

Parameters
otherthe UID to compare to.

◆ Pack()

bool ola::rdm::UID::Pack ( uint8_t *  buffer,
unsigned int  length 
) const
inline

Write the binary representation of the UID to memory.

Parameters
buffera pointer to memory to write the UID to
lengththe size of the memory block, should be at least UID_SIZE.
Returns
true if length was >= UID_SIZE, false otherwise.

◆ ToString()

std::string ola::rdm::UID::ToString ( ) const
inline

Convert a UID to a human readable string.

Returns
a string in the form XXXX:YYYYYYYY.

◆ ToUInt64()

uint64_t ola::rdm::UID::ToUInt64 ( ) const
inline

Convert a UID to a uint64_t.

Returns
a uint64_t in the form 0x0000XXXXYYYYYYYY.

◆ VendorcastAddress() [1/2]

static UID ola::rdm::UID::VendorcastAddress ( uint16_t  esta_id)
inlinestatic

Returns a UID that matches all devices for a particular manufacturer.

Parameters
esta_idthe manufacturer id of the devices to match.
Returns
a UID(X, 0xffffffff).

◆ VendorcastAddress() [2/2]

static UID ola::rdm::UID::VendorcastAddress ( UID  uid)
inlinestatic

Returns a UID that matches all devices for a particular manufacturer.

Parameters
uida UID whose manufacturer id you want to match.
Returns
a UID(X, 0xffffffff).

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const UID uid 
)
friend

A helper function to write a UID to an ostream.

Parameters
outthe ostream
uidthe UID to write.

The documentation for this class was generated from the following files: