A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LoRa.h Source File

LoRa.h

Go to the documentation of this file.
00001 /**
00002  * @file LoRa.h
00003  *
00004  * @author Adrian
00005  * @date May 31, 2016
00006  *
00007  */
00008 #include "mDot.h"
00009 #include "MTSLog.h"
00010 #include "LoRaConfig.h "
00011 
00012 #ifndef LORA_H_
00013 #define LORA_H_
00014 
00015 /**
00016  * @class LoRa
00017  * @brief Represents the LoRa Module with all its functionality. It wraps Multitech owns mDot Library functions.
00018  * It's possible to wrap other functionality from other LoRa Module Manufactures for future use cases
00019  */
00020 class LoRa {
00021 public:
00022     LoRa(mDot*,RawSerial*);
00023     virtual ~LoRa();
00024 
00025     /**
00026      * @brief Initializes and start the LoRa Module depending on the desireMode
00027      * @param desiredMode
00028      */
00029     void init(LORA_MODE desiredMode);
00030 
00031     /**
00032      * @brief Sends data stored inside a vector via LoRa
00033      * @param dataToSend the vector that contains the Data that needs to be sent
00034      * @return
00035      */
00036     int32_t send(std::vector<uint8_t>& dataToSend);
00037 
00038     /**
00039      * @brief Receives data via LoRa and stores it inside a vector
00040      * @param receivedData the vector where the received data needs to be stored
00041      * @return
00042      */
00043     int32_t recv(std::vector<uint8_t>& receivedData);
00044 
00045     /**
00046      * @brief Gets the Rssi of the last sent Message. It's important that at least 1
00047      * Acknowledgment Retries is set by setAckRetries()
00048      * @return
00049      */
00050     int16_t getLastRssi();
00051 
00052     /**
00053      * @brief DON'T USE IT RESULTS IN HARDFAULT!
00054      * Gets the SNR of the last sent Message.
00055      * @return
00056      */
00057     int16_t getLastSnr();
00058 
00059     /**
00060      * @brief Gets the actual spreading Factor from 7 to 12 from the LoRa Module
00061      * @return
00062      */
00063     uint8_t getSpreadingFactor();
00064 
00065     /**
00066      * @brief Gets the actual transmit Power in dBm from the LoRa Module
00067      * @return
00068      */
00069     uint8_t getTxPowerdBm();
00070 
00071     /**
00072      * @brief Sends a 0 Byte long ping message to the gateway
00073      */
00074     void ping();
00075 
00076 
00077     /**
00078      * @brief  Get ms until next free channel
00079      * only applicable for European models, US models return 0
00080      */
00081     uint32_t getNextTxMs();
00082 
00083 
00084 
00085 private:
00086     mDot* dot;
00087     RawSerial* debugSerial;
00088 
00089     LoRaConfig* config;
00090 
00091     int16_t rssi;
00092     int16_t snr;
00093     uint8_t spreadingFactor;
00094     uint8_t txPowerdBm;
00095 
00096     /**
00097      * @brief Depending on the LoRaConfig it defines wheter the LoRa Module connects to a
00098      * public network or not
00099      * @return
00100      */
00101     int32_t setPublicNetwork();
00102 
00103     /**
00104      * @brief Depending on the LoRaConfig it defines the frequency SubBand that is used for
00105      * transmission of Message to the Gateway
00106      * @return
00107      */
00108     int32_t setFrequencySubBand();
00109 
00110     /**
00111      * @brief Depending on the LoRaConfig it defines the name of the Network the
00112      * LoRa Module signs up
00113      * @return
00114      */
00115     int32_t setNetworkName();
00116 
00117     /**
00118      * @brief Depending on the LoRaConfig it defines the Passphrase thats used to
00119      * use the Network
00120      * @return
00121      */
00122     int32_t setNetworkPassphrase();
00123 
00124     /**
00125      * @brief Depending on the LoRaConfig it defines that AppEUI thats used for OTAA
00126      * @return
00127      */
00128     int32_t setAppEUI();
00129 
00130     /**
00131      * @brief Depending on the LoRaConfig it defines that AppKey thats used for OTAA
00132      * @return
00133      */
00134     int32_t setAppKey();
00135 
00136     /**
00137      * @brief Depending on the LoRaConfig it defines that DeviceEUI thats used for OTAA
00138      * @return
00139      */
00140     int32_t setDeviceEUI();
00141 
00142 
00143     /**
00144      * @brief Depending on the LoRaConfig it sets the join mode of the Node.
00145      * Either OTTA (Over the Air Activation or ABP (Activation by Personalization)
00146      * @param
00147      * @return
00148      */
00149     int32_t setJoinMode();
00150 
00151     /**
00152      * @brief Depending on the LoRaConfig it defines the spreading Factor
00153      * for transmissions via LoRa
00154      * @return
00155      */
00156     int32_t setSpreadingFactor();
00157 
00158     /**
00159      * @brief Depending on the LoRaConfig it defines the number of Acknowledgment Retries
00160      * that are made
00161      * @return
00162      */
00163     int32_t setAckRetries();
00164 
00165     /**
00166      * @brief Depending on the LoRaConfig it defines the power of LoRa data Transmission
00167      * @return
00168      */
00169     int32_t setTxPower();
00170 
00171     /**
00172      * @brief Saves parameters of the LoRa Module
00173      */
00174     void saveConfig();
00175 
00176     /**
00177      * @brief Resets Configuration of the LoRa Module
00178      */
00179     void resetConfig();
00180 
00181     /**
00182      * @brief Tries to join the Network defined by NetworkName and NetworkPassphrase
00183      */
00184     void joinNetwork();
00185 
00186 
00187 
00188 };
00189 
00190 #endif /* LORA_H_ */