SEAN O CONNELL / Mbed 2 deprecated mDot_LoRa_Sensornode

Dependencies:   libmDot mbed-rtos mbed

Fork of mDot_LoRa_Sensornode by Adrian Mitevski

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 RESULUTS 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 private:
00079     mDot* dot;
00080     RawSerial* debugSerial;
00081 
00082     LoRaConfig* config;
00083 
00084     int16_t rssi;
00085     int16_t snr;
00086     uint8_t spreadingFactor;
00087     uint8_t txPowerdBm;
00088 
00089     /**
00090      * @brief Depending on the LoRaConfig it defines wheter the LoRa Module connects to a
00091      * public network or not
00092      * @return
00093      */
00094     int32_t setPublicNetwork();
00095 
00096     /**
00097      * @brief Depending on the LoRaConfig it defines the frequency SubBand that is used for
00098      * transmission of Message to the Gateway
00099      * @return
00100      */
00101     int32_t setFrequencySubBand();
00102 
00103     /**
00104      * @brief Depending on the LoRaConfig it defines the name of the Network the
00105      * LoRa Module signs up
00106      * @return
00107      */
00108     int32_t setNetworkName();
00109 
00110     /**
00111      * @brief Depending on the LoRaConfig it defines the Passphrase thats used to
00112      * use the Network
00113      * @return
00114      */
00115     int32_t setNetworkPassphrase();
00116 
00117     /**
00118      * @brief Depending on the LoRaConfig it defines the spreading Factor
00119      * for transmissions via LoRa
00120      * @return
00121      */
00122     int32_t setSpreadingFactor();
00123 
00124     /**
00125      * @brief Depending on the LoRaConfig it defines the number of Acknowledgment Retries
00126      * that are made
00127      * @return
00128      */
00129     int32_t setAckRetries();
00130 
00131     /**
00132      * @brief Depending on the LoRaConfig it defines the power of LoRa data Transmission
00133      * @return
00134      */
00135     int32_t setTxPower();
00136 
00137     /**
00138      * @brief Saves parameters of the LoRa Module
00139      */
00140     void saveConfig();
00141 
00142     /**
00143      * @brief Resets Configuration of the LoRa Module
00144      */
00145     void resetConfig();
00146 
00147     /**
00148      * @brief Tries to join the Network defined by NetworkName and NetworkPassphrase
00149      */
00150     void joinNetwork();
00151 
00152 
00153 
00154 };
00155 
00156 #endif /* LORA_H_ */