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