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 LoRaConfig.h Source File

LoRaConfig.h

Go to the documentation of this file.
00001 /**
00002  * @file LoRaConfig.h
00003  *
00004  * @author Adrian
00005  * @date Jun 11, 2016
00006  *
00007  */
00008 
00009 #include <string>
00010 #include <stdint.h>
00011 #include <vector>
00012 #ifndef LORACONFIG_H_
00013 #define LORACONFIG_H_
00014 
00015 #define LORA_NETWORK_NAME           "conduitgwy"
00016 #define LORA_NETWORK_PASSPHRASE     "conduitgwy"
00017 
00018 #define LORA_SUBBAND_0                      0
00019 #define LORA_SUBBAND_1                      1
00020 #define LORA_SUBBAND_2                      2
00021 #define LORA_SUBBAND_3                      3
00022 #define LORA_SUBBAND_4                      4
00023 #define LORA_SUBBAND_5                      5
00024 #define LORA_SUBBAND_6                      6
00025 #define LORA_SUBBAND_7                      7
00026 #define LORA_SUBBAND_8                      8
00027 
00028 #define LORA_SPREADING_FACTOR_7             7
00029 #define LORA_SPREADING_FACTOR_8             8
00030 #define LORA_SPREADING_FACTOR_9             9
00031 #define LORA_SPREADING_FACTOR_10            10
00032 #define LORA_SPREADING_FACTOR_11            11
00033 #define LORA_SPREADING_FACTOR_12            12
00034 
00035 #define LORA_TX_POWER_2_DBM                 2
00036 #define LORA_TX_POWER_4_DBM                 4
00037 #define LORA_TX_POWER_8_DBM                 8
00038 #define LORA_TX_POWER_16_DBM                16
00039 #define LORA_TX_POWER_20_DBM                20
00040 
00041 #define LORA_ACKNOWLEDGE_RETRIES_0          0
00042 #define LORA_ACKNOWLEDGE_RETRIES_1          1
00043 #define LORA_ACKNOWLEDGE_RETRIES_2          2
00044 
00045 /**
00046  * LoRa Modes.
00047  */
00048 enum LORA_MODE{
00049     LORA_MODE_0_OFF = 0,//!< LORA_MODE_0
00050     LORA_MODE_1 = 1,//!< LORA_MODE_1
00051     LORA_MODE_2 = 2,//!< LORA_MODE_2
00052     LORA_MODE_3 = 3,//!< LORA_MODE_3
00053     LORA_MODE_4 = 4,//!< LORA_MODE_4
00054     LORA_MODE_5 = 5,//!< LORA_MODE_5
00055 };
00056 
00057 /**
00058  * Join Modes for LoRa
00059  */
00060 enum JOIN_MODE{
00061     OTA = 0,//!< OTTA
00062     ABP = 1 //!< ABP
00063 };
00064 
00065 static uint8_t LORA_APP_EUI_MSB[] = { 0x70, 0xB3, 0xD5, 0x7E, 0xF0, 0x00, 0x41, 0x78 };
00066 static uint8_t LORA_APP_KEY_MSB[]   = { 0x0B, 0xC0, 0x6E, 0x37, 0x33, 0x80, 0xC3, 0xE9, 0x6D, 0xD4, 0xBD, 0x3A, 0x34, 0x3E, 0xFC, 0xB4 };
00067 static uint8_t LORA_DEVICE_EUI_MSB[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77};
00068 
00069 /**
00070  * @class LoRaConfig
00071  * @brief A configuration container for the LoRa Module.
00072  * All its configuration values are stored an held inside
00073  * this Class. Depending on the LORA_MODE it sets all the configuration values.
00074  */
00075 class LoRaConfig {
00076 public:
00077     LoRaConfig();
00078     virtual ~LoRaConfig();
00079 
00080     /**
00081      * @brief Generates a configuration according to the chosen LORA_MODE
00082      * by setting all LoRa Module specific configuration values depending on the chosen LORA_MODE
00083      * @param desiredMode the mode to build the configuration according to
00084      */
00085     void build(LORA_MODE desiredMode);
00086 
00087     /**
00088      * @brief Gets info if the Network to which the LoRa Module sings up
00089      * is public or not from its Configuration
00090      */
00091     bool isPublic();
00092 
00093     /**
00094      * @brief Gets info if LoRa Module will be active and run or not
00095      * from its Configuration
00096      * @return
00097      */
00098     bool isActiv();
00099 
00100     /**
00101      * @brief Gets the name of the Network to which the LoRa Module sings up
00102      * from its Configuration
00103      * @return
00104      */
00105     std::string getNetworkName();
00106 
00107     /**
00108      * @brief Gets the Passphrase of the Network to which the LoRa Module sings up
00109      * from its Configuration
00110      * @return
00111      */
00112     std::string getNetworkPassphrase();
00113 
00114     /**
00115      * @brief Gets the Network Address. Only used when using ABP JoinMode
00116      * @return
00117      */
00118     std::string getNetworkAddress();
00119 
00120     /**
00121      * @brief Gets the App EUI
00122      * @return
00123      */
00124     std::vector<uint8_t> getAppEUI();
00125 
00126     /**
00127      * @brief Gets the App Key
00128      * @return
00129      */
00130     std::vector<uint8_t> getAppKey();
00131 
00132     /**
00133      * @brief Gets the Device EUI
00134      * @return
00135      */
00136     std::vector<uint8_t> getDeviceEUI();
00137 
00138     /**
00139      * @brief Gets the frequency SubBand that will be used by the LoRa Module to
00140      * send and receive its data from its Configuration
00141      * @return
00142      */
00143     uint8_t getFrequencySubBand();
00144 
00145     /**
00146      * @brief Gets the spreading Factor that the LoRa Module will us for data transmission
00147      * from its Configuration
00148      * @return
00149      */
00150     uint8_t getSpreadingFactor();
00151 
00152     /**
00153      * @brief Gets the transmission Power of the LoRa Module from its Configuration
00154      * @return
00155      */
00156     uint8_t getTxPowerdBm();
00157 
00158     /**
00159      * @brief Gets the number of Acknowledgment Retries that will be made
00160      * from its Configuration
00161      * @return
00162      */
00163     uint8_t getAcknowledgeRetries();
00164 
00165     /**
00166      * @brief Gets the Actual LORA_MODE of the built LoRaConfiguration
00167      * from its Configuration
00168      * @return
00169      */
00170     LORA_MODE getLORA_MODE();
00171 
00172     /**
00173      * @brief Gets the Actual JOIN_MODE of the built LoRaConfiguration
00174      * form its Configuration
00175      * @return
00176      */
00177     JOIN_MODE getJOIN_MODE();
00178 
00179 
00180 private:
00181     std::string* networkName;
00182     std::string* networkPassphrase;
00183     std::string* networkAddress;
00184     std::vector<uint8_t>* appEUI;
00185     std::vector<uint8_t>* appKey;
00186     std::vector<uint8_t>* deviceEUI;
00187     bool publicity;
00188     bool activity;
00189     uint8_t frequencySubBand;
00190     uint8_t spreadingFactor;
00191     uint8_t txPowerdBm;
00192     uint8_t acknowledgeRetries;
00193 
00194     LORA_MODE loraMode;
00195     JOIN_MODE joinMode;
00196 
00197 
00198     /**
00199      * @brief Sets the Network publicity of the network that will be used in the Configuration
00200      * @param
00201      */
00202     void setNetworkPublicity(bool publicity);
00203 
00204     /**
00205      * @brief Sets the Activity of the LoRa module for the Configuration
00206      * @param activity true = module will be active false = module will not be active
00207      */
00208     void setActivity(bool activity);
00209 
00210     /**
00211      * @brief Sets the Name of the Network that will be used in the Configuration
00212      * @param networkName the name of the network
00213      */
00214     void setNetworkName(char* networkName);
00215 
00216     /**
00217      * @brief Sets the Passphrase of the Network that will be used in the Configuration
00218      * @param networkPassphrase passphrase of the Network
00219      */
00220     void setNetworkPassphrase(char* networkPassphrase);
00221 
00222     /**
00223      * @brief Sets the Networkaddress of the Network that will be used in the Configuration
00224      * @param networkAddress
00225      */
00226     void setNetworkAddress(char* networkAddress);
00227 
00228     /**
00229      * @brief Sets the APP EUI for OTAA
00230      * @param appEUI
00231      */
00232     void setAppEUI();
00233 
00234     /**
00235      * @brief Sets the APP Key for OTAA
00236      * @param appKey
00237      */
00238     void setAppKey();
00239 
00240     /**
00241      * @brief Sets the device EUI for OTAA
00242      * @param deviceEUI
00243      */
00244     void setDeviceEUI();
00245 
00246 
00247     /**
00248      * @brief Sets the SubBand that will be used in by the LoRa Module in the Configuration
00249      * @param subBand the SubBand that will be used
00250      */
00251     void setFrequencySubBand(uint8_t subBand);
00252 
00253     /**
00254      * @brief Sets the spreading Factor of a LoRa Data Transmission in the Configuration
00255      * @param spreadingFactor
00256      */
00257     void setSpreadingFactor(uint8_t spreadingFactor);
00258 
00259     /**
00260      * @brief Sets the Data transmission Power via LoRa in the Configuration
00261      * @param
00262      */
00263     void setTxPowerdBm(uint8_t );
00264 
00265     /**
00266      * @brief Set the Acknowledgment Retries in the Configuration
00267      * @param
00268      */
00269     void setAcknowledgeRetries(uint8_t);
00270 
00271     /**
00272      * @brief Sets the LORA_MODE of the Configuration
00273      * @param
00274      */
00275     void setLORA_MODE(LORA_MODE);
00276 
00277     /**
00278      * @brief Sets the Join Mode to a Network
00279      * @param
00280      */
00281     void setJOIN_MODE(JOIN_MODE);
00282 
00283 };
00284 
00285 #endif /* LORACONFIG_H_ */