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