Z-Wave Protocol Controller Reference
zwave_command_class_indicator.c File Reference
#include "zwave_command_class_indicator.h"
#include "ZW_classcmd.h"
#include "zwave_command_handler.h"
#include "platform_exec.h"
#include "zwave_unid.h"
#include "zwave_command_class_indices.h"
#include "zwave_command_classes_utils.h"
#include "zwave_controller_connection_info.h"
#include "zwave_tx.h"
#include "script_defines.h"
#include "ctimer.h"
#include "dotdot_mqtt_generated_commands.h"
#include "sl_log.h"
Include dependency graph for zwave_command_class_indicator.c:

Macros

#define LOG_TAG   "zwave_command_class_indicator"
 

Functions

static void call_external_blinker (unsigned int on_time_ms, unsigned int off_time_ms, unsigned int num_cycles)
 
static void indicator_sequence_timout_callback (void *ptr)
 
static void update_indicator (void)
 
static void publish_generated_identify_command (const zwave_controller_connection_info_t *info)
 Publishes that a node has sent us (generated) an identify command. More...
 
static void set_indicator_value0 (uint8_t value)
 
static uint8_t get_indicator_value0 (void)
 
static sl_status_t zwave_command_class_indicator_handle_set (const zwave_controller_connection_info_t *connection_info, const uint8_t *frame_data)
 
static bool zwave_command_class_indicator_get_object_count (int *obj_count, uint8_t cmd_properties, uint16_t frame_length)
 
static bool zwave_command_class_indicator_get_indicator_values (int obj_count, const VG_INDICATOR_SET_V3_VG *vg_array, uint8_t *on_off_period_length, uint8_t *on_off_num_cycles, uint8_t *on_time)
 
static sl_status_t zwave_command_class_indicator_handle_setV3 (const zwave_controller_connection_info_t *connection_info, const uint8_t *frame_data, uint16_t frame_length)
 
static sl_status_t zwave_command_class_indicator_handle_get (const zwave_controller_connection_info_t *connection_info, const uint8_t *frame_data, uint16_t frame_length)
 
static sl_status_t zwave_command_class_indicator_handle_getV3 (const zwave_controller_connection_info_t *connection_info, const uint8_t *frame_data, uint16_t frame_length)
 
static sl_status_t zwave_command_class_indicator_handle_supported_getV3 (const zwave_controller_connection_info_t *connection_info, const uint8_t *frame_data, uint16_t frame_length)
 
sl_status_t zwave_command_class_indicator_support_handler (const zwave_controller_connection_info_t *connection_info, const uint8_t *frame_data, uint16_t frame_length)
 Handles incoming indicator encapsulated commands. More...
 
sl_status_t zwave_command_class_indicator_init ()
 setup for indicator command class More...
 

Variables

static uint8_t g_on_off_period_length = 0
 
static uint8_t g_on_off_num_cycles = 0
 
static uint8_t g_on_time = 0
 
static char * g_node_identify_script = IDENTIFY_SCRIPT_PATH
 
static struct ctimer g_indicator_timer
 

Macro Definition Documentation

◆ LOG_TAG

#define LOG_TAG   "zwave_command_class_indicator"

Function Documentation

◆ call_external_blinker()

static void call_external_blinker ( unsigned int  on_time_ms,
unsigned int  off_time_ms,
unsigned int  num_cycles 
)
static

Call external script/application to control the indicator LED.

Parameters
on_time_msON duration (in milliseconds) for a single blink cycle. If on_time_ms is zero the indicator should be turned off.
off_time_msOFF duration (in milliseconds) for a single blink cycle.
num_cyclesNumber of blink cycles. If num_cycles is zero the indicator LED should blink "forever" or until the next time this function is called.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_indicator_value0()

static uint8_t get_indicator_value0 ( void  )
static

Maps the three version 3 indicator properties stored in the global variables g_on_off_period_length, g_on_off_num_cycles and g_on_time to a single indicator value.

See also
SetIndicator0Value
Returns
Single value representing the indicator state.
Here is the caller graph for this function:

◆ indicator_sequence_timout_callback()

static void indicator_sequence_timout_callback ( void *  ptr)
static

Called on timeout of the timer controlling the length of the full blink sequence.

Will reset all Node Identify properties to default values such that the INDICATOR_GET command will reflect that the indicator is no longer active.

Please note: The timer is a "best effort" approximation to reflect the status of the externally controlled LED. Since the external blinker is running free after it has been started we do not know exactly if it has blinked the requested number of times when this timeout occurs since the external blink timers could have drifted a bit.

We do not try to stop the LED from here - it's controlled by an external script that we expect to terminate at the "right" time. We only reset the internal state variables to reflect the the LED is expected to no longer be active.

The timer is not started if the client has requested an unlimited number of blink cycles (g_on_off_num_cycles == 0xFF). In that case there will be no timeout.

Here is the caller graph for this function:

◆ publish_generated_identify_command()

static void publish_generated_identify_command ( const zwave_controller_connection_info_t info)
static

Publishes that a node has sent us (generated) an identify command.

Parameters
infoConnection info object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_indicator_value0()

static void set_indicator_value0 ( uint8_t  value)
static

Maps a single indicator value to the three version 3 indicator properties stored in the global variables g_on_off_period_length, g_on_off_num_cycles and g_on_time.

Used for backward compatibility with the version 1 command class. The single indicator value is either the version 1 indicator value or the version 3 Indicator0 value.

Parameters
valueThe value of the indicator. We're assuming Indicator0 to be a binary indicator (a more advanced extension could be to map to a multilevel indicator where the value controls e.g. the blink frequency). value is interpreted like this:
  • 0: Turn the indicator off
  • >0: Turn the indicator on
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_indicator()

static void update_indicator ( void  )
static

Calls call_external_blinker after calculating the parameters to pass.

Uses the global variables g_on_off_period_length, g_on_off_num_cycles and g_on_time (set by Indicator Command Class commands) to calculate the values to pass to call_external_blinker. In addition it updates the g_indicator_timer timer.

Should be called whenever a SET command is received.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_indicator_get_indicator_values()

static bool zwave_command_class_indicator_get_indicator_values ( int  obj_count,
const VG_INDICATOR_SET_V3_VG *  vg_array,
uint8_t *  on_off_period_length,
uint8_t *  on_off_num_cycles,
uint8_t *  on_time 
)
static
Here is the caller graph for this function:

◆ zwave_command_class_indicator_get_object_count()

static bool zwave_command_class_indicator_get_object_count ( int *  obj_count,
uint8_t  cmd_properties,
uint16_t  frame_length 
)
static
Here is the caller graph for this function:

◆ zwave_command_class_indicator_handle_get()

static sl_status_t zwave_command_class_indicator_handle_get ( const zwave_controller_connection_info_t connection_info,
const uint8_t *  frame_data,
uint16_t  frame_length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_indicator_handle_getV3()

static sl_status_t zwave_command_class_indicator_handle_getV3 ( const zwave_controller_connection_info_t connection_info,
const uint8_t *  frame_data,
uint16_t  frame_length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_indicator_handle_set()

static sl_status_t zwave_command_class_indicator_handle_set ( const zwave_controller_connection_info_t connection_info,
const uint8_t *  frame_data 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_indicator_handle_setV3()

static sl_status_t zwave_command_class_indicator_handle_setV3 ( const zwave_controller_connection_info_t connection_info,
const uint8_t *  frame_data,
uint16_t  frame_length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_indicator_handle_supported_getV3()

static sl_status_t zwave_command_class_indicator_handle_supported_getV3 ( const zwave_controller_connection_info_t connection_info,
const uint8_t *  frame_data,
uint16_t  frame_length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_indicator_timer

struct ctimer g_indicator_timer
static

◆ g_node_identify_script

char* g_node_identify_script = IDENTIFY_SCRIPT_PATH
static

◆ g_on_off_num_cycles

uint8_t g_on_off_num_cycles = 0
static

◆ g_on_off_period_length

uint8_t g_on_off_period_length = 0
static

◆ g_on_time

uint8_t g_on_time = 0
static