-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboardTrigger.cpp
More file actions
38 lines (34 loc) · 860 Bytes
/
KeyboardTrigger.cpp
File metadata and controls
38 lines (34 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "KeyboardTrigger.h"
#include "Logger.h"
#include "Config.h"
#include <HTTPClient.h>
#include <WString.h>
#include "SmartThingsManager.h"
#include "StringDict.h"
#include <SABleKeyboard.h>
namespace SA
{
bool ShouldBeTriggered(const char* deviceID)
{
return SmartThingsManager::Get().IsSwitchEnabled(deviceID, true);
}
void ReportCompletion(const char* deviceID)
{
SmartThingsManager::Get().SetSwitchValue(deviceID, false);
}
KeyboardTrigger::KeyboardTrigger(SABleKeyboard& keyboard, const char* triggeringDeviceID)
: m_keyboard(keyboard)
, m_triggeringDeviceID(triggeringDeviceID)
{}
void KeyboardTrigger::Update()
{
if (ShouldBeTriggered(m_triggeringDeviceID))
{
if (m_keyboard.IsAuthenticated())
{
OnTriggered();
ReportCompletion(m_triggeringDeviceID);
}
}
}
}