Entity Class

class EntityClass

EntityClass: The EntityClass is the base class for interacting with BrainStem UEI entities. All BrainStem UEI classes inherit from EntityClass. Advanced users may use EntityClass to extend BrainStem functionality specific to their needs.

Subclassed by Acroname::BrainStem::AnalogClass, Acroname::BrainStem::AppClass, Acroname::BrainStem::ClockClass, Acroname::BrainStem::DigitalClass, Acroname::BrainStem::EqualizerClass, Acroname::BrainStem::I2CClass, Acroname::BrainStem::MuxClass, Acroname::BrainStem::PointerClass, Acroname::BrainStem::PortClass, Acroname::BrainStem::PowerDeliveryClass, Acroname::BrainStem::RailClass, Acroname::BrainStem::RCServoClass, Acroname::BrainStem::RelayClass, Acroname::BrainStem::SignalClass, Acroname::BrainStem::StoreClass, Acroname::BrainStem::SystemClass, Acroname::BrainStem::TemperatureClass, Acroname::BrainStem::TimerClass, Acroname::BrainStem::UARTClass, Acroname::BrainStem::USBClass, Acroname::BrainStem::USBSystemClass

Public Functions

EntityClass(void)

Constructor.

virtual ~EntityClass(void)

Destructor.

void init(Module *pModule, const uint8_t command, const uint8_t index)

init.

Initialize the entity class.

Parameters:
  • pModule – The BrainStem module object.

  • command – The command of the UEI.

  • index – The index of the UEI entity.

aErr callUEI(const uint8_t option)

A callUEI is a setUEI that has no data length.

Parameters:

option – An option for the UEI.

Returns:

Returns common entity return values

aErr setUEI8(const uint8_t option, const uint8_t byteValue)

Set a byte value.

Parameters:
  • option – The option for the UEI.

  • byteValue – The value.

Returns:

Returns common entity return values

aErr setUEI8(const uint8_t option, const uint8_t param, const uint8_t byteValue)

Set a byte value with a subindex.

Parameters:
  • option – The option for the UEI.

  • param – of the option.

  • byteValue – The value.

Returns:

Returns common entity return values

aErr getUEI8(const uint8_t option, uint8_t *byteValue)

Get a byte value.

Parameters:
  • option – The option for the UEI.

  • byteValue – The value.

Returns:

Returns common entity return values

aErr getUEI8(const uint8_t option, const uint8_t param, uint8_t *byteValue)

Get a byte value with a parameter.

Parameters:
  • option – The option for the UEI.

  • param – The parameter.

  • byteValue – The value.

Returns:

Returns common entity return values

aErr setUEI16(const uint8_t option, const uint16_t shortValue)

Set a 2-byte value.

Parameters:
  • option – The option for the UEI.

  • shortValue – The value.

Returns:

Returns common entity return values

aErr getUEI16(const uint8_t option, uint16_t *shortValue)

Get a 2-byte value.

Parameters:
  • option – The option for the UEI.

  • shortValue – The value.

Returns:

Returns common entity return values

aErr getUEI16(const uint8_t option, const uint8_t param, uint16_t *shortValue)

Get a 2-byte value with a parameter.

Parameters:
  • option – The option for the UEI.

  • param – The parameter.

  • shortValue – The value.

Returns:

Returns common entity return values

aErr setUEI32(const uint8_t option, const uint32_t intValue)

Set a 4-byte value.

Parameters:
  • option – The option for the UEI.

  • intValue – The value.

Returns:

Returns common entity return values

aErr setUEI32(const uint8_t option, const uint8_t subIndex, const uint32_t intValue)

Set a 4-byte value, with a subindex parameter.

Parameters:
  • option – The option for the UEI.

  • subIndex – The subindex to set.

  • intValue – The value.

Returns:

Returns common entity return values

aErr getUEI32(const uint8_t option, uint32_t *intValue)

Get a 4-byte value.

Parameters:
  • option – The option for the UEI.

  • intValue – The 4 byte value

Returns:

Returns common entity return values

aErr getUEI32(const uint8_t option, const uint8_t param, uint32_t *intValue)

Get a 4-byte value with parameter.

Parameters:
  • option – The option for the UEI.

  • param – The parameter.

  • intValue – The 4 byte value

Returns:

Returns common entity return values

aErr setUEIBytes(const uint8_t option, const uint8_t *bufPtr, const size_t bufLen)

Set a multi-byte value.

Parameters:
  • option – The option for the UEI.

  • bufPtr – The pointer to a data buffer

  • bufLen – The length of the data buffer

Returns:

Returns common entity return values

aErr getUEIBytes(const uint8_t option, uint8_t *buf, const size_t bufLength, size_t *unloadedLength)

Unloads UEI Bytes data as byte data

Parameters:
  • option – The option for the UEI.

  • buf – Start of where data should be stored..

  • bufLength – Size of the buffer

  • unloadedLength – Amount of data unloaded (in bytes)

Returns:

Returns common entity return values

aErr getUEIBytesCheck(size_t *unloadedLength, const size_t valueSize)
Parameters:
  • unloadedLength – Amount of data unloaded (in bytes)

  • valueSize – The base type size in this array

Returns:

Returns common entity return values

uint8_t getIndex(void) const

Get the UEI entity index.

Returns:

The 1 byte index of the UEI entity.

aErr drainUEI(const uint8_t option)

Drain all packets matching this UEI from the packet fifo.

This functionality is useful in rare cases where packet synchronization is lost and a valid return packet is not accessible.

aErr setStreamEnabled(uint8_t enabled)

Enables streaming for all possible option codes within the cmd and index the entity was created for.

Parameters:

enabled – The state to be applied. 0 = Disabled; 1 = enabled

Returns:

Returns common entity return values

aErr registerOptionCallback(const uint8_t option, const bool enable, Link::streamCallback_t cb, void *pRef)

Registers a callback function based on a specific option code. Option code applies to the cmd and index of the called API.

Parameters:
  • option – option to filter by (supports Wildcards)

  • enable – True - installs/updates callback and ref; False - uninstalls callback

  • cb – Callback to be executed when a new packet matching the criteria is received.

  • pRef – Pointer to user reference for use inside the callback function.

Returns:

aErrNotFound - Item not found (uninstalling only)

Returns:

aErrNone - success

aErr getStreamStatus(std::map<uint64_t, uint32_t> *status)

Gets all available stream values associated with the cmd and index of the called API. Keys can be decoded with Link::getStreamKeyElement.

Parameters:

status – map of option value pairs to be filled. Option codes are based on the cmd and index of the calling API.

Returns:

aErrParam if status is null

Returns:

aErrResource - if the link is not valid

Returns:

aErrNone - success

Public Static Functions

static uint8_t getUEIBytesSequence(const aPacket *packet)
Parameters:

packet – UEI packet to be checked/filtered.

Returns:

The sequence number of the byte.

static bool getUEIBytesContinue(const aPacket *packet)
Parameters:

packet – UEI packet to be checked/filtered.

Returns:

True - Continue bit is set (more packets to come); False - Continue bit is not set (first or last packet).

static uint8_t sUEIBytesFilter(const aPacket *packet, const void *ref)

Filter function for UEI Bytes calls. Exposed for unit-testing purposes only.

Parameters:
  • packet – UEI packet to be checked/filtered.

  • ref – Opaque reference handle

group EntityReturnValues

Common EntityClass Return Values.