17 #ifndef HF_ITF_LEVEL_CONTROL_H 18 #define HF_ITF_LEVEL_CONTROL_H 27 namespace LevelControl
52 namespace LevelControl
73 typedef enum _Attributes
84 Message(uint8_t level = 0): level(level) {}
87 static constexpr uint16_t min_size =
sizeof(uint8_t);
96 uint16_t pack(Common::ByteArray &array, uint16_t offset = 0)
const 100 array.write(offset, level);
106 uint16_t unpack(
const Common::ByteArray &array, uint16_t offset = 0)
110 array.read(offset, level);
122 static constexpr
bool WRITABBLE =
true;
157 return payload_size_helper<Level>();
171 else if (value > 100)
188 else if (value > 255)
236 void level(uint8_t new_level);
246 void level(
float new_level);
248 #ifdef HF_ITF_LEVEL_CONTROL_INCREASE_LEVEL_CMD 254 void increase(uint8_t increment);
262 void increase(
float increment);
265 #ifdef HF_ITF_LEVEL_CONTROL_DECREASE_LEVEL_CMD 271 void decrease(uint8_t decrement);
279 void decrease(
float decrement);
366 level(addr, new_level);
383 level(addr, new_level);
386 #ifdef HF_ITF_LEVEL_CONTROL_INCREASE_LEVEL_CMD 402 void increase_level(uint8_t increment)
405 increase_level(addr, increment);
422 void increase_level(
float increment)
425 increase_level(addr, increment);
429 #ifdef HF_ITF_LEVEL_CONTROL_DECREASE_LEVEL_CMD 445 void decrease_level(uint8_t decrement)
448 decrease_level(addr, decrement);
457 void decrease_level(Protocol::Address &addr,
float decrement);
465 void decrease_level(
float decrement)
467 Protocol::Address addr;
468 decrease_level(addr, decrement);
510 std::ostream &
operator<<(std::ostream &stream,
virtual void level_change(Protocol::Address &source, uint8_t old_level, uint8_t new_level)
Callback for a SET_ATTR_REQ or SET_LEVEL_CMD message, when the level value is changed.
Return all mandatory attributes for the interface.
Helper class to handle the Level attribute for the Level Control interface.
Decrease Level Command ID.
Helper class template for parent class implementation of the interfaces.
Level Control Interface : Client side implementation.
This file contains the definitions for the HAN-FUN protocol messages.
void check_and_fix(float &value)
Make sure level percentage values is in range [0,100].
Increase Level Command ID.
HF::Attributes::IAttribute * attribute(uint8_t uid)
Return a pointer to the interface attribute with the given uid.
#define HF_SERIALIZABLE_CHECK(__array, __offset, __size)
Helper macro to check if the given __array has enough size so __size bytes can be written/read from t...
This file contains the definitions common to all interfaces.
HF::Attributes::UIDS attributes(uint8_t pack_id=HF::Attributes::Pack::MANDATORY) const
Return a vector containing the attribute UIDs, for the given pack ID.
HF::Interface const * owner() const
This class represents a byte array.
Common::Result handle_command(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
Level Control interface UID.
uint16_t uid() const
This method returns the interface UID.
Level Control Interface : Parent.
Level Control Interface : Server side implementation.
HF::Attributes::IAttribute * create_attribute(HF::Interfaces::Alert::Server *server, uint8_t uid)
Create an attribute object that can hold the attribute with the given uid.
Interface/Service Attribute API.
HF::Attributes::IAttribute * create_attribute(uint8_t uid)
Create an attribute object that can hold the attribute with the given uid. (HF::Interfaces::LevelCont...
void level(uint8_t new_level)
Send a SET_LEVEL_CMD to broadcast network address to set the level at new_level.
Helper class template for implementing a given interface role.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
Common::Result handle_attribute(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
void check_and_fix(int16_t &value)
Make sure level percentage values is in range [0,255].
Helper template class to declare an attribute with the given T type.
void level(Protocol::Address &addr, uint8_t new_level)
Send a SET_LEVEL_CMD to the given address to set the level at new_level.
void level(float new_level)
Send a SET_LEVEL_CMD to broadcast network address to set the level at new_level.
Common interface for all Interfaces.
uint16_t payload_size(Protocol::Message::Interface &itf) const
Return the minimal payload size that a message should hold when addressed at the given interface...
std::ostream & operator<<(std::ostream &stream, const HF::Interfaces::LevelControl::CMD command)
Convert the given command into a string and write it to the given stream.
Result
Commands result codes.
uint8_t level()
Getter for the current level.
uint8_t _level
Current level value.
Top-level namespace for the HAN-FUN library.