Library for LoRa communication using MultiTech MDOT.

Dependents:   mDot_test_rx adc_sensor_lora mDotEVBM2X mDot_AT_firmware ... more

Function documentation is in mDot.h

Warning

Using libmDot 2.0.3 and above with an existing application may require a change in the MacEvent handler!
Compile applications with mbed v121 and mbed-rtos v116 libraries.

In AT Command Firmware remove line 803.

CommandTerminal/CommandTerminal.cpp

        delete[] info->RxBuffer;

Likewise, if your application is handling events from the library asynchronously.

Committer:
Mike Fiore
Date:
Tue Mar 29 10:18:28 2016 -0500
Revision:
11:9938ba31d428
Parent:
9:ebf682e616d0
update to version 1.0.7 of mDot library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 11:9938ba31d428 1 #ifndef MTSTEXT_H
Mike Fiore 11:9938ba31d428 2 #define MTSTEXT_H
Mike Fiore 11:9938ba31d428 3
Mike Fiore 11:9938ba31d428 4 #include <string>
Mike Fiore 11:9938ba31d428 5 #include <vector>
Mike Fiore 11:9938ba31d428 6 #include <stddef.h>
Mike Fiore 11:9938ba31d428 7 #include <stdint.h>
Mike Fiore 11:9938ba31d428 8 #include <stdio.h>
Mike Fiore 11:9938ba31d428 9 #include <string.h>
Mike Fiore 11:9938ba31d428 10
Mike Fiore 11:9938ba31d428 11 namespace mts
Mike Fiore 11:9938ba31d428 12 {
Mike Fiore 11:9938ba31d428 13
Mike Fiore 11:9938ba31d428 14 /** This class contains a number of static methods for manipulating strings and other
Mike Fiore 11:9938ba31d428 15 * text data.
Mike Fiore 11:9938ba31d428 16 */
Mike Fiore 11:9938ba31d428 17 class Text
Mike Fiore 11:9938ba31d428 18 {
Mike Fiore 11:9938ba31d428 19 public:
Mike Fiore 11:9938ba31d428 20 /** This static method can be used to pull out a string at the next line break. A
Mike Fiore 11:9938ba31d428 21 * break can either be a newline '\n', carriage return '\r' or both.
Mike Fiore 11:9938ba31d428 22 *
Mike Fiore 11:9938ba31d428 23 * @param source the source string to look for the line break on.
Mike Fiore 11:9938ba31d428 24 * @param start the start postion within the string to begin looking for the line
Mike Fiore 11:9938ba31d428 25 * break.
Mike Fiore 11:9938ba31d428 26 * @param cursor this value will be updated with the index for the next available character
Mike Fiore 11:9938ba31d428 27 * after the line break. If a line break is not found returns -1.
Mike Fiore 11:9938ba31d428 28 * @returns the string beginning with the start index up to including the line breaks.
Mike Fiore 11:9938ba31d428 29 */
Mike Fiore 11:9938ba31d428 30 static std::string getLine(const std::string& source, const size_t& start, size_t& cursor);
Mike Fiore 11:9938ba31d428 31
Mike Fiore 11:9938ba31d428 32 /** This is a static method for splitting strings using a delimeter value.
Mike Fiore 11:9938ba31d428 33 *
Mike Fiore 11:9938ba31d428 34 * @param str the string to try and split.
Mike Fiore 11:9938ba31d428 35 * @param delimiter the delimeter value to split on as a character.
Mike Fiore 11:9938ba31d428 36 * @param limit the maximum number of splits. If equal to 0 it splits as amny times as possible.
Mike Fiore 11:9938ba31d428 37 * The default is 0.
Mike Fiore 11:9938ba31d428 38 * @returns an ordered vector of strings conatining the splits of the original string.
Mike Fiore 11:9938ba31d428 39 */
Mike Fiore 11:9938ba31d428 40 static std::vector<std::string> split(const std::string& str, char delimiter, int limit = 0);
Mike Fiore 11:9938ba31d428 41
Mike Fiore 11:9938ba31d428 42 /** This is a static method for splitting strings using a delimeter value.
Mike Fiore 11:9938ba31d428 43 *
Mike Fiore 11:9938ba31d428 44 * @param str the string to try and split.
Mike Fiore 11:9938ba31d428 45 * @param delimiter the delimeter value to split on as a string.
Mike Fiore 11:9938ba31d428 46 * @param limit the maximum number of splits. If equal to 0 it splits as amny times as possible.
Mike Fiore 11:9938ba31d428 47 * The default is 0.
Mike Fiore 11:9938ba31d428 48 * @returns an ordered vector of strings conatining the splits of the original string.
Mike Fiore 11:9938ba31d428 49 */
Mike Fiore 11:9938ba31d428 50 static std::vector<std::string> split(const std::string& str, const std::string& delimiter, int limit = 0);
Mike Fiore 11:9938ba31d428 51
Mike Fiore 11:9938ba31d428 52 static std::string readString(char* index, int length);
Mike Fiore 11:9938ba31d428 53
Mike Fiore 11:9938ba31d428 54 static std::string toUpper(const std::string str);
Mike Fiore 11:9938ba31d428 55
Mike Fiore 11:9938ba31d428 56 static std::string float2String(double val, int precision);
Mike Fiore 11:9938ba31d428 57
Mike Fiore 11:9938ba31d428 58 static std::string bin2hexString(const std::vector<uint8_t>& data, const char* delim = "", bool leadingZeros = false, bool bytePadding = true);
Mike Fiore 7:683dba5d576f 59
Mike Fiore 11:9938ba31d428 60 static std::string bin2hexString(const uint8_t* data, const uint32_t len, const char* delim = "", bool leadingZeros = false, bool bytePadding = true);
Mike Fiore 11:9938ba31d428 61
Mike Fiore 11:9938ba31d428 62 static std::string bin2base64(const std::vector<uint8_t>& data);
Mike Fiore 11:9938ba31d428 63
Mike Fiore 11:9938ba31d428 64 static std::string bin2base64(const uint8_t* data, size_t size);
Mike Fiore 11:9938ba31d428 65
Mike Fiore 11:9938ba31d428 66 static bool base642bin(const std::string in, std::vector<uint8_t>& out);
Mike Fiore 1:9f30fbe9e9c1 67
Mike Fiore 1:9f30fbe9e9c1 68 static void ltrim(std::string& str, const char* args);
Mike Fiore 1:9f30fbe9e9c1 69
Mike Fiore 1:9f30fbe9e9c1 70 static void rtrim(std::string& str, const char* args);
Mike Fiore 1:9f30fbe9e9c1 71
Mike Fiore 1:9f30fbe9e9c1 72 static void trim(std::string& str, const char* args);
Mike Fiore 11:9938ba31d428 73
Mike Fiore 11:9938ba31d428 74 private:
Mike Fiore 11:9938ba31d428 75 // Safety for class with only static methods
Mike Fiore 11:9938ba31d428 76 Text();
Mike Fiore 11:9938ba31d428 77 Text(const Text& other);
Mike Fiore 11:9938ba31d428 78 Text& operator=(const Text& other);
Mike Fiore 11:9938ba31d428 79 };
Mike Fiore 11:9938ba31d428 80
Mike Fiore 11:9938ba31d428 81 }
Mike Fiore 11:9938ba31d428 82
Mike Fiore 11:9938ba31d428 83 #endif