Changeset afa1e8
- Timestamp:
- 01/26/12 14:38:42 (4 months ago)
- Branches:
- ('master', 'deebf2045e7119c339412580f37a1e653f7d5715')('controller-upgrade', '00f95d22e12d96ef089e0902ef62ae8ce841dc6f')
- Children:
- ee8f3b41d0207f6a981fa9406fbed01fda1a7411
- Parents:
- bf72debefba5c47023afd5993290995c613e4185
- git-author:
- Stefan Persson <stefan.persson@telldus.se>2012-01-26 14:38:42+01:00
- git-committer:
- Stefan Persson <stefan.persson@telldus.se>2012-01-26 14:38:42+01:00
- Location:
- telldus-core
- Files:
-
- 5 edited
-
common/Strings.cpp (modified) (1 diff)
-
common/Strings.h (modified) (2 diffs)
-
service/ProtocolFineoffset.cpp (modified) (3 diffs)
-
service/ProtocolMandolyn.cpp (modified) (1 diff)
-
service/ProtocolOregon.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
telldus-core/common/Strings.cpp
r2ec2da rafa1e8 145 145 */ 146 146 147 uint64_t TelldusCore::hexTo64l(const std::string data){ 148 #ifdef _WINDOWS 149 return _strtoui64(data.c_str(), NULL, 16); 150 #else 151 return strtol(data.c_str(), NULL, 16); 152 #endif 153 } 154 147 155 int TelldusCore::wideToInteger(const std::wstring &input){ 148 156 std::wstringstream inputstream; -
telldus-core/common/Strings.h
r716deb rafa1e8 4 4 #include <string> 5 5 #include <stdarg.h> 6 #ifdef _MSC_VER 7 typedef unsigned __int8 uint8_t; 8 typedef unsigned __int16 uint16_t; 9 typedef unsigned __int32 uint32_t; 10 typedef unsigned __int64 uint64_t; 11 #else 12 #include <stdint.h> 13 #endif 6 14 7 15 namespace TelldusCore { … … 14 22 //std::wstring intToWStringSafe(int value); 15 23 std::string intToString(int value); 24 uint64_t hexTo64l(const std::string data); 16 25 std::string wideToString(const std::wstring &input); 17 26 -
telldus-core/service/ProtocolFineoffset.cpp
racdf57 rafa1e8 1 1 #include "ProtocolFineoffset.h" 2 #include "Strings.h" 2 3 #include <stdlib.h> 3 4 #include <sstream> 4 5 #include <iomanip> 5 #ifdef _MSC_VER6 typedef unsigned __int8 uint8_t;7 typedef unsigned __int16 uint16_t;8 #else9 #include <stdint.h>10 #endif11 6 12 7 std::string ProtocolFineoffset::decodeData(ControllerMessage &dataMsg) … … 17 12 } 18 13 19 uint8_t checksum = strtol(data.substr(data.length()-2).c_str(), NULL, 16);14 uint8_t checksum = (uint8_t)TelldusCore::hexTo64l(data.substr(data.length()-2)); 20 15 data = data.substr(0, data.length()-2); 21 16 22 uint8_t humidity = strtol(data.substr(data.length()-2).c_str(), NULL, 16);17 uint8_t humidity = (uint8_t)TelldusCore::hexTo64l(data.substr(data.length()-2)); 23 18 data = data.substr(0, data.length()-2); 24 19 25 uint16_t value = strtol(data.substr(data.length()-3).c_str(), NULL, 16);20 uint16_t value = (uint16_t)TelldusCore::hexTo64l(data.substr(data.length()-3)); 26 21 double temperature = (value & 0x7FF)/10.0; 27 22 … … 32 27 data = data.substr(0, data.length()-3); 33 28 34 uint16_t id = strtol(data.c_str(), NULL, 16) & 0xFF;29 uint16_t id = (uint16_t)TelldusCore::hexTo64l(data) & 0xFF; 35 30 36 31 std::stringstream retString; -
telldus-core/service/ProtocolMandolyn.cpp
r16a9b8 rafa1e8 1 1 #include "ProtocolMandolyn.h" 2 #include "Strings.h" 2 3 #include <stdlib.h> 3 4 #include <sstream> 4 5 #include <iomanip> 5 6 6 #ifdef _MSC_VER7 typedef unsigned __int8 uint8_t;8 typedef unsigned __int32 uint32_t;9 #else10 #include <stdint.h>11 #endif12 13 7 std::string ProtocolMandolyn::decodeData(ControllerMessage &dataMsg) 14 8 { 15 9 std::string data = dataMsg.getParameter("data"); 16 uint32_t value = strtol(data.c_str(), NULL, 16);10 uint32_t value = (uint32_t)TelldusCore::hexTo64l(data); 17 11 18 12 bool parity = value & 0x1; -
telldus-core/service/ProtocolOregon.cpp
rf58793 rafa1e8 1 1 #include "ProtocolOregon.h" 2 #include "Strings.h" 2 3 #include <stdlib.h> 3 4 #include <sstream> 4 5 #include <iomanip> 5 #ifdef _MSC_VER6 typedef unsigned __int8 uint8_t;7 typedef unsigned __int64 uint64_t;8 #else9 #include <stdint.h>10 #endif11 6 12 7 std::string ProtocolOregon::decodeData(ControllerMessage &dataMsg) … … 25 20 26 21 std::string ProtocolOregon::decodeEA4C(const std::string &data) { 27 uint64_t value = strtol(data.c_str(), NULL, 16);28 22 uint64_t value = TelldusCore::hexTo64l(data); 23 29 24 uint8_t checksum = 0xE + 0xA + 0x4 + 0xC; 30 25 checksum -= (value & 0xF) * 0x10; … … 70 65 71 66 std::string ProtocolOregon::decode1A2D(const std::string &data) { 72 uint64_t value = strtol(data.c_str(), NULL, 16);67 uint64_t value = TelldusCore::hexTo64l(data); 73 68 uint8_t checksum2 = value & 0xFF; 74 69 value >>= 8;
Note: See TracChangeset
for help on using the changeset viewer.
