This is code is part of a Technion course project in advanced IoT, implementing a device to receive and present sensors data from a Formula racing car built by students at Technion - Israel Institute of Technology.
Fork of DISCO-L072CZ-LRWAN1_LoRa_PingPong by
This is code is part of a Technion course project in advanced IoT, implementing a device to receive sensors data from another L072CZ-LRWAN1 installed on a Formula racing car (built by students at Technion - Israel Institute of Technology), and sends it to a GUI presenting the data (GUI project: github.com/ward-mattar/TechnionFormulaGUI).
How to install
- Create an account on Mbed: https://os.mbed.com/account/signup/
- Import project into Compiler
- In the Program Workspace select "Formula_Nucleo_Receiver"
- Select a Platform like so:
- Click button at top-left
- Add Board
- Search "NUCLEO F103RB" and then "Add to your Mbed Compiler"
- Finally click "Compile", if the build was successful, the binary would download automatically
- To install it on device simply plug it in to a PC, open device drive and drag then drop binary file in it
SX1276GenericLib/radio/radio.h@12:046346a16ff4, 2018-05-19 (annotated)
- Committer:
- wardm
- Date:
- Sat May 19 15:42:38 2018 +0000
- Revision:
- 12:046346a16ff4
V1.0.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wardm | 12:046346a16ff4 | 1 | /* |
wardm | 12:046346a16ff4 | 2 | / _____) _ | | |
wardm | 12:046346a16ff4 | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ |
wardm | 12:046346a16ff4 | 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
wardm | 12:046346a16ff4 | 5 | _____) ) ____| | | || |_| ____( (___| | | | |
wardm | 12:046346a16ff4 | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
wardm | 12:046346a16ff4 | 7 | (C) 2014 Semtech |
wardm | 12:046346a16ff4 | 8 | |
wardm | 12:046346a16ff4 | 9 | Description: Interface for the radios, contains the main functions that a radio needs, and 5 callback functions |
wardm | 12:046346a16ff4 | 10 | |
wardm | 12:046346a16ff4 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project |
wardm | 12:046346a16ff4 | 12 | |
wardm | 12:046346a16ff4 | 13 | Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin |
wardm | 12:046346a16ff4 | 14 | */ |
wardm | 12:046346a16ff4 | 15 | #ifndef __RADIO_H__ |
wardm | 12:046346a16ff4 | 16 | #define __RADIO_H__ |
wardm | 12:046346a16ff4 | 17 | |
wardm | 12:046346a16ff4 | 18 | #ifdef __MBED__ |
wardm | 12:046346a16ff4 | 19 | #include "mbed.h" |
wardm | 12:046346a16ff4 | 20 | #endif |
wardm | 12:046346a16ff4 | 21 | #ifdef ARDUINO |
wardm | 12:046346a16ff4 | 22 | #include <arduino.h> |
wardm | 12:046346a16ff4 | 23 | #endif |
wardm | 12:046346a16ff4 | 24 | |
wardm | 12:046346a16ff4 | 25 | /*! |
wardm | 12:046346a16ff4 | 26 | * Radio driver internal state machine states definition |
wardm | 12:046346a16ff4 | 27 | */ |
wardm | 12:046346a16ff4 | 28 | typedef enum RadioState |
wardm | 12:046346a16ff4 | 29 | { |
wardm | 12:046346a16ff4 | 30 | RF_IDLE = 0, |
wardm | 12:046346a16ff4 | 31 | RF_RX_RUNNING, |
wardm | 12:046346a16ff4 | 32 | RF_TX_RUNNING, |
wardm | 12:046346a16ff4 | 33 | RF_CAD, |
wardm | 12:046346a16ff4 | 34 | } RadioState_t; |
wardm | 12:046346a16ff4 | 35 | |
wardm | 12:046346a16ff4 | 36 | |
wardm | 12:046346a16ff4 | 37 | /*! |
wardm | 12:046346a16ff4 | 38 | * Type of the modem. [LORA / FSK] |
wardm | 12:046346a16ff4 | 39 | */ |
wardm | 12:046346a16ff4 | 40 | typedef enum ModemType |
wardm | 12:046346a16ff4 | 41 | { |
wardm | 12:046346a16ff4 | 42 | MODEM_FSK = 0, |
wardm | 12:046346a16ff4 | 43 | MODEM_LORA |
wardm | 12:046346a16ff4 | 44 | }RadioModems_t; |
wardm | 12:046346a16ff4 | 45 | |
wardm | 12:046346a16ff4 | 46 | |
wardm | 12:046346a16ff4 | 47 | /*! |
wardm | 12:046346a16ff4 | 48 | * Radio LoRa modem parameters |
wardm | 12:046346a16ff4 | 49 | */ |
wardm | 12:046346a16ff4 | 50 | typedef struct |
wardm | 12:046346a16ff4 | 51 | { |
wardm | 12:046346a16ff4 | 52 | int8_t Power; |
wardm | 12:046346a16ff4 | 53 | uint32_t Bandwidth; |
wardm | 12:046346a16ff4 | 54 | uint32_t Datarate; |
wardm | 12:046346a16ff4 | 55 | bool LowDatarateOptimize; |
wardm | 12:046346a16ff4 | 56 | uint8_t Coderate; |
wardm | 12:046346a16ff4 | 57 | uint16_t PreambleLen; |
wardm | 12:046346a16ff4 | 58 | bool FixLen; |
wardm | 12:046346a16ff4 | 59 | uint8_t PayloadLen; |
wardm | 12:046346a16ff4 | 60 | bool CrcOn; |
wardm | 12:046346a16ff4 | 61 | bool FreqHopOn; |
wardm | 12:046346a16ff4 | 62 | uint8_t HopPeriod; |
wardm | 12:046346a16ff4 | 63 | bool IqInverted; |
wardm | 12:046346a16ff4 | 64 | bool RxContinuous; |
wardm | 12:046346a16ff4 | 65 | uint32_t TxTimeout; |
wardm | 12:046346a16ff4 | 66 | bool PublicNetwork; |
wardm | 12:046346a16ff4 | 67 | }RadioLoRaSettings_t; |
wardm | 12:046346a16ff4 | 68 | |
wardm | 12:046346a16ff4 | 69 | /*! |
wardm | 12:046346a16ff4 | 70 | * Radio FSK modem parameters |
wardm | 12:046346a16ff4 | 71 | */ |
wardm | 12:046346a16ff4 | 72 | typedef struct |
wardm | 12:046346a16ff4 | 73 | { |
wardm | 12:046346a16ff4 | 74 | int8_t Power; |
wardm | 12:046346a16ff4 | 75 | uint32_t Fdev; |
wardm | 12:046346a16ff4 | 76 | uint32_t Bandwidth; |
wardm | 12:046346a16ff4 | 77 | uint32_t BandwidthAfc; |
wardm | 12:046346a16ff4 | 78 | uint32_t Datarate; |
wardm | 12:046346a16ff4 | 79 | uint16_t PreambleLen; |
wardm | 12:046346a16ff4 | 80 | bool FixLen; |
wardm | 12:046346a16ff4 | 81 | uint8_t PayloadLen; |
wardm | 12:046346a16ff4 | 82 | bool CrcOn; |
wardm | 12:046346a16ff4 | 83 | bool IqInverted; |
wardm | 12:046346a16ff4 | 84 | bool RxContinuous; |
wardm | 12:046346a16ff4 | 85 | uint32_t TxTimeout; |
wardm | 12:046346a16ff4 | 86 | uint32_t RxSingleTimeout; |
wardm | 12:046346a16ff4 | 87 | }RadioFskSettings_t; |
wardm | 12:046346a16ff4 | 88 | |
wardm | 12:046346a16ff4 | 89 | /*! |
wardm | 12:046346a16ff4 | 90 | * Radio FSK packet handler state |
wardm | 12:046346a16ff4 | 91 | */ |
wardm | 12:046346a16ff4 | 92 | typedef struct |
wardm | 12:046346a16ff4 | 93 | { |
wardm | 12:046346a16ff4 | 94 | uint8_t PreambleDetected; |
wardm | 12:046346a16ff4 | 95 | uint8_t SyncWordDetected; |
wardm | 12:046346a16ff4 | 96 | int8_t RssiValue; |
wardm | 12:046346a16ff4 | 97 | int32_t AfcValue; |
wardm | 12:046346a16ff4 | 98 | uint8_t RxGain; |
wardm | 12:046346a16ff4 | 99 | uint16_t Size; |
wardm | 12:046346a16ff4 | 100 | uint16_t NbBytes; |
wardm | 12:046346a16ff4 | 101 | uint8_t FifoThresh; |
wardm | 12:046346a16ff4 | 102 | uint8_t ChunkSize; |
wardm | 12:046346a16ff4 | 103 | }RadioFskPacketHandler_t; |
wardm | 12:046346a16ff4 | 104 | |
wardm | 12:046346a16ff4 | 105 | /*! |
wardm | 12:046346a16ff4 | 106 | * Radio LoRa packet handler state |
wardm | 12:046346a16ff4 | 107 | */ |
wardm | 12:046346a16ff4 | 108 | typedef struct |
wardm | 12:046346a16ff4 | 109 | { |
wardm | 12:046346a16ff4 | 110 | int8_t SnrValue; |
wardm | 12:046346a16ff4 | 111 | int8_t RssiValue; |
wardm | 12:046346a16ff4 | 112 | uint8_t Size; |
wardm | 12:046346a16ff4 | 113 | }RadioLoRaPacketHandler_t; |
wardm | 12:046346a16ff4 | 114 | |
wardm | 12:046346a16ff4 | 115 | /*! |
wardm | 12:046346a16ff4 | 116 | * Radio Settings |
wardm | 12:046346a16ff4 | 117 | */ |
wardm | 12:046346a16ff4 | 118 | typedef struct |
wardm | 12:046346a16ff4 | 119 | { |
wardm | 12:046346a16ff4 | 120 | RadioState State; |
wardm | 12:046346a16ff4 | 121 | ModemType Modem; |
wardm | 12:046346a16ff4 | 122 | uint32_t Channel; |
wardm | 12:046346a16ff4 | 123 | RadioFskSettings_t Fsk; |
wardm | 12:046346a16ff4 | 124 | RadioFskPacketHandler_t FskPacketHandler; |
wardm | 12:046346a16ff4 | 125 | RadioLoRaSettings_t LoRa; |
wardm | 12:046346a16ff4 | 126 | RadioLoRaPacketHandler_t LoRaPacketHandler; |
wardm | 12:046346a16ff4 | 127 | }RadioSettings_t; |
wardm | 12:046346a16ff4 | 128 | |
wardm | 12:046346a16ff4 | 129 | /*! |
wardm | 12:046346a16ff4 | 130 | * @brief Radio driver callback functions |
wardm | 12:046346a16ff4 | 131 | */ |
wardm | 12:046346a16ff4 | 132 | typedef struct |
wardm | 12:046346a16ff4 | 133 | { |
wardm | 12:046346a16ff4 | 134 | /*! |
wardm | 12:046346a16ff4 | 135 | * @brief Tx Done callback prototype. |
wardm | 12:046346a16ff4 | 136 | */ |
wardm | 12:046346a16ff4 | 137 | void ( *TxDone )(void *radio, void *userThisPtr, void *userData); |
wardm | 12:046346a16ff4 | 138 | /*! |
wardm | 12:046346a16ff4 | 139 | * @brief Tx Timeout callback prototype. |
wardm | 12:046346a16ff4 | 140 | */ |
wardm | 12:046346a16ff4 | 141 | void ( *TxTimeout )(void *radio, void *userThisPtr, void *userData); |
wardm | 12:046346a16ff4 | 142 | /*! |
wardm | 12:046346a16ff4 | 143 | * @brief Rx Done callback prototype. |
wardm | 12:046346a16ff4 | 144 | * |
wardm | 12:046346a16ff4 | 145 | * @param [IN] payload Received buffer pointer |
wardm | 12:046346a16ff4 | 146 | * @param [IN] size Received buffer size |
wardm | 12:046346a16ff4 | 147 | * @param [IN] rssi RSSI value computed while receiving the frame [dBm] |
wardm | 12:046346a16ff4 | 148 | * @param [IN] snr Raw SNR value given by the radio hardware |
wardm | 12:046346a16ff4 | 149 | * FSK : N/A ( set to 0 ) |
wardm | 12:046346a16ff4 | 150 | * LoRa: SNR value in dB |
wardm | 12:046346a16ff4 | 151 | */ |
wardm | 12:046346a16ff4 | 152 | void ( *RxDone )(void *radio, void *userThisPtr, void *userData, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ); |
wardm | 12:046346a16ff4 | 153 | /*! |
wardm | 12:046346a16ff4 | 154 | * @brief Rx Timeout callback prototype. |
wardm | 12:046346a16ff4 | 155 | */ |
wardm | 12:046346a16ff4 | 156 | void ( *RxTimeout )(void *radio, void *userThisPtr, void *userData); |
wardm | 12:046346a16ff4 | 157 | /*! |
wardm | 12:046346a16ff4 | 158 | * @brief Rx Error callback prototype. |
wardm | 12:046346a16ff4 | 159 | */ |
wardm | 12:046346a16ff4 | 160 | void ( *RxError )(void *radio, void *userThisPtr, void *userData); |
wardm | 12:046346a16ff4 | 161 | /*! |
wardm | 12:046346a16ff4 | 162 | * \brief FHSS Change Channel callback prototype. |
wardm | 12:046346a16ff4 | 163 | * |
wardm | 12:046346a16ff4 | 164 | * \param [IN] currentChannel Index number of the current channel |
wardm | 12:046346a16ff4 | 165 | */ |
wardm | 12:046346a16ff4 | 166 | void ( *FhssChangeChannel )(void *radio, void *userThisPtr, void *userData, uint8_t currentChannel ); |
wardm | 12:046346a16ff4 | 167 | |
wardm | 12:046346a16ff4 | 168 | /*! |
wardm | 12:046346a16ff4 | 169 | * @brief CAD Done callback prototype. |
wardm | 12:046346a16ff4 | 170 | * |
wardm | 12:046346a16ff4 | 171 | * @param [IN] channelDetected Channel Activity detected during the CAD |
wardm | 12:046346a16ff4 | 172 | */ |
wardm | 12:046346a16ff4 | 173 | void ( *CadDone ) (void *radio, void *userThisPtr, void *userData, bool channelActivityDetected ); |
wardm | 12:046346a16ff4 | 174 | |
wardm | 12:046346a16ff4 | 175 | /* |
wardm | 12:046346a16ff4 | 176 | * Optional data which is being provided in callbacks |
wardm | 12:046346a16ff4 | 177 | * can be used e.g. for the C++ this pointer. |
wardm | 12:046346a16ff4 | 178 | */ |
wardm | 12:046346a16ff4 | 179 | void *userThisPtr; |
wardm | 12:046346a16ff4 | 180 | |
wardm | 12:046346a16ff4 | 181 | /* |
wardm | 12:046346a16ff4 | 182 | * Optional data which allows to bring in data structures pointer |
wardm | 12:046346a16ff4 | 183 | * for a given radio. As callbacks are being called in interrupt level |
wardm | 12:046346a16ff4 | 184 | * the userData is perfect to know the context without iterating this |
wardm | 12:046346a16ff4 | 185 | * data structures. |
wardm | 12:046346a16ff4 | 186 | */ |
wardm | 12:046346a16ff4 | 187 | void *userData; |
wardm | 12:046346a16ff4 | 188 | |
wardm | 12:046346a16ff4 | 189 | }RadioEvents_t; |
wardm | 12:046346a16ff4 | 190 | |
wardm | 12:046346a16ff4 | 191 | /*! |
wardm | 12:046346a16ff4 | 192 | * Interface for the radios, contains the main functions that a radio needs, and 5 callback functions |
wardm | 12:046346a16ff4 | 193 | */ |
wardm | 12:046346a16ff4 | 194 | class Radio |
wardm | 12:046346a16ff4 | 195 | { |
wardm | 12:046346a16ff4 | 196 | protected: |
wardm | 12:046346a16ff4 | 197 | RadioEvents_t* RadioEvents; |
wardm | 12:046346a16ff4 | 198 | |
wardm | 12:046346a16ff4 | 199 | public: |
wardm | 12:046346a16ff4 | 200 | //------------------------------------------------------------------------- |
wardm | 12:046346a16ff4 | 201 | // Constructor |
wardm | 12:046346a16ff4 | 202 | //------------------------------------------------------------------------- |
wardm | 12:046346a16ff4 | 203 | /*! |
wardm | 12:046346a16ff4 | 204 | * @brief Constructor of the radio object, the parameters are the callback functions described in the header. |
wardm | 12:046346a16ff4 | 205 | * |
wardm | 12:046346a16ff4 | 206 | * @param [IN] events Structure containing the driver callback functions |
wardm | 12:046346a16ff4 | 207 | */ |
wardm | 12:046346a16ff4 | 208 | Radio( RadioEvents_t *events ); |
wardm | 12:046346a16ff4 | 209 | virtual ~Radio( ) {}; |
wardm | 12:046346a16ff4 | 210 | |
wardm | 12:046346a16ff4 | 211 | //------------------------------------------------------------------------- |
wardm | 12:046346a16ff4 | 212 | // Pure virtual functions |
wardm | 12:046346a16ff4 | 213 | //------------------------------------------------------------------------- |
wardm | 12:046346a16ff4 | 214 | |
wardm | 12:046346a16ff4 | 215 | /*! |
wardm | 12:046346a16ff4 | 216 | * @brief Initializes the radio |
wardm | 12:046346a16ff4 | 217 | * |
wardm | 12:046346a16ff4 | 218 | * @param [IN] events Structure containing the driver callback functions |
wardm | 12:046346a16ff4 | 219 | */ |
wardm | 12:046346a16ff4 | 220 | virtual bool Init( RadioEvents_t *events ) = 0; |
wardm | 12:046346a16ff4 | 221 | |
wardm | 12:046346a16ff4 | 222 | /*! |
wardm | 12:046346a16ff4 | 223 | * @brief Return current radio status, returns true if a radios has been found. |
wardm | 12:046346a16ff4 | 224 | * |
wardm | 12:046346a16ff4 | 225 | * @param status Radio status. [RF_IDLE, RX_RUNNING, TX_RUNNING, CAD_RUNNING] |
wardm | 12:046346a16ff4 | 226 | */ |
wardm | 12:046346a16ff4 | 227 | virtual RadioState GetStatus( void ) = 0; |
wardm | 12:046346a16ff4 | 228 | |
wardm | 12:046346a16ff4 | 229 | /*! |
wardm | 12:046346a16ff4 | 230 | * @brief Configures the radio with the given modem |
wardm | 12:046346a16ff4 | 231 | * |
wardm | 12:046346a16ff4 | 232 | * @param [IN] modem Modem to be used [0: FSK, 1: LoRa] |
wardm | 12:046346a16ff4 | 233 | */ |
wardm | 12:046346a16ff4 | 234 | virtual void SetModem( RadioModems_t modem ) = 0; |
wardm | 12:046346a16ff4 | 235 | |
wardm | 12:046346a16ff4 | 236 | /*! |
wardm | 12:046346a16ff4 | 237 | * @brief Sets the channel frequency |
wardm | 12:046346a16ff4 | 238 | * |
wardm | 12:046346a16ff4 | 239 | * @param [IN] freq Channel RF frequency |
wardm | 12:046346a16ff4 | 240 | */ |
wardm | 12:046346a16ff4 | 241 | virtual void SetChannel( uint32_t freq ) = 0; |
wardm | 12:046346a16ff4 | 242 | |
wardm | 12:046346a16ff4 | 243 | /*! |
wardm | 12:046346a16ff4 | 244 | * @brief Sets the channels configuration |
wardm | 12:046346a16ff4 | 245 | * |
wardm | 12:046346a16ff4 | 246 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
wardm | 12:046346a16ff4 | 247 | * @param [IN] freq Channel RF frequency |
wardm | 12:046346a16ff4 | 248 | * @param [IN] rssiThresh RSSI threshold |
wardm | 12:046346a16ff4 | 249 | * |
wardm | 12:046346a16ff4 | 250 | * @retval isFree [true: Channel is free, false: Channel is not free] |
wardm | 12:046346a16ff4 | 251 | */ |
wardm | 12:046346a16ff4 | 252 | virtual bool IsChannelFree( RadioModems_t modem, uint32_t freq, int16_t rssiThresh ) = 0; |
wardm | 12:046346a16ff4 | 253 | |
wardm | 12:046346a16ff4 | 254 | /*! |
wardm | 12:046346a16ff4 | 255 | * @brief Generates a 32 bits random value based on the RSSI readings |
wardm | 12:046346a16ff4 | 256 | * |
wardm | 12:046346a16ff4 | 257 | * \remark This function sets the radio in LoRa modem mode and disables |
wardm | 12:046346a16ff4 | 258 | * all interrupts. |
wardm | 12:046346a16ff4 | 259 | * After calling this function either Radio.SetRxConfig or |
wardm | 12:046346a16ff4 | 260 | * Radio.SetTxConfig functions must be called. |
wardm | 12:046346a16ff4 | 261 | * |
wardm | 12:046346a16ff4 | 262 | * @retval randomValue 32 bits random value |
wardm | 12:046346a16ff4 | 263 | */ |
wardm | 12:046346a16ff4 | 264 | virtual uint32_t Random( void )= 0; |
wardm | 12:046346a16ff4 | 265 | |
wardm | 12:046346a16ff4 | 266 | /*! |
wardm | 12:046346a16ff4 | 267 | * @brief Sets the reception parameters |
wardm | 12:046346a16ff4 | 268 | * |
wardm | 12:046346a16ff4 | 269 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
wardm | 12:046346a16ff4 | 270 | * @param [IN] bandwidth Sets the bandwidth |
wardm | 12:046346a16ff4 | 271 | * FSK : >= 2600 and <= 250000 Hz |
wardm | 12:046346a16ff4 | 272 | * LoRa: [0: 125 kHz, 1: 250 kHz, |
wardm | 12:046346a16ff4 | 273 | * 2: 500 kHz, 3: Reserved] |
wardm | 12:046346a16ff4 | 274 | * @param [IN] datarate Sets the Datarate |
wardm | 12:046346a16ff4 | 275 | * FSK : 600..300000 bits/s |
wardm | 12:046346a16ff4 | 276 | * LoRa: [6: 64, 7: 128, 8: 256, 9: 512, |
wardm | 12:046346a16ff4 | 277 | * 10: 1024, 11: 2048, 12: 4096 chips] |
wardm | 12:046346a16ff4 | 278 | * @param [IN] coderate Sets the coding rate ( LoRa only ) |
wardm | 12:046346a16ff4 | 279 | * FSK : N/A ( set to 0 ) |
wardm | 12:046346a16ff4 | 280 | * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
wardm | 12:046346a16ff4 | 281 | * @param [IN] bandwidthAfc Sets the AFC Bandwidth ( FSK only ) |
wardm | 12:046346a16ff4 | 282 | * FSK : >= 2600 and <= 250000 Hz |
wardm | 12:046346a16ff4 | 283 | * LoRa: N/A ( set to 0 ) |
wardm | 12:046346a16ff4 | 284 | * @param [IN] preambleLen Sets the Preamble length ( LoRa only ) |
wardm | 12:046346a16ff4 | 285 | * FSK : N/A ( set to 0 ) |
wardm | 12:046346a16ff4 | 286 | * LoRa: Length in symbols ( the hardware adds 4 more symbols ) |
wardm | 12:046346a16ff4 | 287 | * @param [IN] symbTimeout Sets the RxSingle timeout value |
wardm | 12:046346a16ff4 | 288 | * FSK : timeout number of bytes |
wardm | 12:046346a16ff4 | 289 | * LoRa: timeout in symbols |
wardm | 12:046346a16ff4 | 290 | * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed] |
wardm | 12:046346a16ff4 | 291 | * @param [IN] payloadLen Sets payload length when fixed lenght is used |
wardm | 12:046346a16ff4 | 292 | * @param [IN] crcOn Enables/Disables the CRC [0: OFF, 1: ON] |
wardm | 12:046346a16ff4 | 293 | * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
wardm | 12:046346a16ff4 | 294 | * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only) |
wardm | 12:046346a16ff4 | 295 | * @param [IN] iqInverted Inverts IQ signals ( LoRa only ) |
wardm | 12:046346a16ff4 | 296 | * FSK : N/A ( set to 0 ) |
wardm | 12:046346a16ff4 | 297 | * LoRa: [0: not inverted, 1: inverted] |
wardm | 12:046346a16ff4 | 298 | * @param [IN] rxContinuous Sets the reception in continuous mode |
wardm | 12:046346a16ff4 | 299 | * [false: single mode, true: continuous mode] |
wardm | 12:046346a16ff4 | 300 | */ |
wardm | 12:046346a16ff4 | 301 | virtual void SetRxConfig ( RadioModems_t modem, uint32_t bandwidth, |
wardm | 12:046346a16ff4 | 302 | uint32_t datarate, uint8_t coderate, |
wardm | 12:046346a16ff4 | 303 | uint32_t bandwidthAfc, uint16_t preambleLen, |
wardm | 12:046346a16ff4 | 304 | uint16_t symbTimeout, bool fixLen, |
wardm | 12:046346a16ff4 | 305 | uint8_t payloadLen, |
wardm | 12:046346a16ff4 | 306 | bool crcOn, bool freqHopOn, uint8_t hopPeriod, |
wardm | 12:046346a16ff4 | 307 | bool iqInverted, bool rxContinuous ) = 0; |
wardm | 12:046346a16ff4 | 308 | |
wardm | 12:046346a16ff4 | 309 | /*! |
wardm | 12:046346a16ff4 | 310 | * @brief Sets the transmission parameters |
wardm | 12:046346a16ff4 | 311 | * |
wardm | 12:046346a16ff4 | 312 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
wardm | 12:046346a16ff4 | 313 | * @param [IN] power Sets the output power [dBm] |
wardm | 12:046346a16ff4 | 314 | * @param [IN] fdev Sets the frequency deviation ( FSK only ) |
wardm | 12:046346a16ff4 | 315 | * FSK : [Hz] |
wardm | 12:046346a16ff4 | 316 | * LoRa: 0 |
wardm | 12:046346a16ff4 | 317 | * @param [IN] bandwidth Sets the bandwidth ( LoRa only ) |
wardm | 12:046346a16ff4 | 318 | * FSK : 0 |
wardm | 12:046346a16ff4 | 319 | * LoRa: [0: 125 kHz, 1: 250 kHz, |
wardm | 12:046346a16ff4 | 320 | * 2: 500 kHz, 3: Reserved] |
wardm | 12:046346a16ff4 | 321 | * @param [IN] datarate Sets the Datarate |
wardm | 12:046346a16ff4 | 322 | * FSK : 600..300000 bits/s |
wardm | 12:046346a16ff4 | 323 | * LoRa: [6: 64, 7: 128, 8: 256, 9: 512, |
wardm | 12:046346a16ff4 | 324 | * 10: 1024, 11: 2048, 12: 4096 chips] |
wardm | 12:046346a16ff4 | 325 | * @param [IN] coderate Sets the coding rate ( LoRa only ) |
wardm | 12:046346a16ff4 | 326 | * FSK : N/A ( set to 0 ) |
wardm | 12:046346a16ff4 | 327 | * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
wardm | 12:046346a16ff4 | 328 | * @param [IN] preambleLen Sets the preamble length |
wardm | 12:046346a16ff4 | 329 | * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed] |
wardm | 12:046346a16ff4 | 330 | * @param [IN] crcOn Enables disables the CRC [0: OFF, 1: ON] |
wardm | 12:046346a16ff4 | 331 | * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
wardm | 12:046346a16ff4 | 332 | * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only) |
wardm | 12:046346a16ff4 | 333 | * @param [IN] iqInverted Inverts IQ signals ( LoRa only ) |
wardm | 12:046346a16ff4 | 334 | * FSK : N/A ( set to 0 ) |
wardm | 12:046346a16ff4 | 335 | * LoRa: [0: not inverted, 1: inverted] |
wardm | 12:046346a16ff4 | 336 | * @param [IN] timeout Transmission timeout [us] |
wardm | 12:046346a16ff4 | 337 | */ |
wardm | 12:046346a16ff4 | 338 | virtual void SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev, |
wardm | 12:046346a16ff4 | 339 | uint32_t bandwidth, uint32_t datarate, |
wardm | 12:046346a16ff4 | 340 | uint8_t coderate, uint16_t preambleLen, |
wardm | 12:046346a16ff4 | 341 | bool fixLen, bool crcOn, bool freqHopOn, |
wardm | 12:046346a16ff4 | 342 | uint8_t hopPeriod, bool iqInverted, uint32_t timeout ) = 0; |
wardm | 12:046346a16ff4 | 343 | |
wardm | 12:046346a16ff4 | 344 | /*! |
wardm | 12:046346a16ff4 | 345 | * @brief Checks if the given RF frequency is supported by the hardware |
wardm | 12:046346a16ff4 | 346 | * |
wardm | 12:046346a16ff4 | 347 | * @param [IN] frequency RF frequency to be checked |
wardm | 12:046346a16ff4 | 348 | * @retval isSupported [true: supported, false: unsupported] |
wardm | 12:046346a16ff4 | 349 | */ |
wardm | 12:046346a16ff4 | 350 | virtual bool CheckRfFrequency( uint32_t frequency ) = 0; |
wardm | 12:046346a16ff4 | 351 | |
wardm | 12:046346a16ff4 | 352 | /*! |
wardm | 12:046346a16ff4 | 353 | * @brief Computes the packet time on air for the given payload |
wardm | 12:046346a16ff4 | 354 | * |
wardm | 12:046346a16ff4 | 355 | * \Remark Can only be called once SetRxConfig or SetTxConfig have been called |
wardm | 12:046346a16ff4 | 356 | * |
wardm | 12:046346a16ff4 | 357 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
wardm | 12:046346a16ff4 | 358 | * @param [IN] pktLen Packet payload length |
wardm | 12:046346a16ff4 | 359 | * |
wardm | 12:046346a16ff4 | 360 | * @retval airTime Computed airTime for the given packet payload length |
wardm | 12:046346a16ff4 | 361 | */ |
wardm | 12:046346a16ff4 | 362 | virtual uint32_t TimeOnAir ( RadioModems_t modem, int16_t pktLen ) = 0; |
wardm | 12:046346a16ff4 | 363 | |
wardm | 12:046346a16ff4 | 364 | /*! |
wardm | 12:046346a16ff4 | 365 | * @brief Sends the buffer of size. Prepares the packet to be sent and sets |
wardm | 12:046346a16ff4 | 366 | * the radio in transmission |
wardm | 12:046346a16ff4 | 367 | * |
wardm | 12:046346a16ff4 | 368 | * @param [IN]: buffer Buffer pointer |
wardm | 12:046346a16ff4 | 369 | * @param [IN]: size Buffer size |
wardm | 12:046346a16ff4 | 370 | * @param [IN]: buffer Header pointer |
wardm | 12:046346a16ff4 | 371 | * @param [IN]: size Header size |
wardm | 12:046346a16ff4 | 372 | */ |
wardm | 12:046346a16ff4 | 373 | virtual void Send( void *buffer, int16_t size, void *header = NULL, int16_t hsize = 0) = 0; |
wardm | 12:046346a16ff4 | 374 | |
wardm | 12:046346a16ff4 | 375 | /*! |
wardm | 12:046346a16ff4 | 376 | * @brief Sets the radio in sleep mode |
wardm | 12:046346a16ff4 | 377 | */ |
wardm | 12:046346a16ff4 | 378 | virtual void Sleep( void ) = 0; |
wardm | 12:046346a16ff4 | 379 | |
wardm | 12:046346a16ff4 | 380 | /*! |
wardm | 12:046346a16ff4 | 381 | * @brief Sets the radio in standby mode |
wardm | 12:046346a16ff4 | 382 | */ |
wardm | 12:046346a16ff4 | 383 | virtual void Standby( void ) = 0; |
wardm | 12:046346a16ff4 | 384 | |
wardm | 12:046346a16ff4 | 385 | /*! |
wardm | 12:046346a16ff4 | 386 | * @brief Sets the radio in CAD mode |
wardm | 12:046346a16ff4 | 387 | */ |
wardm | 12:046346a16ff4 | 388 | virtual void StartCad( void ) = 0; |
wardm | 12:046346a16ff4 | 389 | |
wardm | 12:046346a16ff4 | 390 | /*! |
wardm | 12:046346a16ff4 | 391 | * @brief Sets the radio in reception mode for the given time |
wardm | 12:046346a16ff4 | 392 | * @param [IN] timeout Reception timeout [us] |
wardm | 12:046346a16ff4 | 393 | * [0: continuous, others timeout] |
wardm | 12:046346a16ff4 | 394 | */ |
wardm | 12:046346a16ff4 | 395 | virtual void Rx( uint32_t timeout ) = 0; |
wardm | 12:046346a16ff4 | 396 | |
wardm | 12:046346a16ff4 | 397 | /*! |
wardm | 12:046346a16ff4 | 398 | * @brief Check is radio receives a signal |
wardm | 12:046346a16ff4 | 399 | */ |
wardm | 12:046346a16ff4 | 400 | virtual bool RxSignalPending() = 0; |
wardm | 12:046346a16ff4 | 401 | |
wardm | 12:046346a16ff4 | 402 | |
wardm | 12:046346a16ff4 | 403 | /*! |
wardm | 12:046346a16ff4 | 404 | * @brief Sets the radio in transmission mode for the given time |
wardm | 12:046346a16ff4 | 405 | * @param [IN] timeout Transmission timeout [us] |
wardm | 12:046346a16ff4 | 406 | * [0: continuous, others timeout] |
wardm | 12:046346a16ff4 | 407 | */ |
wardm | 12:046346a16ff4 | 408 | virtual void Tx( uint32_t timeout ) = 0; |
wardm | 12:046346a16ff4 | 409 | |
wardm | 12:046346a16ff4 | 410 | /*! |
wardm | 12:046346a16ff4 | 411 | * @brief Sets the radio in continuous wave transmission mode |
wardm | 12:046346a16ff4 | 412 | * |
wardm | 12:046346a16ff4 | 413 | * @param [IN]: freq Channel RF frequency |
wardm | 12:046346a16ff4 | 414 | * @param [IN]: power Sets the output power [dBm] |
wardm | 12:046346a16ff4 | 415 | * @param [IN]: time Transmission mode timeout [s] |
wardm | 12:046346a16ff4 | 416 | */ |
wardm | 12:046346a16ff4 | 417 | virtual void SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time ) = 0; |
wardm | 12:046346a16ff4 | 418 | |
wardm | 12:046346a16ff4 | 419 | /*! |
wardm | 12:046346a16ff4 | 420 | * @brief Returns the maximal transfer unit for a given modem |
wardm | 12:046346a16ff4 | 421 | * |
wardm | 12:046346a16ff4 | 422 | * @retval MTU size in bytes |
wardm | 12:046346a16ff4 | 423 | */ |
wardm | 12:046346a16ff4 | 424 | virtual int16_t MaxMTUSize( RadioModems_t modem ) = 0; |
wardm | 12:046346a16ff4 | 425 | |
wardm | 12:046346a16ff4 | 426 | /*! |
wardm | 12:046346a16ff4 | 427 | * @brief Reads the current RSSI value |
wardm | 12:046346a16ff4 | 428 | * |
wardm | 12:046346a16ff4 | 429 | * @retval rssiValue Current RSSI value in [dBm] |
wardm | 12:046346a16ff4 | 430 | */ |
wardm | 12:046346a16ff4 | 431 | virtual int16_t GetRssi ( RadioModems_t modem ) = 0; |
wardm | 12:046346a16ff4 | 432 | |
wardm | 12:046346a16ff4 | 433 | /*! |
wardm | 12:046346a16ff4 | 434 | * @brief Reads the current frequency error |
wardm | 12:046346a16ff4 | 435 | * |
wardm | 12:046346a16ff4 | 436 | * @retval frequency error value in [Hz] |
wardm | 12:046346a16ff4 | 437 | */ |
wardm | 12:046346a16ff4 | 438 | virtual int32_t GetFrequencyError( RadioModems_t modem ) = 0; |
wardm | 12:046346a16ff4 | 439 | |
wardm | 12:046346a16ff4 | 440 | /*! |
wardm | 12:046346a16ff4 | 441 | * @brief Writes the radio register at the specified address |
wardm | 12:046346a16ff4 | 442 | * |
wardm | 12:046346a16ff4 | 443 | * @param [IN]: addr Register address |
wardm | 12:046346a16ff4 | 444 | * @param [IN]: data New register value |
wardm | 12:046346a16ff4 | 445 | */ |
wardm | 12:046346a16ff4 | 446 | virtual void Write ( uint8_t addr, uint8_t data ) = 0; |
wardm | 12:046346a16ff4 | 447 | |
wardm | 12:046346a16ff4 | 448 | /*! |
wardm | 12:046346a16ff4 | 449 | * @brief Reads the radio register at the specified address |
wardm | 12:046346a16ff4 | 450 | * |
wardm | 12:046346a16ff4 | 451 | * @param [IN]: addr Register address |
wardm | 12:046346a16ff4 | 452 | * @retval data Register value |
wardm | 12:046346a16ff4 | 453 | */ |
wardm | 12:046346a16ff4 | 454 | virtual uint8_t Read ( uint8_t addr ) = 0; |
wardm | 12:046346a16ff4 | 455 | |
wardm | 12:046346a16ff4 | 456 | /*! |
wardm | 12:046346a16ff4 | 457 | * @brief Writes multiple radio registers starting at address |
wardm | 12:046346a16ff4 | 458 | * |
wardm | 12:046346a16ff4 | 459 | * @param [IN] addr First Radio register address |
wardm | 12:046346a16ff4 | 460 | * @param [IN] buffer Buffer containing the new register's values |
wardm | 12:046346a16ff4 | 461 | * @param [IN] size Number of registers to be written |
wardm | 12:046346a16ff4 | 462 | */ |
wardm | 12:046346a16ff4 | 463 | virtual void Write( uint8_t addr, void *buffer, uint8_t size ) = 0; |
wardm | 12:046346a16ff4 | 464 | |
wardm | 12:046346a16ff4 | 465 | /*! |
wardm | 12:046346a16ff4 | 466 | * @brief Reads multiple radio registers starting at address |
wardm | 12:046346a16ff4 | 467 | * |
wardm | 12:046346a16ff4 | 468 | * @param [IN] addr First Radio register address |
wardm | 12:046346a16ff4 | 469 | * @param [OUT] buffer Buffer where to copy the registers data |
wardm | 12:046346a16ff4 | 470 | * @param [IN] size Number of registers to be read |
wardm | 12:046346a16ff4 | 471 | */ |
wardm | 12:046346a16ff4 | 472 | virtual void Read ( uint8_t addr, void *buffer, uint8_t size ) = 0; |
wardm | 12:046346a16ff4 | 473 | |
wardm | 12:046346a16ff4 | 474 | /*! |
wardm | 12:046346a16ff4 | 475 | * @brief Writes the buffer contents to the Radio FIFO |
wardm | 12:046346a16ff4 | 476 | * |
wardm | 12:046346a16ff4 | 477 | * @param [IN] buffer Buffer containing data to be put on the FIFO. |
wardm | 12:046346a16ff4 | 478 | * @param [IN] size Number of bytes to be written to the FIFO |
wardm | 12:046346a16ff4 | 479 | */ |
wardm | 12:046346a16ff4 | 480 | virtual void WriteFifo( void *buffer, uint8_t size ) = 0; |
wardm | 12:046346a16ff4 | 481 | |
wardm | 12:046346a16ff4 | 482 | /*! |
wardm | 12:046346a16ff4 | 483 | * @brief Reads the contents of the Radio FIFO |
wardm | 12:046346a16ff4 | 484 | * |
wardm | 12:046346a16ff4 | 485 | * @param [OUT] buffer Buffer where to copy the FIFO read data. |
wardm | 12:046346a16ff4 | 486 | * @param [IN] size Number of bytes to be read from the FIFO |
wardm | 12:046346a16ff4 | 487 | */ |
wardm | 12:046346a16ff4 | 488 | virtual void ReadFifo( void *buffer, uint8_t size ) = 0; |
wardm | 12:046346a16ff4 | 489 | |
wardm | 12:046346a16ff4 | 490 | /*! |
wardm | 12:046346a16ff4 | 491 | * @brief Sets the maximum payload length. |
wardm | 12:046346a16ff4 | 492 | * |
wardm | 12:046346a16ff4 | 493 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
wardm | 12:046346a16ff4 | 494 | * @param [IN] max Maximum payload length in bytes |
wardm | 12:046346a16ff4 | 495 | */ |
wardm | 12:046346a16ff4 | 496 | virtual void SetMaxPayloadLength( RadioModems_t modem, uint8_t max ) = 0; |
wardm | 12:046346a16ff4 | 497 | |
wardm | 12:046346a16ff4 | 498 | /*! |
wardm | 12:046346a16ff4 | 499 | * @brief Sets the network to public or private. Updates the sync byte. |
wardm | 12:046346a16ff4 | 500 | * |
wardm | 12:046346a16ff4 | 501 | * @remark Applies to LoRa modem only |
wardm | 12:046346a16ff4 | 502 | * |
wardm | 12:046346a16ff4 | 503 | * @param [IN] enable if true, it enables a public network |
wardm | 12:046346a16ff4 | 504 | */ |
wardm | 12:046346a16ff4 | 505 | virtual void SetPublicNetwork( bool enable ) = 0; |
wardm | 12:046346a16ff4 | 506 | |
wardm | 12:046346a16ff4 | 507 | /*! |
wardm | 12:046346a16ff4 | 508 | * \brief Sets the radio output power. |
wardm | 12:046346a16ff4 | 509 | * |
wardm | 12:046346a16ff4 | 510 | * @param [IN] power Sets the RF output power |
wardm | 12:046346a16ff4 | 511 | */ |
wardm | 12:046346a16ff4 | 512 | virtual void SetRfTxPower( int8_t power ) = 0; |
wardm | 12:046346a16ff4 | 513 | |
wardm | 12:046346a16ff4 | 514 | }; |
wardm | 12:046346a16ff4 | 515 | |
wardm | 12:046346a16ff4 | 516 | #endif // __RADIO_H__ |