How to understand “precise_timestamp_calculate”?
chris-william0829 opened this issue · 0 comments
hey, guys.
i found sx1302 gives two timestamps, and the precision timestamp gives a timestamp at the end of the header. (in loragw_sx1302_timestamp.h)
/**
@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 ftime_enable);
but in the function "precise_timestamp_calculate"(in loragw_sx1302_timestamp.c), there is a code to shift the timestamp at the end of header to the end of preamble.
/* Coarse timestamp correction to match with GW v2 (end of header -> end of preamble) */
offset_preamble_hdr = 256 * (1 << sf) * (8 + 4 + (((sf == 5) || (sf == 6)) ? 2 : 0)) +
256 * ((1 << sf) / 4 - 1); /* 32e6 / 125e3 = 256 */
/* Take the packet frequency error in account in the offset */
offset_preamble_hdr += ((double)offset_preamble_hdr * pkt_freq_error + 0.5);
timestamp_cnt_end_of_preamble = timestamp_cnt - offset_preamble_hdr + 2138; /* 2138 is the number of 32MHz clock cycle offset b/w GW_V2 and SX1303 decimation/filtering group delay */
/* Shift the packet coarse timestamp which is used to get ref PPS counter */
timestamp_cnt = timestamp_cnt_end_of_preamble;
so, does the 'offset_preamble_hdr' means the transmission time of the header? and how to understand the equation?
And one more thing. In sx127x datasheet, semtech gives the calculation of the time on air for lora.
I never knew how to understand the calculation of the npayload.
which part is the header?
How to understand the offset_preamble_hdr and the calculation of the npayload in sx127x datasheet?
I would appreciate for your help!