-
Notifications
You must be signed in to change notification settings - Fork 15
Using libHexabus (0.6.0 or later)
Since every interaction in and with a Hexabus network hinges on the packets, packet handling will be discussed first.
Valid Hexabus packets are represented in a class hierarchy.
Every valid Hexabus packet on the wire has a representation in this class hierarchy, with the obvious equivalences of hexabus packet type identifiers and classes in this hierarchy. Packets are visitable, and a visitor interface for all valid packet types is provided, as will be explained in greater detail lateron. All classes live in the namespace hexabus
, which will be elided for brevity.
Base class for all packets in libhexabus. Provides two accessors: uint8_t type()
, which returns the type code of the packet on the network, and uint8_t flags()
, which contains the flags of the packet. Provides the abstract bast void accept(PacketVisitor&)
, making all packets visitable.
Represents an error packet (packet type HXB_PTYPE_ERROR). Provides one extra accessor: uint8_t code()
, which contains the error code received with the packet.
Provides a constructor ErrorPacket(uint8_t code, uint8_t flags = 0)
.
Base class for all packets with EID information. Provides one extra accessor: uint32_t eid()
, which contains the EID sent with the packet.
Represents a direct query (packet type HXB_PTYPE_QUERY).
Provides a constructor QueryPacket(uint32_t eid, uint8_t flags = 0)
.
Represents an endpoint query (packet type HXB_PTYPE_EPQUERY).
Provides a constructor EndpointQueryPacket(uint32_t eid, uint8_t flags = 0)
.
Represents a packet with contents of some specified type. Provides one extra accessor: uint8_t datatype()
, which contains the hexabus datatype identifier. This value can be any of the valid HXB_DTYPE_*
values.
Represents a packet that contains a value. Provides on extra accessor: TValue value()
, which contains the value of the packet. Valid template parameters for TValue
, with the equivalent hexabus datatype identifiers, are:
Type | Hexabus type code | Notes |
bool | HXB_DTYPE_BOOL | |
uint8_t | HXB_DTYPE_UINT8 | |
uint32_t | HXB_DTYPE_UINT32 | |
float | HXB_DTYPE_FLOAT | |
boost::posix_time::ptime | HXB_DTYPE_DATETIME | |
boost::posix_time::time_duration | HXB_DTYPE_TIMESTAMP | |
std::string | HXB_DTYPE_128STRING | Strings longer than 127 characters will be rejected |
std::vector<char> | HXB_DTYPE_66BYTES | Vectors longer than 66 bytes will be rejected, shorter vector will be zero-padded |
Please note that this class cannot be instantiated with parameters of TValue not listed above. Attempting to instantiate anyway will result in a compile-time assertion.
Represents an info packet (packet type HXB_PTYPE_INFO).
Valid instantiatons (as defined by ValuePacket) provide a constructor InfoPacket(uint32_t eid, const TValue& value, uint8_t flags = 0)
.
Represents a write packet (packet type HXB_PTYPE_WRITE).
Valid instantiatons (as defined by ValuePacket) provide a constructor WritePacket(uint32_t eid, const TValue& value, uint8_t flags = 0)
.
Represents an endpoint info packet (packet type HXB_PTYPE_EPINFO). Note that, according to the hexabus packet format, the datatype
member of this class need not correlate with the actual value
. In fact, the datatype
member contains the data type of the endpoint, while value
contains a textual description of the endpoint.
Provides a constructor EndpointInfoPacket(uint32_t eid, uint8_t datatype, const std::string& value, uint8_t flags = 0)
.