the node firmware of ChiaYi Xingang

Revision:
65:acc0468b9aec
Parent:
64:64982192a2af
--- a/SxRadio.h	Thu Aug 23 14:18:55 2018 -0500
+++ b/SxRadio.h	Thu Apr 18 14:55:19 2019 -0500
@@ -45,7 +45,7 @@
         RF_CAD,
     }RadioState_t;
 
-    SxRadio(uint32_t WakeupTime) : WakeupTime(WakeupTime), State(RF_IDLE), Modem(MODEM_LORA) { }
+    SxRadio(uint32_t WakeupTime) : WakeupTime(WakeupTime), freq_offset(0), State(RF_IDLE), Modem(MODEM_LORA) { }
     virtual ~SxRadio() {};
 
     /*!
@@ -67,9 +67,10 @@
     /*!
      * \brief Configures the radio with the given modem
      *
-     * \param [IN] modem Modem to be used [0: FSK, 1: LoRa] 
+     * \param [IN] modem Modem to be used [0: FSK, 1: LoRa]
      */
     virtual void SetModem( RadioModems_t modem ) = 0;
+	virtual RadioModems_t GetModem( void ) { return Modem; }
     /*!
      * \brief Sets the channel frequency
      *
@@ -90,7 +91,7 @@
     /*!
      * \brief Generates a 32 bits random value based on the RSSI readings
      *
-     * \remark This function sets the radio in LoRa modem mode and disables 
+     * \remark This function sets the radio in LoRa modem mode and disables
      *         all interrupts.
      *         After calling this function either Radio.SetRxConfig or
      *         Radio.SetTxConfig functions must be called.
@@ -105,22 +106,22 @@
      * \param [IN] bandwidth    Sets the bandwidth
      *                          FSK : >= 2600 and <= 250000 Hz
      *                          LoRa: [0: 125 kHz, 1: 250 kHz,
-     *                                 2: 500 kHz, 3: Reserved] 
+     *                                 2: 500 kHz, 3: Reserved]
      * \param [IN] datarate     Sets the Datarate
      *                          FSK : 600..300000 bits/s
      *                          LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
      *                                10: 1024, 11: 2048, 12: 4096  chips]
      * \param [IN] coderate     Sets the coding rate (LoRa only)
      *                          FSK : N/A ( set to 0 )
-     *                          LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] 
-     * \param [IN] bandwidthAfc Sets the AFC Bandwidth (FSK only) 
+     *                          LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
+     * \param [IN] bandwidthAfc Sets the AFC Bandwidth (FSK only)
      *                          FSK : >= 2600 and <= 250000 Hz
-     *                          LoRa: N/A ( set to 0 ) 
+     *                          LoRa: N/A ( set to 0 )
      * \param [IN] preambleLen  Sets the Preamble length
-     *                          FSK : Number of bytes 
+     *                          FSK : Number of bytes
      *                          LoRa: Length in symbols (the hardware adds 4 more symbols)
-     * \param [IN] symbTimeout  Sets the RxSingle timeout value (LoRa only) 
-     *                          FSK : N/A ( set to 0 ) 
+     * \param [IN] symbTimeout  Sets the RxSingle timeout value (LoRa only)
+     *                          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 length is used
@@ -136,6 +137,9 @@
      *                          LoRa: [0: not inverted, 1: inverted]
      * \param [IN] rxContinuous Sets the reception in continuous mode
      *                          [false: single mode, true: continuous mode]
+     * \param [IN] fskPad       Duration in ms to increase FSK rx window
+     *                          FSK: time in ms to increase FSK rx window duration
+     *                          LoRa: N/A
      */
     virtual void SetRxConfig( RadioModems_t modem, uint32_t bandwidth,
                               uint32_t datarate, uint8_t coderate,
@@ -143,11 +147,11 @@
                               uint16_t symbTimeout, bool fixLen,
                               uint8_t payloadLen,
                               bool crcOn, bool FreqHopOn, uint8_t HopPeriod,
-                              bool iqInverted, bool rxContinuous ) = 0;
+                              bool iqInverted, bool rxContinuous , uint32_t fskPad = 0) = 0;
     /*!
      * \brief Sets the transmission parameters
      *
-     * \param [IN] modem        Radio modem to be used [0: FSK, 1: LoRa] 
+     * \param [IN] modem        Radio modem to be used [0: FSK, 1: LoRa]
      * \param [IN] power        Sets the output power [dBm]
      * \param [IN] fdev         Sets the frequency deviation (FSK only)
      *                          FSK : [Hz]
@@ -155,16 +159,16 @@
      * \param [IN] bandwidth    Sets the bandwidth (LoRa only)
      *                          FSK : 0
      *                          LoRa: [0: 125 kHz, 1: 250 kHz,
-     *                                 2: 500 kHz, 3: Reserved] 
+     *                                 2: 500 kHz, 3: Reserved]
      * \param [IN] datarate     Sets the Datarate
      *                          FSK : 600..300000 bits/s
      *                          LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
      *                                10: 1024, 11: 2048, 12: 4096  chips]
      * \param [IN] coderate     Sets the coding rate (LoRa only)
      *                          FSK : N/A ( set to 0 )
-     *                          LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] 
+     *                          LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
      * \param [IN] preambleLen  Sets the preamble length
-     *                          FSK : Number of bytes 
+     *                          FSK : Number of bytes
      *                          LoRa: Length in symbols (the hardware adds 4 more symbols)
      * \param [IN] fixLen       Fixed length packets [0: variable, 1: fixed]
      * \param [IN] crcOn        Enables disables the CRC [0: OFF, 1: ON]
@@ -179,13 +183,15 @@
      *                          LoRa: [0: not inverted, 1: inverted]
      * \param [IN] timeout      Transmission timeout [us]
      */
-    virtual void SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev, 
+    virtual void SetTxConfig( RadioModems_t 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;
 
-    virtual void SetTxContinuous(bool enable) = 0;
+    virtual void SetTxPower(int8_t power) = 0;
+
+    virtual void SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time ) = 0;
 
     /*!
      * \brief Checks if the given RF frequency is supported by the hardware
@@ -269,6 +275,7 @@
     virtual void ReadBuffer( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0;
 
     virtual void SignalMacEvent(void) {};
+    virtual void SignalLinkEvent(void) {};
 
     virtual void ResetRadio(void) {};
 
@@ -277,9 +284,17 @@
     void GrabMutex(void) { mutex.lock(); }
     void ReleaseMutex(void) { mutex.unlock(); }
 
+    int32_t GetFrequencyOffset() { return freq_offset; }
+    void SetFrequencyOffset(int32_t offset) { freq_offset = offset; }
+
     const uint32_t WakeupTime;
 
+
+
+
 protected:
+    int32_t freq_offset;
+
     RadioState_t State;
 
     RadioModems_t Modem;
@@ -288,6 +303,7 @@
      * Access protection
      */
     Mutex mutex;
+
 };
 
 #endif // __SXRADIO_H__