HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Interfaces::SimpleButton::Server Class Reference

Simple Button Interface : Server side implementation. More...

#include <simple_button.h>

+ Inheritance diagram for HF::Interfaces::SimpleButton::Server:
+ Collaboration diagram for HF::Interfaces::SimpleButton::Server:

Public Member Functions

 Server ()
 Constructor.
 
virtual ~Server ()
 Destructor.
 
void pressed (const Protocol::Address &addr, uint16_t timestamp)
 This method is used to indicate that the button was pressed and generate the appropriate message, to the given address. More...
 
void pressed (uint16_t timestamp)
 This method is used to indicate that the button was pressed. More...
 
void released (const Protocol::Address &addr, uint16_t timestamp)
 This method is used to indicate that the button was released and generate the appropriate message, to the given address. More...
 
void released (uint16_t timestamp)
 This method is used to indicate that the button was released and generate the appropriate message, to the given broadcast address based on the difference between the timestamp of the last call to pressed and the given timestamp. More...
 
uint16_t short_press_max_duration () const
 Get the Short Press Max Duration for the Simple Button server. More...
 
virtual void short_press_max_duration (uint16_t __value)
 Set the Short Press Max Duration for the Simple Button server. More...
 
uint16_t extra_long_press_min_duration () const
 Get the Extra Long Press Min Duration for the Simple Button server. More...
 
virtual void extra_long_press_min_duration (uint16_t __value)
 Set the Extra Long Press Min Duration for the Simple Button server. More...
 
HF::Attributes::IAttributeattribute (uint8_t uid)
 Return a pointer to the interface attribute with the given uid. More...
 
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. More...
 
- Public Member Functions inherited from HF::Interfaces::InterfaceRole< SimpleButton::Base, HF::Interface::SERVER_ROLE >
HF::Interface::Role role () const
 Return the Interface::Role this interface implements. More...
 
- Public Member Functions inherited from HF::Interfaces::Interface< HF::Interface::SIMPLE_BUTTON >
uint16_t uid () const
 This method returns the interface UID. More...
 
- Public Member Functions inherited from HF::Interfaces::AbstractInterface
Common::Result handle (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
void periodic (uint32_t time)
 Handle periodic processing. More...
 

Static Public Attributes

static constexpr uint16_t DOUBLE_CLICK_GAP_DURATION_MIN_VALUE = 0x0064
 This is the minimum value that the Double Click Gap Duration can have.
 
- Static Public Attributes inherited from HF::Interface
static constexpr uint8_t MAX_CMD_ID = 0xFF
 Maximum value for command IDs in interfaces.
 

Protected Member Functions

Commands
void short_press (const Protocol::Address &addr)
 Send a HAN-FUN message containing a SimpleButton::SHORT_PRESS_CMD, to the given network address. More...
 
void short_press ()
 Send a HAN-FUN message containing a SimpleButton::SHORT_PRESS_CMD, to the broadcast network address.
 
void long_press (const Protocol::Address &addr)
 Send a HAN-FUN message containing a SimpleButton::LONG_PRESS_CMD, to the given network address. More...
 
void long_press ()
 Send a HAN-FUN message containing a SimpleButton::LONG_PRESS_CMD, to the broadcast network address.
 
- Protected Member Functions inherited from HF::Interfaces::SimpleButton::Base
 Base ()
 Constructor.
 
- Protected Member Functions inherited from HF::Interfaces::Interface< HF::Interface::SIMPLE_BUTTON >
bool check_uid (uint16_t uid) const
 
- Protected Member Functions inherited from HF::Interfaces::AbstractInterface
virtual void send (const Protocol::Address &addr, Protocol::Message &message)=0
 Send message msg to the network address given by addr. More...
 
virtual void notify (const HF::Attributes::IAttribute &old_value, const HF::Attributes::IAttribute &new_value) const
 Notify that an attribute value as changed. More...
 
Common::Result check (Protocol::Message &message, Common::ByteArray &payload, uint16_t offset)
 Check if message has correct attributes to be processed by the interface. More...
 
Common::Result check_payload_size (Protocol::Message &message, Common::ByteArray &payload, uint16_t offset)
 Check if payload data size if sufficient for processing the message. More...
 
virtual uint16_t payload_size (Protocol::Message &message) const
 Return the minimal payload size that should be present for the given message. More...
 
virtual 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. More...
 
template<typename _Message >
uint16_t payload_size_helper () const
 Helper function template to retrieve minimum size required for serializing/deserializing the class given. More...
 
virtual Common::Result handle_command (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
virtual Common::Result handle_attribute (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 

Protected Attributes

uint16_t _short_press_max_duration
 Short Press Max Duration.
 
uint16_t _extra_long_press_min_duration
 Extra Long Press Minimum Duration.
 
uint16_t _timestamp
 Timestamp of last call. More...
 

Additional Inherited Members

- Public Types inherited from HF::Interface
enum  Role { CLIENT_ROLE = 0, SERVER_ROLE = 1 }
 Interface roles. More...
 
enum  UID {
  DEVICE_MANAGEMENT = 0x0001, BIND_MANAGEMENT = 0x0002, GROUP_MANAGEMENT = 0x0003, IDENTIFY = 0x0004,
  DEVICE_INFORMATION = 0x0005, ATTRIBUTE_REPORTING = 0x0006, BATCH_PROGRAM_MANAGEMENT = 0x0007, EVENT_SCHEDULING = 0x0008,
  WEEKLY_SCHEDULING = 0x0009, GROUP_TABLE = 0x000A, TAMPER_ALERT = 0x0101, TIME = 0x0102,
  POWER = 0x0110, KEEP_ALIVE = 0x0115, RSSI = 0x0111, SUOTA = 0x0400,
  ALERT = 0x0100, ON_OFF = 0x0200, LEVEL_CONTROL = 0x0201, COLOUR_CONTROL = 0x0202,
  SIMPLE_KEYPAD = 0x0203, SIMPLE_POWER_METER = 0x0300, SIMPLE_TEMPERATURE = 0x0301, SIMPLE_HUMIDITY = 0x0302,
  SIMPLE_THERMOSTAT = 0x0303, SIMPLE_BUTTON = 0x0304, SIMPLE_VISUAL_EFFECTS = 0x0305, SIMPLE_AIR_PRESSURE = 0x0306,
  SIMPLE_LIGHT_SENSOR = 0x0307, RESERVED = 0x7F00, MAX_UID = 0x7FFE, ANY_UID = 0x7FFF
}
 Interfaces Unique Identifiers (UID). More...
 

Detailed Description

Simple Button Interface : Server side implementation.

This class provides the server side of the Simple Button interface.

Definition at line 157 of file simple_button.h.

Member Function Documentation

◆ attribute()

HF::Attributes::IAttribute* HF::Interfaces::SimpleButton::Server::attribute ( uint8_t  uid)
virtual

Return a pointer to the interface attribute with the given uid.

Parameters
[in]uididentifier of the attribute in the interface.
Returns
a pointer to the attribute if it exists, nullptr otherwise.

Reimplemented from HF::Interfaces::AbstractInterface.

◆ attributes()

HF::Attributes::UIDS HF::Interfaces::SimpleButton::Server::attributes ( uint8_t  pack_id = HF::Attributes::Pack::MANDATORY) const
virtual

Return a vector containing the attribute UIDs, for the given pack ID.

Parameters
[in]pack_idthe Attribute pack ID to get the attributes UIDs for.
Returns
vector containing the attributes UIDs.

Reimplemented from HF::Interfaces::AbstractInterface.

◆ extra_long_press_min_duration() [1/2]

uint16_t HF::Interfaces::SimpleButton::Server::extra_long_press_min_duration ( ) const

Get the Extra Long Press Min Duration for the Simple Button server.

Returns
the current Extra Long Press Min Duration.

◆ extra_long_press_min_duration() [2/2]

virtual void HF::Interfaces::SimpleButton::Server::extra_long_press_min_duration ( uint16_t  __value)
virtual

Set the Extra Long Press Min Duration for the Simple Button server.

Parameters
[in]__valuethe Extra Long Press Min Duration value to set the server to.

◆ long_press()

void HF::Interfaces::SimpleButton::Server::long_press ( const Protocol::Address addr)
protected

Send a HAN-FUN message containing a SimpleButton::LONG_PRESS_CMD, to the given network address.

Parameters
[in]addrthe network address to send the message to.

◆ pressed() [1/2]

void HF::Interfaces::SimpleButton::Server::pressed ( const Protocol::Address addr,
uint16_t  timestamp 
)

This method is used to indicate that the button was pressed and generate the appropriate message, to the given address.

Parameters
[in]addrthe network address to send any generated message to.
[in]timestamptime in milliseconds the button was released.

Referenced by pressed().

+ Here is the caller graph for this function:

◆ pressed() [2/2]

void HF::Interfaces::SimpleButton::Server::pressed ( uint16_t  timestamp)
inline

This method is used to indicate that the button was pressed.

Parameters
[in]timestamptime in milliseconds the button was pressed.

Definition at line 213 of file simple_button.h.

References pressed().

214  {
215  Protocol::Address addr;
216  pressed(addr, timestamp);
217  }
void pressed(const Protocol::Address &addr, uint16_t timestamp)
This method is used to indicate that the button was pressed and generate the appropriate message...
+ Here is the call graph for this function:

◆ released() [1/2]

void HF::Interfaces::SimpleButton::Server::released ( const Protocol::Address addr,
uint16_t  timestamp 
)

This method is used to indicate that the button was released and generate the appropriate message, to the given address.

Warning
Calling this method without calling pressed before has undefined behavior.
Parameters
[in]addrthe network address to send any generated message to.
[in]timestamptime in milliseconds the button was released.

Referenced by released().

+ Here is the caller graph for this function:

◆ released() [2/2]

void HF::Interfaces::SimpleButton::Server::released ( uint16_t  timestamp)
inline

This method is used to indicate that the button was released and generate the appropriate message, to the given broadcast address based on the difference between the timestamp of the last call to pressed and the given timestamp.

Warning
Calling this method without calling pressed before has undefined behavior.
Parameters
[in]timestamptime in milliseconds the button was released.

Definition at line 239 of file simple_button.h.

References released().

240  {
241  Protocol::Address addr;
242  released(addr, timestamp);
243  }
void released(const Protocol::Address &addr, uint16_t timestamp)
This method is used to indicate that the button was released and generate the appropriate message...
+ Here is the call graph for this function:

◆ short_press()

void HF::Interfaces::SimpleButton::Server::short_press ( const Protocol::Address addr)
protected

Send a HAN-FUN message containing a SimpleButton::SHORT_PRESS_CMD, to the given network address.

Parameters
[in]addrthe network address to send the message to.

◆ short_press_max_duration() [1/2]

uint16_t HF::Interfaces::SimpleButton::Server::short_press_max_duration ( ) const

Get the Short Press Max Duration for the Simple Button server.

Returns
the current Short Press Max Duration.

◆ short_press_max_duration() [2/2]

virtual void HF::Interfaces::SimpleButton::Server::short_press_max_duration ( uint16_t  __value)
virtual

Set the Short Press Max Duration for the Simple Button server.

Parameters
[in]__valuethe Short Press Max Duration value to set the server to.

Field Documentation

◆ _timestamp

uint16_t HF::Interfaces::SimpleButton::Server::_timestamp
protected

Timestamp of last call.

Definition at line 169 of file simple_button.h.


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