AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Namespaces | Macros | Functions | Variables
AlertsCapabilityAgent.cpp File Reference
#include <AVSCommon/AVS/CapabilityConfiguration.h>
#include <AVSCommon/AVS/MessageRequest.h>
#include <AVSCommon/AVS/SpeakerConstants/SpeakerConstants.h>
#include <AVSCommon/Utils/File/FileUtils.h>
#include <AVSCommon/Utils/JSON/JSONUtils.h>
#include <AVSCommon/Utils/Metrics/DataPointCounterBuilder.h>
#include <AVSCommon/Utils/Metrics/DataPointStringBuilder.h>
#include <AVSCommon/Utils/Metrics/MetricEventBuilder.h>
#include <AVSCommon/Utils/Timing/TimeUtils.h>
#include <acsdkManufactory/Annotated.h>
#include <Settings/Setting.h>
#include <Settings/SettingEventMetadata.h>
#include <Settings/SettingEventSender.h>
#include <Settings/SharedAVSSettingProtocol.h>
#include <Settings/Storage/DeviceSettingStorageInterface.h>
#include <Settings/Types/AlarmVolumeRampTypes.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#include <algorithm>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include "acsdkAlerts/Alarm.h"
#include "acsdkAlerts/AlertsCapabilityAgent.h"
#include "acsdkAlerts/Reminder.h"
#include "acsdkAlerts/Timer.h"
Include dependency graph for AlertsCapabilityAgent.cpp:

Namespaces

 alexaClientSDK
 Whether or not curl logs should be emitted.
 
 alexaClientSDK::acsdkAlerts
 

Macros

#define LX(event)   alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)
 

Functions

static const std::string alexaClientSDK::acsdkAlerts::TAG ("AlertsCapabilityAgent")
 String to identify log entries originating from this file. More...
 
static std::shared_ptr< avsCommon::avs::CapabilityConfiguration > alexaClientSDK::acsdkAlerts::getAlertsCapabilityConfiguration ()
 
static rapidjson::Value alexaClientSDK::acsdkAlerts::buildAllAlertsContext (const std::vector< Alert::ContextInfo > &alertsInfo, Document::AllocatorType &allocator)
 
static std::string alexaClientSDK::acsdkAlerts::currentISO8601TimeUTC ()
 
static rapidjson::Value alexaClientSDK::acsdkAlerts::buildActiveAlertsContext (const std::vector< Alert::ContextInfo > &alertsInfo, Document::AllocatorType &allocator)
 
static void alexaClientSDK::acsdkAlerts::submitMetric (const std::shared_ptr< MetricRecorderInterface > &metricRecorder, const std::string &eventName, int count)
 
static void alexaClientSDK::acsdkAlerts::addGenericMetadata (std::unordered_map< std::string, std::string > &metadata, const std::string &alertToken, const std::string &alertType, bool isConnected, long monotonicTime, const std::string &scheduledTriggerTime, const std::string &actualTriggerTime)
 
static void alexaClientSDK::acsdkAlerts::addAlertStartedRingingMetadata (std::unordered_map< std::string, std::string > &metadata, const std::string &ascending, int volume)
 
static void alexaClientSDK::acsdkAlerts::addAlertCanceledMetadata (std::unordered_map< std::string, std::string > &metadata)
 
static void alexaClientSDK::acsdkAlerts::submitMetricWithMetadata (const std::shared_ptr< MetricRecorderInterface > &metricRecorder, const std::string &eventName, std::unordered_map< std::string, std::string > metadata)
 

Variables

static const std::string alexaClientSDK::acsdkAlerts::ALERTS_CAPABILITY_INTERFACE_TYPE = "AlexaInterface"
 
static const std::string alexaClientSDK::acsdkAlerts::ALERTS_CAPABILITY_INTERFACE_NAME = "Alerts"
 Alerts interface name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERTS_CAPABILITY_INTERFACE_VERSION = "1.5"
 Alerts interface version. More...
 
static const std::string alexaClientSDK::acsdkAlerts::KEY_TYPE = "type"
 The value for Type which we need for json parsing. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_NAME_SET_ALERT = "SetAlert"
 The value of the SetAlert Directive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_NAME_DELETE_ALERT = "DeleteAlert"
 The value of the DeleteAlert Directive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_NAME_DELETE_ALERTS = "DeleteAlerts"
 The value of the DeleteAlerts Directive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_NAME_SET_VOLUME = "SetVolume"
 The value of the SetVolume Directive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_NAME_ADJUST_VOLUME = "AdjustVolume"
 The value of the AdjustVolume Directive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_NAME_SET_ALARM_VOLUME_RAMP = "SetAlarmVolumeRamp"
 The value of the SetAlarmVolumeRamp Directive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::SET_ALERT_SUCCEEDED_EVENT_NAME = "SetAlertSucceeded"
 The value of the SetAlertSucceeded Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::SET_ALERT_FAILED_EVENT_NAME = "SetAlertFailed"
 The value of the SetAlertFailed Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DELETE_ALERT_SUCCEEDED_EVENT_NAME = "DeleteAlertSucceeded"
 The value of the DeleteAlertSucceeded Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DELETE_ALERT_FAILED_EVENT_NAME = "DeleteAlertFailed"
 The value of the DeleteAlertFailed Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_STARTED_EVENT_NAME = "AlertStarted"
 The value of the AlertStarted Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_STOPPED_EVENT_NAME = "AlertStopped"
 The value of the AlertStopped Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_ENTERED_FOREGROUND_EVENT_NAME = "AlertEnteredForeground"
 The value of the AlertEnteredForeground Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_ENTERED_BACKGROUND_EVENT_NAME = "AlertEnteredBackground"
 The value of the AlertEnteredBackground Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_VOLUME_CHANGED_EVENT_NAME = "VolumeChanged"
 The value of the VolumeChanged Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_DELETE_ALERTS_SUCCEEDED_EVENT_NAME = "DeleteAlertsSucceeded"
 The value of the DeleteAlertsSucceeded Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_DELETE_ALERTS_FAILED_EVENT_NAME = "DeleteAlertsFailed"
 The value of the DeleteAlertsFailed Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_ALARM_VOLUME_RAMP_CHANGED_EVENT_NAME = "AlarmVolumeRampChanged"
 The value of the AlarmVolumeRampChanged Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_REPORT_ALARM_VOLUME_RAMP_EVENT_NAME = "AlarmVolumeRampReport"
 The value of the ReportAlarmVolumeRamp Event name. More...
 
static const std::string alexaClientSDK::acsdkAlerts::EVENT_PAYLOAD_TOKEN_KEY = "token"
 The value of the event payload key for a single token. More...
 
static const std::string alexaClientSDK::acsdkAlerts::EVENT_PAYLOAD_TOKENS_KEY = "tokens"
 The value of the event payload key for multiple tokens. More...
 
static const std::string alexaClientSDK::acsdkAlerts::EVENT_PAYLOAD_SCHEDULED_TIME_KEY = "scheduledTime"
 The value of the event payload key for scheduled time. More...
 
static const std::string alexaClientSDK::acsdkAlerts::EVENT_PAYLOAD_EVENT_TIME_KEY = "eventTime"
 The value of the event payload key for event time. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_PAYLOAD_TOKEN_KEY = "token"
 The value of Token text in a Directive we may receive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_PAYLOAD_TOKENS_KEY = "tokens"
 The value of Token list key in a Directive we may receive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_PAYLOAD_VOLUME = "volume"
 The value of volume key in a Directive we may receive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::DIRECTIVE_PAYLOAD_ALARM_VOLUME_RAMP = "alarmVolumeRamp"
 The value of alarm volume ramp key in a Directive we may receive. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_CONTEXT_HEADER_NAMESPACE_VALUE_KEY = "Alerts"
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_CONTEXT_HEADER_NAME_VALUE_KEY = "AlertsState"
 The value of the Alerts Context Names. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_CONTEXT_ALL_ALERTS_TOKEN_KEY = "allAlerts"
 The value of the Alerts Context allAlerts node. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_CONTEXT_ACTIVE_ALERTS_TOKEN_KEY = "activeAlerts"
 The value of the Alerts Context activeAlerts node. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_CONTEXT_ALERT_TOKEN_KEY = "token"
 The value of the Alerts Context token key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_CONTEXT_ALERT_TYPE_KEY = "type"
 The value of the Alerts Context type key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_CONTEXT_ALERT_SCHEDULED_TIME_KEY = "scheduledTime"
 The value of the Alerts Context scheduled time key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_PAYLOAD_VOLUME_KEY = "volume"
 The value of the volume state info volume key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_PAYLOAD_ALARM_VOLUME_RAMP_KEY = "alarmVolumeRamp"
 The value of the alarm volume ramp state key for alarm volume ramp events. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_PAYLOAD_ERROR_KEY = "error"
 The JSON key in the payload of error events. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_PAYLOAD_ERROR_TYPE_KEY = "type"
 The JSON key for the error type in the payload of error events. More...
 
static const std::string alexaClientSDK::acsdkAlerts::AVS_PAYLOAD_ERROR_MESSAGE_KEY = "message"
 The JSON key for the error message in the payload of error events. More...
 
static const std::string alexaClientSDK::acsdkAlerts::OFFLINE_STOPPED_ALERT_TOKEN_KEY = "token"
 The value of the offline stopped alert token key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::OFFLINE_STOPPED_ALERT_SCHEDULED_TIME_KEY = "scheduledTime"
 The value of the offline stopped alert scheduledTime key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::OFFLINE_STOPPED_ALERT_EVENT_TIME_KEY = "eventTime"
 The value of the offline stopped alert eventTime key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::OFFLINE_STOPPED_ALERT_ID_KEY = "id"
 The value of the offline stopped alert id key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::EMPTY_DIALOG_REQUEST_ID = ""
 An empty dialogRequestId. More...
 
static const std::string alexaClientSDK::acsdkAlerts::NAMESPACE = "Alerts"
 The namespace for this capability agent. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::acsdkAlerts::SET_ALERT {NAMESPACE, DIRECTIVE_NAME_SET_ALERT}
 The SetAlert directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::acsdkAlerts::DELETE_ALERT {NAMESPACE, DIRECTIVE_NAME_DELETE_ALERT}
 The DeleteAlert directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::acsdkAlerts::DELETE_ALERTS {NAMESPACE, DIRECTIVE_NAME_DELETE_ALERTS}
 The DeleteAlerts directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::acsdkAlerts::SET_VOLUME {NAMESPACE, DIRECTIVE_NAME_SET_VOLUME}
 The SetVolume directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::acsdkAlerts::ADJUST_VOLUME {NAMESPACE, DIRECTIVE_NAME_ADJUST_VOLUME}
 The AdjustVolume directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::acsdkAlerts::SET_ALARM_VOLUME_RAMP {NAMESPACE, DIRECTIVE_NAME_SET_ALARM_VOLUME_RAMP}
 The SetAlarmVolumeRamp directive signature. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_METRIC_SOURCE_PREFIX = "ALERT-"
 Metric Activity Name Prefix for ALERT metric source. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_STARTED_METRIC_NAME = "NotificationStartedRinging"
 Metric names. More...
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_CANCELED_METRIC_NAME = "NotificationCanceled"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_TYPE_KEY = "NotificationType"
 Metric metadata keys. More...
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_TOKEN_KEY = "NotificationId"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_VERSION_KEY = "NotificationMetadataVersion"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_DEVICE_STATE_KEY = "DeviceState"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_ACTUAL_TRIGGER_TIME_KEY = "ActualTriggerTime"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_SCHEDULED_TRIGGER_TIME_KEY = "ScheduledTriggerTime"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_MONOTONIC_TIME_KEY = "MonotonicTime"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_IS_ASCENDING_KEY = "IsAscending"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_ALERT_VOLUME_KEY = "NotificationVolume"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_IS_QUEUED_KEY = "IsNotificationQueued"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_CANCELED_REASON_KEY = "CanceledReason"
 
static const int alexaClientSDK::acsdkAlerts::METRIC_METADATA_VERSION_VALUE = 2
 Metric metadata values. More...
 
static const int alexaClientSDK::acsdkAlerts::MILLISECONDS_IN_A_SECOND = 1000
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_IS_QUEUED_VALUE = "false"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_DEVICE_STATE_ONLINE = "ONLINE"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_DEVICE_STATE_OFFLINE = "OFFLINE"
 
static const std::string alexaClientSDK::acsdkAlerts::METRIC_METADATA_CANCELED_REASON_VALUE = "TriggerTimeInThePast"
 
static const std::string alexaClientSDK::acsdkAlerts::FAILED_SNOOZE_ALERT = "failedToSnoozeAlert"
 Metric constants related to Alerts. More...
 
static const std::string alexaClientSDK::acsdkAlerts::FAILED_SCHEDULE_ALERT = "failedToScheduleAlert"
 
static const std::string alexaClientSDK::acsdkAlerts::INVALID_PAYLOAD_FOR_SET_ALARM_VOLUME = "invalidPayloadToSetAlarmRamping"
 
static const std::string alexaClientSDK::acsdkAlerts::INVALID_PAYLOAD_FOR_CHANGE_ALARM_VOLUME = "invalidPayloadToChangeAlarmVolume"
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_RINGING_LESS_THAN_30_PERCENT_MAX_VOLUME
 
static const std::string alexaClientSDK::acsdkAlerts::ALERT_RINGING_ZERO_VOLUME = "alertTriggeredAtZeroAlertVolume"
 
static const int alexaClientSDK::acsdkAlerts::ALERT_VOLUME_METRIC_LIMIT = 30
 

Macro Definition Documentation

◆ LX

#define LX (   event)    alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)

Create a LogEntry using this file's TAG and the specified event string.

Parameters
Theevent string for this LogEntry.

AlexaClientSDK 1.26.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0