diff options
-rw-r--r-- | docs/notes.txt | 1 | ||||
-rw-r--r-- | src/AntChannel.cpp | 4 | ||||
-rw-r--r-- | src/AntChannel.hpp | 3 | ||||
-rw-r--r-- | src/AntFr310XT.cpp | 7 | ||||
-rw-r--r-- | src/AntFr310XT.hpp | 3 | ||||
-rw-r--r-- | src/AntMessage.cpp | 3 | ||||
-rw-r--r-- | src/AntMessage.hpp | 3 | ||||
-rw-r--r-- | src/AntMessenger.cpp | 4 | ||||
-rw-r--r-- | src/AntMessenger.hpp | 4 | ||||
-rw-r--r-- | src/FIT.cpp | 5 | ||||
-rw-r--r-- | src/FIT.hpp | 31 | ||||
-rw-r--r-- | src/GPX.cpp | 7 | ||||
-rw-r--r-- | src/GPX.hpp | 29 | ||||
-rw-r--r-- | src/GarminConvert.cpp | 7 | ||||
-rw-r--r-- | src/GarminConvert.hpp | 17 | ||||
-rw-r--r-- | src/antpm-downloader.cpp | 1 | ||||
-rw-r--r-- | src/antpm-fit2gpx.cpp | 1 | ||||
-rw-r--r-- | src/antpm-usbmon2ant.cpp | 1 |
18 files changed, 89 insertions, 42 deletions
diff --git a/docs/notes.txt b/docs/notes.txt index 450b7d6..ca41389 100644 --- a/docs/notes.txt +++ b/docs/notes.txt @@ -12,6 +12,7 @@ * ANTFS authentication * ANTFS download file * ANTFS erase file +* It generally helps to keep the watch close (20-30 cm) to the USB2ANT dongle while communicating. ** TODO * capture ant agent log: for downloading all, for erasing, for uploading diff --git a/src/AntChannel.cpp b/src/AntChannel.cpp index c24c0ae..7f04551 100644 --- a/src/AntChannel.cpp +++ b/src/AntChannel.cpp @@ -17,7 +17,7 @@ - +namespace antpm{ void AntChannel::addMsgListener2(AntListenerBase* lb) @@ -295,3 +295,5 @@ AntBurstListener::collectBurst(std::vector<uint8_t>& burstData, const size_t tim printf("ok: collectBurst: %d bytes\n", int(burstData.size())); return true; } + +} diff --git a/src/AntChannel.hpp b/src/AntChannel.hpp index 948da57..c585b61 100644 --- a/src/AntChannel.hpp +++ b/src/AntChannel.hpp @@ -15,6 +15,8 @@ #include <boost/thread.hpp> +namespace antpm{ + struct AntChannel; struct AntListenerBase @@ -101,3 +103,4 @@ struct AntBurstListener : public AntListenerBase bool collectBurst(std::vector<uint8_t>& burstData, const size_t timeout_ms); }; +} diff --git a/src/AntFr310XT.cpp b/src/AntFr310XT.cpp index 1dacc3a..74abee0 100644 --- a/src/AntFr310XT.cpp +++ b/src/AntFr310XT.cpp @@ -31,6 +31,11 @@ //#include <boost/property_tree/ptree.hpp> //#include <boost/property_tree/ini_parser.hpp> +using namespace std; + +namespace antpm{ + + const uchar net = 0x00; const uchar chan = 0x00; //const uint hostSN = 0x7c9101e0; // from Garmin ANT+ Agent @@ -579,3 +584,5 @@ AntFr310XT2::createDownloadFolder() //folder = getConfigFolder() + "/" + getDateString() + "/"; CHECK_RETURN(mkDir(folder.c_str())); } + +} diff --git a/src/AntFr310XT.hpp b/src/AntFr310XT.hpp index 6f6caf7..e698dc8 100644 --- a/src/AntFr310XT.hpp +++ b/src/AntFr310XT.hpp @@ -19,6 +19,7 @@ #include <boost/thread.hpp> #include "FIT.hpp" +namespace antpm{ struct AntFr310XT2_EventLoop; // State-machine for ANT+ communication with Forerunner 310XT. @@ -81,3 +82,5 @@ private: StateANTFS changeFSState(const StateANTFS newState); void createDownloadFolder(); }; + +} diff --git a/src/AntMessage.cpp b/src/AntMessage.cpp index 4e6c261..5db3ccc 100644 --- a/src/AntMessage.cpp +++ b/src/AntMessage.cpp @@ -27,6 +27,7 @@ using namespace std; +namespace antpm{ std::string antFSCommand2Str(uchar cmd) @@ -759,3 +760,5 @@ template bool AntMessage::saveAsAntParse<std::vector<AntMessage> >(const char* f template bool AntMessage::saveAsAntParse<std::list<AntMessage> >(std::ostream& os, const std::list<AntMessage>& messages); //template bool AntMessage::saveAsAntParse<std::queue<AntMessage> >(std::ostream& os, const std::queue<AntMessage>& messages); template bool AntMessage::saveAsAntParse<std::vector<AntMessage> >(std::ostream& os, const std::vector<AntMessage>& messages); + +} diff --git a/src/AntMessage.hpp b/src/AntMessage.hpp index 4f88271..85d87c2 100644 --- a/src/AntMessage.hpp +++ b/src/AntMessage.hpp @@ -22,6 +22,8 @@ #include <boost/thread/thread_time.hpp> +namespace antpm{ + std::string antFSCommand2Str(uchar cmd); std::string antFSResponse2Str(uchar resp); bool isAntFSCommandOrResponse(const uchar command, bool& isCommand); @@ -584,3 +586,4 @@ struct AntFsFile bool saveToFile(const char* fileName = "antfs.bin"); }; +} diff --git a/src/AntMessenger.cpp b/src/AntMessenger.cpp index def2fb0..e51d972 100644 --- a/src/AntMessenger.cpp +++ b/src/AntMessenger.cpp @@ -29,7 +29,7 @@ - +namespace antpm{ // runs in other thread struct AntMessenger_Recevier @@ -1143,7 +1143,7 @@ AntMessenger::th_messageHandler() } - +} diff --git a/src/AntMessenger.hpp b/src/AntMessenger.hpp index f5defe3..04fccfc 100644 --- a/src/AntMessenger.hpp +++ b/src/AntMessenger.hpp @@ -24,7 +24,7 @@ - +namespace antpm{ // Interface for delivering event of sent/received ANT+ messages. MUST be thread safe. class AntCallback @@ -165,7 +165,7 @@ private: - +} diff --git a/src/FIT.cpp b/src/FIT.cpp index b0a5270..ab66a34 100644 --- a/src/FIT.cpp +++ b/src/FIT.cpp @@ -42,6 +42,9 @@ using namespace std; +namespace antpm{ + + FIT::FIT() { messageTypeMap[0] = "File Id"; @@ -1219,3 +1222,5 @@ bool FIT::parseZeroFile(vector<uint8_t> &data, ZeroFileContent &zeroFileContent) return true; } + +} diff --git a/src/FIT.hpp b/src/FIT.hpp index e258259..845fb0a 100644 --- a/src/FIT.hpp +++ b/src/FIT.hpp @@ -40,7 +40,7 @@ #include <boost/static_assert.hpp> -using namespace std; +namespace antpm{ #pragma pack(1) @@ -158,7 +158,7 @@ enum BaseTypes struct RecordDef { RecordFixed rfx; - vector<RecordField> rf; + std::vector<RecordField> rf; }; enum MessageFieldTypes @@ -268,9 +268,9 @@ enum GarminProducts class ZeroFileContent { public: - vector<uint16_t> activityFiles; - vector<uint16_t> waypointsFiles; - vector<uint16_t> courseFiles; + std::vector<uint16_t> activityFiles; + std::vector<uint16_t> waypointsFiles; + std::vector<uint16_t> courseFiles; }; class FIT @@ -280,18 +280,19 @@ public: ~FIT(); uint16_t CRC_byte(uint16_t crc, uint8_t byte); - string getDataString(uint8_t *ptr, uint8_t size, uint8_t baseType, uint8_t messageType, uint8_t fieldNum); - bool parse(vector<uint8_t> &fitData, GPX &gpx); - bool parseZeroFile(vector<uint8_t> &data, ZeroFileContent &zeroFileContent); + std::string getDataString(uint8_t *ptr, uint8_t size, uint8_t baseType, uint8_t messageType, uint8_t fieldNum); + bool parse(std::vector<uint8_t> &fitData, GPX &gpx); + bool parseZeroFile(std::vector<uint8_t> &data, ZeroFileContent &zeroFileContent); private: - map<uint8_t, string> messageTypeMap; - map<uint8_t, map<uint8_t, string> > messageFieldNameMap; - map<uint8_t, map<uint8_t, uint8_t> > messageFieldTypeMap; - map<uint8_t, string> dataTypeMap; - map<uint8_t, map<uint8_t, string> > enumMap; - map<uint8_t, string> manufacturerMap; - map<uint8_t, map<uint16_t, string> > productMap; + std::map<uint8_t, std::string> messageTypeMap; + std::map<uint8_t, std::map<uint8_t, std::string> > messageFieldNameMap; + std::map<uint8_t, std::map<uint8_t, uint8_t> > messageFieldTypeMap; + std::map<uint8_t, std::string> dataTypeMap; + std::map<uint8_t, std::map<uint8_t, std::string> > enumMap; + std::map<uint8_t, std::string> manufacturerMap; + std::map<uint8_t, std::map<uint16_t, std::string> > productMap; int16_t manufacturer; }; +} diff --git a/src/GPX.cpp b/src/GPX.cpp index 4c17149..d5bedf4 100644 --- a/src/GPX.cpp +++ b/src/GPX.cpp @@ -34,6 +34,11 @@ #include <iomanip> #include "common.hpp" +using namespace std; + +namespace antpm{ + + WayPoint::WayPoint(): time(0), latitude(INT32_MAX), @@ -219,3 +224,5 @@ bool GPX::writeToFile(string fileName) return true; } + +} diff --git a/src/GPX.hpp b/src/GPX.hpp index 33bc5aa..76bf9ab 100644 --- a/src/GPX.hpp +++ b/src/GPX.hpp @@ -47,7 +47,7 @@ #define UINT32_MAX 0xFFFFFFFF //#endif -using namespace std; +namespace antpm{ class WayPoint { @@ -55,10 +55,10 @@ public: WayPoint(); ~WayPoint(); - void putToFile(ofstream &file); + void putToFile(std::ofstream &file); public: - string name; + std::string name; uint32_t time; int32_t latitude; int32_t longitude; @@ -71,7 +71,7 @@ public: TrackPoint(); ~TrackPoint(); - void putToFile(ofstream &file); + void putToFile(std::ofstream &file); public: uint32_t time; @@ -88,24 +88,24 @@ public: TrackSeg(); ~TrackSeg(); - void putToFile(ofstream &file); + void putToFile(std::ofstream &file); public: - map<uint32_t,TrackPoint> trackPoints; + std::map<uint32_t,TrackPoint> trackPoints; }; class Track { public: - Track(string &name); + Track(std::string &name); ~Track(); void newTrackSeg(); - void putToFile(ofstream &file); + void putToFile(std::ofstream &file); public: - string name; - vector<TrackSeg> trackSegs; + std::string name; + std::vector<TrackSeg> trackSegs; }; class GPX @@ -114,14 +114,15 @@ public: GPX(); ~GPX(); - void newTrack(string name); + void newTrack(std::string name); void newTrackSeg(); void newWayPoint(); - bool writeToFile(string fileName); + bool writeToFile(std::string fileName); public: - vector<WayPoint> wayPoints; - vector<Track> tracks; + std::vector<WayPoint> wayPoints; + std::vector<Track> tracks; }; +} diff --git a/src/GarminConvert.cpp b/src/GarminConvert.cpp index 7554b91..3172a56 100644 --- a/src/GarminConvert.cpp +++ b/src/GarminConvert.cpp @@ -37,6 +37,11 @@ #include <iomanip> #include <ctype.h> +using namespace std; + +namespace antpm{ + + double GarminConvert::coord(int32_t coord) { double rv = coord; @@ -160,3 +165,5 @@ string GarminConvert::hexDump(vector<uint8_t> &buf) return sstr.str(); } + +} diff --git a/src/GarminConvert.hpp b/src/GarminConvert.hpp index a0b17fe..b680e4c 100644 --- a/src/GarminConvert.hpp +++ b/src/GarminConvert.hpp @@ -37,7 +37,7 @@ #define GARMIN_EPOCH 631065600 -using namespace std; +namespace antpm{ class GarminConvert { @@ -47,12 +47,13 @@ public: static double length(uint32_t centimeters); static double speed(uint16_t speed); static double weight(uint16_t weight); - static string gmTime(uint32_t time); - static string localTime(uint32_t time); - static string gTime(uint32_t time); - static string gString(uint8_t *str, int maxSize); - static string gHex(uint8_t *buf, int size); - static string gHex(vector<uint8_t> &buf); - static string hexDump(vector<uint8_t> &buf); + static std::string gmTime(uint32_t time); + static std::string localTime(uint32_t time); + static std::string gTime(uint32_t time); + static std::string gString(uint8_t *str, int maxSize); + static std::string gHex(uint8_t *buf, int size); + static std::string gHex(std::vector<uint8_t> &buf); + static std::string hexDump(std::vector<uint8_t> &buf); }; +} diff --git a/src/antpm-downloader.cpp b/src/antpm-downloader.cpp index 8b5bfe1..7d9362c 100644 --- a/src/antpm-downloader.cpp +++ b/src/antpm-downloader.cpp @@ -31,6 +31,7 @@ namespace po = boost::program_options; using namespace std; +using namespace antpm; namespace antpm diff --git a/src/antpm-fit2gpx.cpp b/src/antpm-fit2gpx.cpp index 4147513..e9ce14c 100644 --- a/src/antpm-fit2gpx.cpp +++ b/src/antpm-fit2gpx.cpp @@ -27,6 +27,7 @@ namespace po = boost::program_options; namespace fs = boost::filesystem; using namespace std; +using namespace antpm; namespace antpm diff --git a/src/antpm-usbmon2ant.cpp b/src/antpm-usbmon2ant.cpp index a8a5332..5524657 100644 --- a/src/antpm-usbmon2ant.cpp +++ b/src/antpm-usbmon2ant.cpp @@ -24,6 +24,7 @@ namespace po = boost::program_options; using namespace std; +using namespace antpm; namespace antpm { |