SensESP
3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
signalk_metadata.cpp
Go to the documentation of this file.
1
#include "
signalk_metadata.h
"
2
3
namespace
sensesp
{
4
5
SKMetadata::SKMetadata
(
const
String& units,
const
String& display_name,
6
const
String& description,
const
String& short_name,
7
float
timeout)
8
: display_name_{display_name},
9
units_{units},
10
description_{description},
11
short_name_{short_name},
12
timeout_{timeout} {}
13
14
void
SKMetadata::add_entry
(
const
String& sk_path, JsonArray& meta) {
15
JsonObject json = meta.add<JsonObject>();
16
json[
"path"
] = sk_path;
17
JsonObject val = json[
"value"
].to<JsonObject>();
18
19
if
(!this->
display_name_
.isEmpty()) {
20
val[
"displayName"
] = this->
display_name_
;
21
}
22
23
if
(!this->
units_
.isEmpty()) {
24
val[
"units"
] = this->
units_
;
25
}
26
27
if
(!this->
description_
.isEmpty()) {
28
val[
"description"
] = this->
description_
;
29
}
30
31
if
(!this->
short_name_
.isEmpty()) {
32
val[
"shortName"
] = this->
short_name_
;
33
}
34
35
if
(this->
timeout_
>= 0.0) {
36
val[
"timeout"
] = this->
timeout_
;
37
}
38
}
39
40
}
// namespace sensesp
sensesp::SKMetadata::display_name_
String display_name_
Definition
signalk_metadata.h:26
sensesp::SKMetadata::add_entry
virtual void add_entry(const String &sk_path, JsonArray &meta)
Definition
signalk_metadata.cpp:14
sensesp::SKMetadata::description_
String description_
Definition
signalk_metadata.h:28
sensesp::SKMetadata::SKMetadata
SKMetadata()
Default constructor creates a blank Metadata structure.
Definition
signalk_metadata.h:52
sensesp::SKMetadata::timeout_
float timeout_
Definition
signalk_metadata.h:30
sensesp::SKMetadata::short_name_
String short_name_
Definition
signalk_metadata.h:29
sensesp::SKMetadata::units_
String units_
Definition
signalk_metadata.h:27
sensesp
Definition
sensesp.cpp:7
signalk_metadata.h
src
sensesp
signalk
signalk_metadata.cpp
Generated by
1.12.0