Correction in RX config error. If REG_LR_PAYLOADLENGTH and REG_LR_PAYLOADMAXLENGTH is not set, the RX is limited to 64 bytes.

Fork of SX1276Lib by Semtech

Revision:
13:618826a997e2
Parent:
12:aa5b3bf7fdf4
Child:
19:71a47bb03fbb
--- a/radio/radio.h	Mon Oct 13 07:33:11 2014 +0000
+++ b/radio/radio.h	Tue Dec 16 10:02:45 2014 +0000
@@ -20,27 +20,27 @@
 #include "./enums/enums.h"
 
 /*!
- *	Interface for the radios, contains the main functions that a radio needs, and 5 callback functions
+ *    Interface for the radios, contains the main functions that a radio needs, and 5 callback functions
  */
 class Radio
 {
 protected:
 
-	//-------------------------------------------------------------------------
-	//						Callback functions pointers
-	//-------------------------------------------------------------------------
-	
-	/*!
+    //-------------------------------------------------------------------------
+    //                        Callback functions pointers
+    //-------------------------------------------------------------------------
+    
+    /*!
      * @brief  Tx Done callback prototype.
      */
-	void ( *txDone )( );
+    void ( *txDone )( );
 
-	/*!
+    /*!
      * @brief  Tx Timeout callback prototype.
      */
-	void ( *txTimeout ) ( );
+    void ( *txTimeout ) ( );
 
-	/*!
+    /*!
      * @brief Rx Done callback prototype.
      *
      * @param [IN] payload Received buffer pointer
@@ -50,19 +50,19 @@
      *                     FSK : N/A ( set to 0 )
      *                     LoRa: SNR value in dB
      */
-	void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );
+    void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );
 
     /*!
      * @brief  Rx Timeout callback prototype.
      */
-	void ( *rxTimeout ) ( );
-	
+    void ( *rxTimeout ) ( );
+    
     /*!
      * @brief Rx Error callback prototype.
      */
-	void ( *rxError ) ( );
-	
-	/*!
+    void ( *rxError ) ( );
+    
+    /*!
      * \brief  FHSS Change Channel callback prototype.
      *
      * \param [IN] CurrentChannel   Index number of the current channel
@@ -74,43 +74,50 @@
      *
      * @param [IN] ChannelDetected    Channel Activity detected during the CAD
      */
-    void ( *cadDone ) ( bool ChannelActivityDetected );
-	
+    void ( *cadDone ) ( bool channelActivityDetected );
+    
 public:
-	//-------------------------------------------------------------------------
-	//						Constructor
-	//-------------------------------------------------------------------------
-	/*!
-	 * @brief Constructor of the radio object, the parameters are the callback functions described in the header.
-	 * @param [IN]	txDone
-	 * @param [IN]	txTimeout
-	 * @param [IN]	rxDone
-	 * @param [IN]	rxTimeout
-	 * @param [IN]	rxError
-	 */
-	Radio( void ( *txDone )( ), void ( *txTimeout ) ( ), void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ), 
-		   void ( *rxTimeout ) ( ), void ( *rxError ) ( ), void ( *fhssChangeChannel ) ( uint8_t channelIndex ), void ( *cadDone ) ( bool ChannelActivityDetected ) );
-	virtual ~Radio( ) {};
+    //-------------------------------------------------------------------------
+    //                        Constructor
+    //-------------------------------------------------------------------------
+    /*!
+     * @brief Constructor of the radio object, the parameters are the callback functions described in the header.
+     * @param [IN]    txDone
+     * @param [IN]    txTimeout
+     * @param [IN]    rxDone
+     * @param [IN]    rxTimeout
+     * @param [IN]    rxError
+     */
+    Radio( void ( *txDone )( ), void ( *txTimeout ) ( ), void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ), 
+           void ( *rxTimeout ) ( ), void ( *rxError ) ( ), void ( *fhssChangeChannel ) ( uint8_t channelIndex ), void ( *cadDone ) ( bool channelActivityDetected ) );
+    virtual ~Radio( ) {};
 
-	//-------------------------------------------------------------------------
-	//						Pure virtual functions
-	//-------------------------------------------------------------------------
+    //-------------------------------------------------------------------------
+    //                        Pure virtual functions
+    //-------------------------------------------------------------------------
 
-	/*!
+    /*!
      * Return current radio status
      *
      * @param status Radio status.[RF_IDLE, RF_RX_RUNNING, RF_TX_RUNNING]
      */
     virtual RadioState GetState( void ) = 0; 
-    
-	/*!
+
+    /*!
+     * \brief Configures the radio with the given modem
+     *
+     * \param [IN] modem Modem to be used [0: FSK, 1: LoRa] 
+     */
+    virtual void SetModem( ModemType modem ) = 0;
+
+    /*!
      * @brief Sets the channel frequency
      *
      * @param [IN] freq         Channel RF frequency
      */
     virtual void SetChannel( uint32_t freq ) = 0;
     
-	/*!
+    /*!
      * @brief Sets the channels configuration
      *
      * @param [IN] modem      Radio modem to be used [0: FSK, 1: LoRa]
@@ -121,7 +128,7 @@
      */
     virtual bool IsChannelFree( ModemType modem, uint32_t freq, int8_t rssiThresh ) = 0;
     
-	/*!
+    /*!
      * @brief Generates a 32 bits random value based on the RSSI readings
      *
      * \remark This function sets the radio in LoRa modem mode and disables
@@ -133,7 +140,7 @@
      */
     virtual uint32_t Random( void )= 0;
     
-	/*!
+    /*!
      * @brief Sets the reception parameters
      *
      * @param [IN] modem        Radio modem to be used [0: FSK, 1: LoRa]
@@ -158,9 +165,10 @@
      *                          FSK : N/A ( set to 0 )
      *                          LoRa: timeout in symbols
      * @param [IN] fixLen       Fixed length packets [0: variable, 1: fixed]
+     * @param [IN] payloadLen   Sets payload length when fixed lenght is used
      * @param [IN] crcOn        Enables/Disables the CRC [0: OFF, 1: ON]
-     * @param [IN] FreqHopOn    Enables disables the intra-packet frequency hopping  [0: OFF, 1: ON] (LoRa only)
- 	 * @param [IN] HopPeriod    Number of symbols bewteen each hop (LoRa only)
+     * @param [IN] freqHopOn    Enables disables the intra-packet frequency hopping  [0: OFF, 1: ON] (LoRa only)
+     * @param [IN] hopPeriod    Number of symbols bewteen each hop (LoRa only)
      * @param [IN] iqInverted   Inverts IQ signals ( LoRa only )
      *                          FSK : N/A ( set to 0 )
      *                          LoRa: [0: not inverted, 1: inverted]
@@ -171,10 +179,11 @@
                                uint32_t datarate, uint8_t coderate,
                                uint32_t bandwidthAfc, uint16_t preambleLen,
                                uint16_t symbTimeout, bool fixLen,
-                               bool crcOn, bool FreqHopOn, uint8_t HopPeriod,
+                               uint8_t payloadLen,
+                               bool crcOn, bool freqHopOn, uint8_t hopPeriod,
                                bool iqInverted, bool rxContinuous ) = 0;
     
-	/*!
+    /*!
      * @brief Sets the transmission parameters
      *
      * @param [IN] modem        Radio modem to be used [0: FSK, 1: LoRa]
@@ -196,8 +205,8 @@
      * @param [IN] preambleLen  Sets the preamble length
      * @param [IN] fixLen       Fixed length packets [0: variable, 1: fixed]
      * @param [IN] crcOn        Enables disables the CRC [0: OFF, 1: ON]
-     * @param [IN] FreqHopOn    Enables disables the intra-packet frequency hopping  [0: OFF, 1: ON] (LoRa only)
- 	 * @param [IN] HopPeriod    Number of symbols bewteen each hop (LoRa only)
+     * @param [IN] freqHopOn    Enables disables the intra-packet frequency hopping  [0: OFF, 1: ON] (LoRa only)
+     * @param [IN] hopPeriod    Number of symbols bewteen each hop (LoRa only)
      * @param [IN] iqInverted   Inverts IQ signals ( LoRa only )
      *                          FSK : N/A ( set to 0 )
      *                          LoRa: [0: not inverted, 1: inverted]
@@ -206,10 +215,10 @@
     virtual void SetTxConfig( ModemType modem, int8_t power, uint32_t fdev,
                               uint32_t bandwidth, uint32_t datarate,
                               uint8_t coderate, uint16_t preambleLen,
-                              bool fixLen, bool crcOn, bool FreqHopOn,
-                              uint8_t HopPeriod, bool iqInverted, uint32_t timeout ) = 0;
+                              bool fixLen, bool crcOn, bool freqHopOn,
+                              uint8_t hopPeriod, bool iqInverted, uint32_t timeout ) = 0;
     
-	/*!
+    /*!
      * @brief Checks if the given RF frequency is supported by the hardware
      *
      * @param [IN] frequency RF frequency to be checked
@@ -217,7 +226,7 @@
      */
     virtual bool CheckRfFrequency( uint32_t frequency ) = 0;
     
-	/*!
+    /*!
      * @brief Computes the packet time on air for the given payload
      *
      * \Remark Can only be called once SetRxConfig or SetTxConfig have been called
@@ -229,7 +238,7 @@
      */
     virtual double TimeOnAir ( ModemType modem, uint8_t pktLen ) = 0;
     
-	/*!
+    /*!
      * @brief Sends the buffer of size. Prepares the packet to be sent and sets
      *        the radio in transmission
      *
@@ -238,43 +247,43 @@
      */
     virtual void Send( uint8_t *buffer, uint8_t size ) = 0;
     
-	/*!
+    /*!
      * @brief Sets the radio in sleep mode
      */
     virtual void Sleep( void ) = 0;
     
-	/*!
+    /*!
      * @brief Sets the radio in standby mode
      */
     virtual void Standby( void ) = 0;
     
-	/*!
+    /*!
      * @brief Sets the radio in CAD mode
      */
     virtual void StartCad( void ) = 0;
     
-	/*!
+    /*!
      * @brief Sets the radio in reception mode for the given time
      * @param [IN] timeout Reception timeout [us]
      *                     [0: continuous, others timeout]
      */
     virtual void Rx( uint32_t timeout ) = 0;
     
-	/*!
+    /*!
      * @brief Sets the radio in transmission mode for the given time
      * @param [IN] timeout Transmission timeout [us]
      *                     [0: continuous, others timeout]
      */
     virtual void Tx( uint32_t timeout ) = 0;
     
-	/*!
+    /*!
      * @brief Reads the current RSSI value
      *
      * @retval rssiValue Current RSSI value in [dBm]
      */
     virtual int16_t GetRssi ( ModemType modem ) = 0;
     
-	/*!
+    /*!
      * @brief Writes the radio register at the specified address
      *
      * @param [IN]: addr Register address
@@ -282,7 +291,7 @@
      */
     virtual void Write ( uint8_t addr, uint8_t data ) = 0;
     
-	/*!
+    /*!
      * @brief Reads the radio register at the specified address
      *
      * @param [IN]: addr Register address
@@ -290,7 +299,7 @@
      */
     virtual uint8_t Read ( uint8_t addr ) = 0;
     
-	/*!
+    /*!
      * @brief Writes multiple radio registers starting at address
      *
      * @param [IN] addr   First Radio register address
@@ -299,7 +308,7 @@
      */
     virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0;
     
-	/*!
+    /*!
      * @brief Reads multiple radio registers starting at address
      *
      * @param [IN] addr First Radio register address
@@ -307,22 +316,22 @@
      * @param [IN] size Number of registers to be read
      */
     virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0;
-	
-	/*!
-	 * @brief Writes the buffer contents to the SX1276 FIFO
-	 *
-	 * @param [IN] buffer Buffer containing data to be put on the FIFO.
-	 * @param [IN] size Number of bytes to be written to the FIFO
-	 */
-	virtual void WriteFifo( uint8_t *buffer, uint8_t size ) = 0;
+    
+    /*!
+     * @brief Writes the buffer contents to the SX1276 FIFO
+     *
+     * @param [IN] buffer Buffer containing data to be put on the FIFO.
+     * @param [IN] size Number of bytes to be written to the FIFO
+     */
+    virtual void WriteFifo( uint8_t *buffer, uint8_t size ) = 0;
 
-	/*!
-	 * @brief Reads the contents of the SX1276 FIFO
-	 *
-	 * @param [OUT] buffer Buffer where to copy the FIFO read data.
-	 * @param [IN] size Number of bytes to be read from the FIFO
-	 */
-	virtual void ReadFifo( uint8_t *buffer, uint8_t size ) = 0;
+    /*!
+     * @brief Reads the contents of the SX1276 FIFO
+     *
+     * @param [OUT] buffer Buffer where to copy the FIFO read data.
+     * @param [IN] size Number of bytes to be read from the FIFO
+     */
+    virtual void ReadFifo( uint8_t *buffer, uint8_t size ) = 0;
 };
 
 #endif // __RADIO_H__