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.
LoRa.h
00001 /* Copyright (c) 2015 Vertical M2M, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef __LORA__ 00020 #define __LORA__ 00021 #include "mbed.h" 00022 #include "mDot.h" 00023 #include <string> 00024 #include <list> 00025 00026 #define LORA_PACKET_MAX_SIZE 51 00027 00028 struct LoRaConfig_t { 00029 /** 00030 * LoRa Network name 00031 */ 00032 std::string networkName; 00033 00034 /** 00035 * LoRa Network key pass 00036 */ 00037 std::string networkPassphrase; 00038 00039 /** 00040 * LoRa Frequence sub band 00041 */ 00042 uint8_t subBand; 00043 00044 /** 00045 * LoRa Spreading factor 00046 */ 00047 mDot::DataRates spreadingFactor; 00048 00049 /** 00050 * Delay in second for seending keepalive 00051 */ 00052 uint16_t loraDelayForKeepAlive; 00053 00054 /** 00055 * Delay in second between LoRa message 00056 */ 00057 uint16_t loraMinDelayBetweenMessage; 00058 }; 00059 00060 class LoRa 00061 { 00062 public: 00063 LoRa(); 00064 ~LoRa(); 00065 00066 bool init(LoRaConfig_t p_config); 00067 bool connect(); 00068 00069 std::string getError(); 00070 std::string getVersion(); 00071 00072 void send(const std::string text); 00073 std::string receive(); 00074 00075 void PeriodicTimer(); 00076 00077 private: 00078 enum SendResult { 00079 e_srOK, 00080 e_srWaitMore, 00081 e_srError 00082 }; 00083 00084 bool setupNetwork(); 00085 00086 SendResult _send(const std::string text); 00087 std::string _receive(); 00088 00089 /** 00090 * List of string to send 00091 */ 00092 std::list<std::string> m_toSend; 00093 00094 /** 00095 * List of string to getted 00096 */ 00097 std::list<std::string> m_readed; 00098 00099 int m_errorCode; 00100 mDot* m_dot; 00101 00102 /** 00103 * LoRa protectoin timer 00104 */ 00105 time_t m_nextSend; 00106 time_t m_nextKeepalive; 00107 00108 /** 00109 * Current message to send, next time 00110 */ 00111 std::string m_currentMessage; 00112 00113 /** 00114 * Delay in second for seending keepalive 00115 */ 00116 uint16_t m_delayForKeepAlive; 00117 00118 /** 00119 * Delay in second between LoRa message 00120 */ 00121 uint16_t m_minDelayBetweenMessage; 00122 }; 00123 00124 #endif
Generated on Wed Jul 13 2022 01:56:24 by
1.7.2