Skip to content

Commit

Permalink
fixes nkolban#447
Browse files Browse the repository at this point in the history
  • Loading branch information
Donderda committed Aug 7, 2018
1 parent 35c8cb7 commit 5f0a168
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 34 deletions.
Binary file added .DS_Store
Binary file not shown.
84 changes: 50 additions & 34 deletions cpp_utils/onhold/BLEEddystoneTLM.cpp → cpp_utils/BLEEddystoneTLM.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Created on: Mar 12, 2018
* Author: pcbreflux
*/
#include "Arduino.h"
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED)
#include <string.h>
#include <sstream>
#include <esp_log.h>
#include "BLEEddystoneTLM.h"

Expand Down Expand Up @@ -54,46 +54,62 @@ uint32_t BLEEddystoneTLM::getTime() {
} // getTime

std::string BLEEddystoneTLM::toString() {
std::stringstream ss;
std::string out = "";
String buff;
uint32_t rawsec;
ss << "Version ";
ss << std::dec << m_eddystoneData.version;
ss << "\n";

out += "Version ";
buff = String(m_eddystoneData.version, DEC);
out += buff.c_str();
out += "\n";
ss << "Battery Voltage ";
ss << std::dec << ENDIAN_CHANGE_U16(m_eddystoneData.volt);
ss << " mV\n";

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

out += "Temperature ";
buff = String((float)m_eddystoneData.temp, 1);
out += buff.c_str();
out += " °C\n";

out += "Adv. Count ";
buff = String(ENDIAN_CHANGE_U32(m_eddystoneData.advCount), DEC);
out += buff.c_str();
out += "\n";
ss << "Adv. Count ";
ss << std::dec << ENDIAN_CHANGE_U32(m_eddystoneData.advCount);

ss << "\n";

out += "Time ";
ss << "Time ";

rawsec = ENDIAN_CHANGE_U32(m_eddystoneData.tmil);
buff = "0000"+String(rawsec/864000, DEC);
out += buff.substring(buff.length()-4,buff.length()).c_str();
out += ".";
buff = "00"+String((rawsec/36000)%24, DEC);
out += buff.substring(buff.length()-2,buff.length()).c_str();
out += ":";
buff = "00"+String((rawsec/600)%60, DEC);
out += buff.substring(buff.length()-2,buff.length()).c_str();
out += ":";
buff = "00"+String((rawsec/10)%60, DEC);
out += buff.substring(buff.length()-2,buff.length()).c_str();
out += "\n";

return out;
std::stringstream buffstream;
buffstream << "0000";
buffstream << std::dec << rawsec/864000;
std::string buff = buffstream.str();

ss << buff.substr(buff.length()-4, buff.length());
ss << ".";

buffstream.str("");
buffstream.clear();
buffstream << "00";
buffstream << std::dec << (rawsec/36000)%24;
buff = buffstream.str();
ss << buff.substr(buff.length()-2, buff.length());
ss << ":";

buffstream.str("");
buffstream.clear();
buffstream << "00";
buffstream << std::dec << (rawsec/600)%60;
buff = buffstream.str();
ss << buff.substr(buff.length()-2, buff.length());
ss << ":";

buffstream.str("");
buffstream.clear();
buffstream << "00";
buffstream << std::dec << (rawsec/10)%60;
buff = buffstream.str();
ss << buff.substr(buff.length()-2, buff.length());
ss << "\n";

return ss.str();
} // toString

/**
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5f0a168

Please sign in to comment.