forked from DanielOgorchock/ST_Anything
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevice.cpp
More file actions
68 lines (58 loc) · 1.58 KB
/
Device.cpp
File metadata and controls
68 lines (58 loc) · 1.58 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//******************************************************************************************
// File: Device.cpp
// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
// Summary: st::Device is the highest level generic class for either a st::Sensor or
// st::Executor subclass.
// In general, this file should not need to be modified.
//
// Change History:
//
// Date Who What
// ---- --- ----
// 2015-01-03 Dan & Daniel Original Creation
// 2018-08-15 Dan Ogorchock Workaround for strcpy_P() ESP32 crash bug
//
//******************************************************************************************
#include "Device.h"
#include "Everything.h"
#include "Constants.h"
namespace st
{
//private
//public
//constructor
Device::Device(const __FlashStringHelper *name):
m_pName(name)
{
if(debug)
{
Serial.print(F("Device: New Device ID: "));
Serial.println(getName());
}
}
//destructor
Device::~Device()
{
if(debug)
{
Serial.print(F("Device: Destroyed Device ID: "));
Serial.println(getName());
}
}
void Device::refresh()
{
}
const String Device::getName() const
{
#if defined(ARDUINO_ARCH_ESP32)
return String((const char*)m_pName); //strcpy_P() causes ESP32 to crash
#else
char tmp[Constants::MAX_NAME_LENGTH];
strcpy_P(tmp, (const char*)m_pName);
return String(tmp);
#endif
}
//debug flag to determine if debug print statements are executed (set value in your sketch)
bool Device::debug=false;
}