diff options
author | kolban <kolban1@kolban.com> | 2017-10-13 10:52:17 -0500 |
---|---|---|
committer | kolban <kolban1@kolban.com> | 2017-10-13 10:52:17 -0500 |
commit | 34902f4e7fc6926a005a5ccfd4e530d6a6321613 (patch) | |
tree | 512593068ed656012ee31fced9526bff80ecad55 /src/GeneralUtils.cpp | |
parent | Merge pull request #5 from sebastiankliem/master (diff) | |
download | thermostat-34902f4e7fc6926a005a5ccfd4e530d6a6321613.tar.gz thermostat-34902f4e7fc6926a005a5ccfd4e530d6a6321613.tar.bz2 thermostat-34902f4e7fc6926a005a5ccfd4e530d6a6321613.zip |
Sync update for 0.4.3 take 2
Diffstat (limited to 'src/GeneralUtils.cpp')
-rw-r--r-- | src/GeneralUtils.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/GeneralUtils.cpp b/src/GeneralUtils.cpp index 4237b14..6bfde84 100644 --- a/src/GeneralUtils.cpp +++ b/src/GeneralUtils.cpp @@ -7,6 +7,7 @@ #include "GeneralUtils.h" #include <esp_log.h> +#include <esp_system.h> #include <string.h> #include <stdio.h> #include <string> @@ -106,6 +107,23 @@ bool GeneralUtils::base64Encode(const std::string &in, std::string *out) { } // base64Encode +/** + * @brief Does the string end with a specific character? + * @param [in] str The string to examine. + * @param [in] c The character to look form. + * @return True if the string ends with the given character. + */ +bool GeneralUtils::endsWith(std::string str, char c) { + if (str.empty()) { + return false; + } + if (str.at(str.length()-1) == c) { + return true; + } + return false; +} // endsWidth + + static int DecodedLength(const std::string &in) { int numEq = 0; int n = in.size(); @@ -261,7 +279,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) { * @param [in] length Length of the data (in bytes) to be logged. * @return N/A. */ -void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) { +void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) { char ascii[80]; char hex[80]; char tempBuf[80]; @@ -386,3 +404,9 @@ const char* GeneralUtils::errorToString(esp_err_t errCode) { return "Unknown ESP_ERR error"; } // errorToString +/** + * @brief Restart the ESP32. + */ +void GeneralUtils::restart() { + esp_restart(); +} // restart |