* HAL: Fixed scheduled downlink time precision by taking the tx start delay into
account.
* HAL: Fixed timestamp correction calculation for BW250 & BW500
* HAL: Fixed possible buffer overflow in lgw_receive() function
* HAL: Keep packet received in RX buffer when the buffer allocated to receive
the packets is too small. Remaining packets will be fetched on the next
lgw_receive calls (aligned on SX1301 behaviour).
This commit is contained in:
Michael Coracin 2019-09-20 11:06:37 +02:00
commit 5942224602
10 changed files with 217 additions and 122 deletions

View file

@ -350,28 +350,15 @@ void sx1302_arb_print_debug_stats(void);
uint16_t sx1302_lora_payload_crc(const uint8_t * data, uint8_t size);
/**
@brief TODO
@param TODO
@return TODO
*/
uint16_t sx1302_rx_buffer_read_ptr_addr(void);
/**
@brief TODO
@param TODO
@return TODO
*/
uint16_t sx1302_rx_buffer_write_ptr_addr(void);
/**
@brief Check if any data to be fetched from the SX1302 RX buffer and fetch it if any.
@param nb_bytes A pointer to allocated memory to hold the number of bytes fetched
@brief Get the number of packets available in rx_buffer and fetch data from ...
@brief ... the SX1302 if rx_buffer is empty.
@param nb_pkt A pointer to allocated memory to hold the number of packet fetched
@return LGW_REG_SUCCESS if success, LGW_REG_ERROR otherwise
*/
int sx1302_fetch(uint16_t * nb_bytes);
int sx1302_fetch(uint8_t * nb_pkt);
/**
@brief Parse and return the next packet available in the fetched RX buffer.
@brief Parse and return the next packet available in rx_buffer.
@param context Gateway configuration context
@param p The structure to get the packet parsed
@return LGW_REG_SUCCESS if a packet could be parsed, LGW_REG_ERROR otherwise
@ -384,9 +371,10 @@ int sx1302_parse(lgw_context_t * context, struct lgw_pkt_rx_s * p);
@param radio_type The type of radio for this RF chain
@param modulation The modulation used for the TX
@param bandwidth The bandwidth used for the TX
@param delay The TX start delay calculated and applied
@return LGW_REG_SUCCESS if success, LGW_REG_ERROR otherwise
*/
int sx1302_tx_set_start_delay(uint8_t rf_chain, lgw_radio_type_t radio_type, uint8_t modulation, uint8_t bandwidth);
int sx1302_tx_set_start_delay(uint8_t rf_chain, lgw_radio_type_t radio_type, uint8_t modulation, uint8_t bandwidth, uint16_t * delay);
/**
@brief Compute the offset to be applied on RSSI for temperature compensation

View file

@ -72,36 +72,38 @@ typedef struct rx_buffer_s {
uint8_t buffer[4096]; /*!> byte array to hald the data fetched from the RX buffer */
uint16_t buffer_size; /*!> The number of bytes currently stored in the buffer */
int buffer_index; /*!> Current parsing index in the buffer */
uint8_t buffer_pkt_nb;
} rx_buffer_t;
/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
/**
@brief TODO
@param TODO
@return TODO
@brief Initialize the rx_buffer instance
@param self A pointer to a rx_buffer handler
@return LGW_REG_SUCCESS if success, LGW_REG_ERROR otherwise
*/
int rx_buffer_new(rx_buffer_t * self);
/**
@brief TODO
@param TODO
@return TODO
@brief Reset the rx_buffer instance
@param self A pointer to a rx_buffer handler
@return LGW_REG_SUCCESS if success, LGW_REG_ERROR otherwise
*/
int rx_buffer_del(rx_buffer_t * self);
/**
@brief TODO
@param TODO
@return TODO
@brief Fetch packets from the SX1302 internal RX buffer, and count packets available.
@param self A pointer to a rx_buffer handler
@return LGW_REG_SUCCESS if success, LGW_REG_ERROR otherwise
*/
int rx_buffer_fetch(rx_buffer_t * self);
/**
@brief TODO
@param TODO
@return TODO
@brief Parse the rx_buffer and return the first packet available in the given structure.
@param self A pointer to a rx_buffer handler
@param pkt A pointer to the structure to receive the packet parsed
@return LGW_REG_SUCCESS if success, LGW_REG_ERROR otherwise
*/
int rx_buffer_pop(rx_buffer_t * self, rx_packet_t * pkt);

View file

@ -54,16 +54,16 @@ typedef struct timestamp_counter_s {
/* --- PUBLIC FUNCTIONS ----------------------------------------------------- */
/**
@brief TODO
@param TODO
@return TODO
@brief Initialize the timestamp_counter instance
@param self Pointer to the counter handler
@return N/A
*/
void timestamp_counter_new(timestamp_counter_t * self);
/**
@brief TODO
@param TODO
@return TODO
@brief Reset the timestamp_counter instance
@param self Pointer to the counter handler
@return N/A
*/
void timestamp_counter_delete(timestamp_counter_t * self);
@ -106,9 +106,14 @@ uint32_t timestamp_counter_get(timestamp_counter_t * self, bool pps);
uint32_t timestamp_counter_correction(int ifmod, uint8_t bandwidth, uint8_t datarate, uint8_t coderate, uint32_t crc_en, uint16_t payload_length);
/**
@brief TODO
@param TODO
@return TODO
@brief Configure the SX1302 to output legacy timestamp or precision timestamp
@note Legacy timestamp gives a timestamp latched at the end of the packet
@note Precision timestamp gives a timestamp latched at the end of the header
@note and additionally supplies metrics every N symbols troughout the payload.
@param enable_precision_ts A boolean to enable precision timestamp output.
@param max_ts_metrics The number of timestamp metrics to be returned when precision timestamp is enabled
@param nb_symbols The sampling rate of timestamp metrics
@return LGW_REG_SUCCESS if success, LGW_REG_ERROR otherwise
*/
int timestamp_counter_mode(bool enable_precision_ts, uint8_t max_ts_metrics, uint8_t nb_symbols);