Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mDot_LoRa_Sensornode
Fork of libmDot by
Revision 9:ebf682e616d0, committed 2015-09-10
- Comitter:
- Mike Fiore
- Date:
- Thu Sep 10 13:16:42 2015 -0500
- Parent:
- 8:57978a837b2d
- Child:
- 10:0b4eb17d07ae
- Commit message:
- update README, move files into new directory structure
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MTS-Utils/MTSCircularBuffer.h Thu Sep 10 13:16:42 2015 -0500
@@ -0,0 +1,165 @@
+/************************************************
+ * MultiTech MTDOT Library
+ * Copyright (c) 2015 MultiTech Systems
+ *
+ * See LICENSE file for license information
+ ***********************************************/
+
+#ifndef MTSCIRCULARBUFFER_H
+#define MTSCIRCULARBUFFER_H
+
+#include "Utils.h"
+
+namespace mts
+{
+
+/** This class provides a circular byte buffer meant for temporary storage
+* during IO transactions. It contains many of the common methods you
+* would expect from a circular buffer like read, write, and various
+* methods for checking the size or status. It should be noted that
+* this class does not include any special code for thread safety like
+* a lock. In most cases this is not problematic, but is something
+* to be aware of.
+*/
+class MTSCircularBuffer
+{
+public:
+ /** Creates an MTSCircularBuffer object with the specified static size.
+ *
+ * @prarm bufferSize size of the buffer in bytes.
+ */
+ MTSCircularBuffer(int bufferSize);
+
+ /** Destructs an MTSCircularBuffer object and frees all related resources.
+ */
+ ~MTSCircularBuffer();
+
+ /** This method enables bulk reads from the buffer. If more data is
+ * requested then available it simply returns all remaining data within the
+ * buffer.
+ *
+ * @param data the buffer where data read will be added to.
+ * @param length the amount of data in bytes to be read into the buffer.
+ * @returns the total number of bytes that were read.
+ */
+ int read(char* data, int length);
+
+ /** This method reads a single byte from the buffer.
+ *
+ * @param data char where the read byte will be stored.
+ * @returns 1 if byte is read or 0 if no bytes available.
+ */
+ int read(char& data);
+
+ /** This method enables bulk writes to the buffer. If more data
+ * is requested to be written then space available the method writes
+ * as much data as possible and returns the actual amount written.
+ *
+ * @param data the byte array to be written.
+ * @param length the length of data to be written from the data paramter.
+ * @returns the number of bytes written to the buffer, which is 0 if
+ * the buffer is full.
+ */
+ int write(const char* data, int length);
+
+ /** This method writes a signle byte as a char to the buffer.
+ *
+ * @param data the byte to be written as a char.
+ * @returns 1 if the byte was written or 0 if the buffer was full.
+ */
+ int write(char data);
+
+ /** This method is used to setup a callback funtion when the buffer reaches
+ * a certain threshold. The threshold condition is checked after every read
+ * and write call is completed. The condition is made up of both a threshold
+ * value and operator. An example that would trigger a callback is if the
+ * threshold was 10, the operator GREATER, and there were 12 bytes added to an
+ * empty buffer.
+ *
+ * @param tptr a pointer to the object to be called when the condition is met.
+ * @param mptr a pointer to the function within the object to be called when
+ * the condition is met.
+ * @param threshold the value in bytes to be used as part of the condition.
+ * @param op the operator to be used in conjunction with the threshold
+ * as part of the condition.
+ */
+ template<typename T>
+ void attach(T *tptr, void( T::*mptr)(void), int threshold, RelationalOperator op) {
+ _threshold = threshold;
+ _op = op;
+ notify.attach(tptr, mptr);
+ }
+
+ /** This method is used to setup a callback funtion when the buffer reaches
+ * a certain threshold. The threshold condition is checked after every read
+ * and write call is completed. The condition is made up of both a threshold
+ * value and operator. An example that would trigger a callback is if the
+ * threshold was 10, the operator GREATER, and there were 12 bytes added to an
+ * empty buffer.
+ *
+ * @param fptr a pointer to the static function to be called when the condition
+ * is met.
+ * @param threshold the value in bytes to be used as part of the condition.
+ * @param op the operator to be used in conjunction with the threshold
+ * as part of the condition.
+ */
+ void attach(void(*fptr)(void), int threshold, RelationalOperator op) {
+ _threshold = threshold;
+ _op = op;
+ notify.attach(fptr);
+ }
+
+ /** This method returns the size of the storage space currently allocated for
+ * the buffer. This value is equivalent to the one passed into the constructor.
+ * This value is equal or greater than the size() of the buffer.
+ *
+ * @returns the allocated size of the buffer in bytes.
+ */
+ int capacity();
+
+ /** This method returns the amount of space left for writing.
+ *
+ * @returns numbers of unused bytes in buffer.
+ */
+ int remaining();
+
+ /** This method returns the number of bytes available for reading.
+ *
+ * @returns number of bytes currently in buffer.
+ */
+ int size();
+
+ /** This method returns whether the buffer is full.
+ *
+ * @returns true if full, otherwise false.
+ */
+ bool isFull();
+
+ /** This method returns whether the buffer is empty.
+ *
+ * @returns true if empty, otherwise false.
+ */
+ bool isEmpty();
+
+ /** This method clears the buffer. This is done through
+ * setting the internal read and write indexes to the same
+ * value and is therefore not an expensive operation.
+ */
+ void clear();
+
+
+private:
+ int bufferSize; // total size of the buffer
+ char* buffer; // internal byte buffer as a character buffer
+ int readIndex; // read index for circular buffer
+ int writeIndex; // write index for circular buffer
+ int bytes; // available data
+ FunctionPointer notify; // function pointer used for the internal callback notification
+ int _threshold; // threshold for the notification
+ RelationalOperator _op; // operator that determines the direction of the threshold
+ void checkThreshold(); // private function that checks thresholds and processes notifications
+};
+
+}
+
+#endif /* MTSCIRCULARBUFFER_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MTS-Utils/MTSLog.h Thu Sep 10 13:16:42 2015 -0500
@@ -0,0 +1,99 @@
+/************************************************
+ * MultiTech MTDOT Library
+ * Copyright (c) 2015 MultiTech Systems
+ *
+ * See LICENSE file for license information
+ ***********************************************/
+
+#ifndef MTSLOG_H
+#define MTSLOG_H
+
+#ifdef MTS_DEBUG
+#define logFatal(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__)
+#define logError(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__)
+#define logWarning(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__)
+#define logInfo(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::INFO_LABEL, ##__VA_ARGS__)
+#define logDebug(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__)
+#define logTrace(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
+#else
+#define logFatal(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "[%s] " format "\r\n", mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__)
+#define logError(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "[%s] " format "\r\n", mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__)
+#define logWarning(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "[%s] " format "\r\n", mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__)
+#define logInfo(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "[%s] " format "\r\n", mts::MTSLog::INFO_LABEL, ##__VA_ARGS__)
+#define logDebug(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "[%s] " format "\r\n", mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__)
+#define logTrace(format, ...) \
+ mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "[%s] " format "\r\n", mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
+#endif
+
+namespace mts {
+
+class MTSLog
+{
+public:
+
+ /** Enum of log levels.
+ */
+ enum logLevel {
+ NONE_LEVEL = 0,
+ FATAL_LEVEL = 1,
+ ERROR_LEVEL = 2,
+ WARNING_LEVEL = 3,
+ INFO_LEVEL = 4,
+ DEBUG_LEVEL = 5,
+ TRACE_LEVEL = 6
+ };
+
+ /** Print log message.
+ */
+ static void printMessage(int level, const char* format, ...);
+
+ /** Determine if the given level is currently printable.
+ */
+ static bool printable(int level);
+
+ /** Set log level
+ * Messages with lower priority than the current level will not be printed.
+ * If the level is set to NONE, no messages will print.
+ */
+ static void setLogLevel(int level);
+
+ /** Get the current log level.
+ */
+ static int getLogLevel();
+
+ /** Get string representation of the current log level.
+ */
+ static const char* getLogLevelString();
+
+ static const char* NONE_LABEL;
+ static const char* FATAL_LABEL;
+ static const char* ERROR_LABEL;
+ static const char* WARNING_LABEL;
+ static const char* INFO_LABEL;
+ static const char* DEBUG_LABEL;
+ static const char* TRACE_LABEL;
+
+private:
+
+ /** Constructor
+ */
+ MTSLog();
+
+ static int currentLevel;
+
+};
+
+}
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MTS-Utils/MTSText.h Thu Sep 10 13:16:42 2015 -0500
@@ -0,0 +1,90 @@
+/************************************************
+ * MultiTech MTDOT Library
+ * Copyright (c) 2015 MultiTech Systems
+ *
+ * See LICENSE file for license information
+ ***********************************************/
+
+#ifndef MTSTEXT_H
+#define MTSTEXT_H
+
+#include <string>
+#include <vector>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+namespace mts
+{
+
+/** This class contains a number of static methods for manipulating strings and other
+* text data.
+*/
+class Text
+{
+public:
+ /** This static method can be used to pull out a string at the next line break. A
+ * break can either be a newline '\n', carriage return '\r' or both.
+ *
+ * @param source the source string to look for the line break on.
+ * @param start the start postion within the string to begin looking for the line
+ * break.
+ * @param cursor this value will be updated with the index for the next available character
+ * after the line break. If a line break is not found returns -1.
+ * @returns the string beginning with the start index up to including the line breaks.
+ */
+ static std::string getLine(const std::string& source, const size_t& start, size_t& cursor);
+
+ /** This is a static method for splitting strings using a delimeter value.
+ *
+ * @param str the string to try and split.
+ * @param delimiter the delimeter value to split on as a character.
+ * @param limit the maximum number of splits. If equal to 0 it splits as amny times as possible.
+ * The default is 0.
+ * @returns an ordered vector of strings conatining the splits of the original string.
+ */
+ static std::vector<std::string> split(const std::string& str, char delimiter, int limit = 0);
+
+ /** This is a static method for splitting strings using a delimeter value.
+ *
+ * @param str the string to try and split.
+ * @param delimiter the delimeter value to split on as a string.
+ * @param limit the maximum number of splits. If equal to 0 it splits as amny times as possible.
+ * The default is 0.
+ * @returns an ordered vector of strings conatining the splits of the original string.
+ */
+ static std::vector<std::string> split(const std::string& str, const std::string& delimiter, int limit = 0);
+
+ static std::string readString(char* index, int length);
+
+ static std::string toUpper(const std::string str);
+
+ static std::string float2String(double val, int precision);
+
+ static std::string bin2hexString(const std::vector<uint8_t>& data, const char* delim = "", bool leadingZeros = false);
+
+ static std::string bin2hexString(const uint8_t* data, const uint32_t len, const char* delim = "", bool leadingZeros = false);
+
+ static std::string bin2base64(const std::vector<uint8_t>& data);
+
+ static std::string bin2base64(const uint8_t* data, size_t size);
+
+ static bool base642bin(const std::string in, std::vector<uint8_t>& out);
+
+ static void ltrim(std::string& str, const char* args);
+
+ static void rtrim(std::string& str, const char* args);
+
+ static void trim(std::string& str, const char* args);
+
+private:
+ // Safety for class with only static methods
+ Text();
+ Text(const Text& other);
+ Text& operator=(const Text& other);
+};
+
+}
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MTS-Utils/Utils.h Thu Sep 10 13:16:42 2015 -0500
@@ -0,0 +1,48 @@
+/************************************************
+ * MultiTech MTDOT Library
+ * Copyright (c) 2015 MultiTech Systems
+ *
+ * See LICENSE file for license information
+ ***********************************************/
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <string>
+
+//Defines a max function that can be used.
+inline int mts_max(int a, int b) { return a > b ? a : b; }
+
+//Defines a min function that can be used.
+inline int mts_min(int a, int b) { return a < b ? a : b; }
+
+///An enumeration for relational operators
+enum RelationalOperator {
+ GREATER, LESS, EQUAL, GREATER_EQUAL, LESS_EQUAL
+};
+
+/** A static method for getting a string representation for the RelationalOperator
+* enumeration.
+*
+* @param relationalOperator a RelationalOperator enumeration.
+* @returns the enumeration name as a string.
+*/
+static std::string getRelationalOperatorNames(RelationalOperator relationalOperator)
+{
+ switch(relationalOperator) {
+ case GREATER:
+ return "GREATER";
+ case LESS:
+ return "LESS";
+ case EQUAL:
+ return "EQUAL";
+ case GREATER_EQUAL:
+ return "GREATER_EQUAL";
+ case LESS_EQUAL:
+ return "LESS_EQUAL";
+ default:
+ return "UNKNOWN ENUM";
+ }
+}
+
+#endif
--- a/MTSCircularBuffer.h Tue Aug 18 09:11:29 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/************************************************
- * MultiTech MTDOT Library
- * Copyright (c) 2015 MultiTech Systems
- *
- * See LICENSE file for license information
- ***********************************************/
-
-#ifndef MTSCIRCULARBUFFER_H
-#define MTSCIRCULARBUFFER_H
-
-#include "Utils.h"
-
-namespace mts
-{
-
-/** This class provides a circular byte buffer meant for temporary storage
-* during IO transactions. It contains many of the common methods you
-* would expect from a circular buffer like read, write, and various
-* methods for checking the size or status. It should be noted that
-* this class does not include any special code for thread safety like
-* a lock. In most cases this is not problematic, but is something
-* to be aware of.
-*/
-class MTSCircularBuffer
-{
-public:
- /** Creates an MTSCircularBuffer object with the specified static size.
- *
- * @prarm bufferSize size of the buffer in bytes.
- */
- MTSCircularBuffer(int bufferSize);
-
- /** Destructs an MTSCircularBuffer object and frees all related resources.
- */
- ~MTSCircularBuffer();
-
- /** This method enables bulk reads from the buffer. If more data is
- * requested then available it simply returns all remaining data within the
- * buffer.
- *
- * @param data the buffer where data read will be added to.
- * @param length the amount of data in bytes to be read into the buffer.
- * @returns the total number of bytes that were read.
- */
- int read(char* data, int length);
-
- /** This method reads a single byte from the buffer.
- *
- * @param data char where the read byte will be stored.
- * @returns 1 if byte is read or 0 if no bytes available.
- */
- int read(char& data);
-
- /** This method enables bulk writes to the buffer. If more data
- * is requested to be written then space available the method writes
- * as much data as possible and returns the actual amount written.
- *
- * @param data the byte array to be written.
- * @param length the length of data to be written from the data paramter.
- * @returns the number of bytes written to the buffer, which is 0 if
- * the buffer is full.
- */
- int write(const char* data, int length);
-
- /** This method writes a signle byte as a char to the buffer.
- *
- * @param data the byte to be written as a char.
- * @returns 1 if the byte was written or 0 if the buffer was full.
- */
- int write(char data);
-
- /** This method is used to setup a callback funtion when the buffer reaches
- * a certain threshold. The threshold condition is checked after every read
- * and write call is completed. The condition is made up of both a threshold
- * value and operator. An example that would trigger a callback is if the
- * threshold was 10, the operator GREATER, and there were 12 bytes added to an
- * empty buffer.
- *
- * @param tptr a pointer to the object to be called when the condition is met.
- * @param mptr a pointer to the function within the object to be called when
- * the condition is met.
- * @param threshold the value in bytes to be used as part of the condition.
- * @param op the operator to be used in conjunction with the threshold
- * as part of the condition.
- */
- template<typename T>
- void attach(T *tptr, void( T::*mptr)(void), int threshold, RelationalOperator op) {
- _threshold = threshold;
- _op = op;
- notify.attach(tptr, mptr);
- }
-
- /** This method is used to setup a callback funtion when the buffer reaches
- * a certain threshold. The threshold condition is checked after every read
- * and write call is completed. The condition is made up of both a threshold
- * value and operator. An example that would trigger a callback is if the
- * threshold was 10, the operator GREATER, and there were 12 bytes added to an
- * empty buffer.
- *
- * @param fptr a pointer to the static function to be called when the condition
- * is met.
- * @param threshold the value in bytes to be used as part of the condition.
- * @param op the operator to be used in conjunction with the threshold
- * as part of the condition.
- */
- void attach(void(*fptr)(void), int threshold, RelationalOperator op) {
- _threshold = threshold;
- _op = op;
- notify.attach(fptr);
- }
-
- /** This method returns the size of the storage space currently allocated for
- * the buffer. This value is equivalent to the one passed into the constructor.
- * This value is equal or greater than the size() of the buffer.
- *
- * @returns the allocated size of the buffer in bytes.
- */
- int capacity();
-
- /** This method returns the amount of space left for writing.
- *
- * @returns numbers of unused bytes in buffer.
- */
- int remaining();
-
- /** This method returns the number of bytes available for reading.
- *
- * @returns number of bytes currently in buffer.
- */
- int size();
-
- /** This method returns whether the buffer is full.
- *
- * @returns true if full, otherwise false.
- */
- bool isFull();
-
- /** This method returns whether the buffer is empty.
- *
- * @returns true if empty, otherwise false.
- */
- bool isEmpty();
-
- /** This method clears the buffer. This is done through
- * setting the internal read and write indexes to the same
- * value and is therefore not an expensive operation.
- */
- void clear();
-
-
-private:
- int bufferSize; // total size of the buffer
- char* buffer; // internal byte buffer as a character buffer
- int readIndex; // read index for circular buffer
- int writeIndex; // write index for circular buffer
- int bytes; // available data
- FunctionPointer notify; // function pointer used for the internal callback notification
- int _threshold; // threshold for the notification
- RelationalOperator _op; // operator that determines the direction of the threshold
- void checkThreshold(); // private function that checks thresholds and processes notifications
-};
-
-}
-
-#endif /* MTSCIRCULARBUFFER_H */
--- a/MTSLog.h Tue Aug 18 09:11:29 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/************************************************
- * MultiTech MTDOT Library
- * Copyright (c) 2015 MultiTech Systems
- *
- * See LICENSE file for license information
- ***********************************************/
-
-#ifndef MTSLOG_H
-#define MTSLOG_H
-
-#ifdef MTS_DEBUG
-#define logFatal(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__)
-#define logError(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__)
-#define logWarning(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__)
-#define logInfo(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::INFO_LABEL, ##__VA_ARGS__)
-#define logDebug(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__)
-#define logTrace(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
-#else
-#define logFatal(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "[%s] " format "\r\n", mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__)
-#define logError(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "[%s] " format "\r\n", mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__)
-#define logWarning(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "[%s] " format "\r\n", mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__)
-#define logInfo(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "[%s] " format "\r\n", mts::MTSLog::INFO_LABEL, ##__VA_ARGS__)
-#define logDebug(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "[%s] " format "\r\n", mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__)
-#define logTrace(format, ...) \
- mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "[%s] " format "\r\n", mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
-#endif
-
-namespace mts {
-
-class MTSLog
-{
-public:
-
- /** Enum of log levels.
- */
- enum logLevel {
- NONE_LEVEL = 0,
- FATAL_LEVEL = 1,
- ERROR_LEVEL = 2,
- WARNING_LEVEL = 3,
- INFO_LEVEL = 4,
- DEBUG_LEVEL = 5,
- TRACE_LEVEL = 6
- };
-
- /** Print log message.
- */
- static void printMessage(int level, const char* format, ...);
-
- /** Determine if the given level is currently printable.
- */
- static bool printable(int level);
-
- /** Set log level
- * Messages with lower priority than the current level will not be printed.
- * If the level is set to NONE, no messages will print.
- */
- static void setLogLevel(int level);
-
- /** Get the current log level.
- */
- static int getLogLevel();
-
- /** Get string representation of the current log level.
- */
- static const char* getLogLevelString();
-
- static const char* NONE_LABEL;
- static const char* FATAL_LABEL;
- static const char* ERROR_LABEL;
- static const char* WARNING_LABEL;
- static const char* INFO_LABEL;
- static const char* DEBUG_LABEL;
- static const char* TRACE_LABEL;
-
-private:
-
- /** Constructor
- */
- MTSLog();
-
- static int currentLevel;
-
-};
-
-}
-
-#endif
--- a/MTSText.h Tue Aug 18 09:11:29 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/************************************************
- * MultiTech MTDOT Library
- * Copyright (c) 2015 MultiTech Systems
- *
- * See LICENSE file for license information
- ***********************************************/
-
-#ifndef MTSTEXT_H
-#define MTSTEXT_H
-
-#include <string>
-#include <vector>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-
-namespace mts
-{
-
-/** This class contains a number of static methods for manipulating strings and other
-* text data.
-*/
-class Text
-{
-public:
- /** This static method can be used to pull out a string at the next line break. A
- * break can either be a newline '\n', carriage return '\r' or both.
- *
- * @param source the source string to look for the line break on.
- * @param start the start postion within the string to begin looking for the line
- * break.
- * @param cursor this value will be updated with the index for the next available character
- * after the line break. If a line break is not found returns -1.
- * @returns the string beginning with the start index up to including the line breaks.
- */
- static std::string getLine(const std::string& source, const size_t& start, size_t& cursor);
-
- /** This is a static method for splitting strings using a delimeter value.
- *
- * @param str the string to try and split.
- * @param delimiter the delimeter value to split on as a character.
- * @param limit the maximum number of splits. If equal to 0 it splits as amny times as possible.
- * The default is 0.
- * @returns an ordered vector of strings conatining the splits of the original string.
- */
- static std::vector<std::string> split(const std::string& str, char delimiter, int limit = 0);
-
- /** This is a static method for splitting strings using a delimeter value.
- *
- * @param str the string to try and split.
- * @param delimiter the delimeter value to split on as a string.
- * @param limit the maximum number of splits. If equal to 0 it splits as amny times as possible.
- * The default is 0.
- * @returns an ordered vector of strings conatining the splits of the original string.
- */
- static std::vector<std::string> split(const std::string& str, const std::string& delimiter, int limit = 0);
-
- static std::string readString(char* index, int length);
-
- static std::string toUpper(const std::string str);
-
- static std::string float2String(double val, int precision);
-
- static std::string bin2hexString(const std::vector<uint8_t>& data, const char* delim = "", bool leadingZeros = false);
-
- static std::string bin2hexString(const uint8_t* data, const uint32_t len, const char* delim = "", bool leadingZeros = false);
-
- static std::string bin2base64(const std::vector<uint8_t>& data);
-
- static std::string bin2base64(const uint8_t* data, size_t size);
-
- static bool base642bin(const std::string in, std::vector<uint8_t>& out);
-
- static void ltrim(std::string& str, const char* args);
-
- static void rtrim(std::string& str, const char* args);
-
- static void trim(std::string& str, const char* args);
-
-private:
- // Safety for class with only static methods
- Text();
- Text(const Text& other);
- Text& operator=(const Text& other);
-};
-
-}
-
-#endif
--- a/README.txt Tue Aug 18 09:11:29 2015 -0500 +++ b/README.txt Thu Sep 10 13:16:42 2015 -0500 @@ -6,19 +6,9 @@ License information can be found in the accompanying LICENSE file. -The mDot header has documentation for all the public functions that will be useful to consumers of -the library. - -The following source code provides an example application which configures the mDot, connects to a -MultiTech Conduit gateway with matching configuration, and sends data packets to the gateway. +The mDot header has documentation for all the public functions that will be useful to consumers of the library. -NOTE: All applications built using the mDot library must include mbed-src instead of mbed and must -have the "newboards" beta token enabled. This is to resolve a stack size issue that may be -encountered otherwise. A fix is on its way to the regular mbed library, but these extra steps are -required until then. To enable the "newboards" beta token, go to the page listed below, click -enable, and completely refresh your online compiler. - -https://developer.mbed.org/betamode/?pre=newboards +The following source code provides an example application which configures the mDot, connects to a MultiTech Conduit gateway with matching configuration, and sends data packets to the gateway. /************** SAMPLE CODE
--- a/Utils.h Tue Aug 18 09:11:29 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/************************************************
- * MultiTech MTDOT Library
- * Copyright (c) 2015 MultiTech Systems
- *
- * See LICENSE file for license information
- ***********************************************/
-
-#ifndef UTILS_H
-#define UTILS_H
-
-#include <string>
-
-//Defines a max function that can be used.
-inline int mts_max(int a, int b) { return a > b ? a : b; }
-
-//Defines a min function that can be used.
-inline int mts_min(int a, int b) { return a < b ? a : b; }
-
-///An enumeration for relational operators
-enum RelationalOperator {
- GREATER, LESS, EQUAL, GREATER_EQUAL, LESS_EQUAL
-};
-
-/** A static method for getting a string representation for the RelationalOperator
-* enumeration.
-*
-* @param relationalOperator a RelationalOperator enumeration.
-* @returns the enumeration name as a string.
-*/
-static std::string getRelationalOperatorNames(RelationalOperator relationalOperator)
-{
- switch(relationalOperator) {
- case GREATER:
- return "GREATER";
- case LESS:
- return "LESS";
- case EQUAL:
- return "EQUAL";
- case GREATER_EQUAL:
- return "GREATER_EQUAL";
- case LESS_EQUAL:
- return "LESS_EQUAL";
- default:
- return "UNKNOWN ENUM";
- }
-}
-
-#endif
