Skip to content

Commit 5f0a168

Browse files
committed
fixes #447
1 parent 35c8cb7 commit 5f0a168

File tree

5 files changed

+50
-34
lines changed

5 files changed

+50
-34
lines changed

.DS_Store

6 KB
Binary file not shown.

cpp_utils/onhold/BLEEddystoneTLM.cpp renamed to cpp_utils/BLEEddystoneTLM.cpp

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* Created on: Mar 12, 2018
55
* Author: pcbreflux
66
*/
7-
#include "Arduino.h"
87
#include "sdkconfig.h"
98
#if defined(CONFIG_BT_ENABLED)
109
#include <string.h>
10+
#include <sstream>
1111
#include <esp_log.h>
1212
#include "BLEEddystoneTLM.h"
1313

@@ -54,46 +54,62 @@ uint32_t BLEEddystoneTLM::getTime() {
5454
} // getTime
5555

5656
std::string BLEEddystoneTLM::toString() {
57+
std::stringstream ss;
5758
std::string out = "";
58-
String buff;
5959
uint32_t rawsec;
60+
ss << "Version ";
61+
ss << std::dec << m_eddystoneData.version;
62+
ss << "\n";
6063

61-
out += "Version ";
62-
buff = String(m_eddystoneData.version, DEC);
63-
out += buff.c_str();
64-
out += "\n";
64+
ss << "Battery Voltage ";
65+
ss << std::dec << ENDIAN_CHANGE_U16(m_eddystoneData.volt);
66+
ss << " mV\n";
6567

66-
out += "Battery Voltage ";
67-
buff = String(ENDIAN_CHANGE_U16(m_eddystoneData.volt), DEC);
68-
out += buff.c_str();
69-
out += " mV\n";
68+
ss << "Temperature ";
69+
ss << (float)m_eddystoneData.temp;
70+
ss << " °C\n";
7071

71-
out += "Temperature ";
72-
buff = String((float)m_eddystoneData.temp, 1);
73-
out += buff.c_str();
74-
out += " °C\n";
75-
76-
out += "Adv. Count ";
77-
buff = String(ENDIAN_CHANGE_U32(m_eddystoneData.advCount), DEC);
78-
out += buff.c_str();
79-
out += "\n";
72+
ss << "Adv. Count ";
73+
ss << std::dec << ENDIAN_CHANGE_U32(m_eddystoneData.advCount);
74+
75+
ss << "\n";
8076

81-
out += "Time ";
77+
ss << "Time ";
78+
8279
rawsec = ENDIAN_CHANGE_U32(m_eddystoneData.tmil);
83-
buff = "0000"+String(rawsec/864000, DEC);
84-
out += buff.substring(buff.length()-4,buff.length()).c_str();
85-
out += ".";
86-
buff = "00"+String((rawsec/36000)%24, DEC);
87-
out += buff.substring(buff.length()-2,buff.length()).c_str();
88-
out += ":";
89-
buff = "00"+String((rawsec/600)%60, DEC);
90-
out += buff.substring(buff.length()-2,buff.length()).c_str();
91-
out += ":";
92-
buff = "00"+String((rawsec/10)%60, DEC);
93-
out += buff.substring(buff.length()-2,buff.length()).c_str();
94-
out += "\n";
95-
96-
return out;
80+
std::stringstream buffstream;
81+
buffstream << "0000";
82+
buffstream << std::dec << rawsec/864000;
83+
std::string buff = buffstream.str();
84+
85+
ss << buff.substr(buff.length()-4, buff.length());
86+
ss << ".";
87+
88+
buffstream.str("");
89+
buffstream.clear();
90+
buffstream << "00";
91+
buffstream << std::dec << (rawsec/36000)%24;
92+
buff = buffstream.str();
93+
ss << buff.substr(buff.length()-2, buff.length());
94+
ss << ":";
95+
96+
buffstream.str("");
97+
buffstream.clear();
98+
buffstream << "00";
99+
buffstream << std::dec << (rawsec/600)%60;
100+
buff = buffstream.str();
101+
ss << buff.substr(buff.length()-2, buff.length());
102+
ss << ":";
103+
104+
buffstream.str("");
105+
buffstream.clear();
106+
buffstream << "00";
107+
buffstream << std::dec << (rawsec/10)%60;
108+
buff = buffstream.str();
109+
ss << buff.substr(buff.length()-2, buff.length());
110+
ss << "\n";
111+
112+
return ss.str();
97113
} // toString
98114

99115
/**
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)