Skip to content

Commit

Permalink
Add 32MHz-based receive timestamp from hardware as "tm32".
Browse files Browse the repository at this point in the history
  • Loading branch information
ke6jjj committed Oct 14, 2022
1 parent 91a84ec commit 45a783b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions libloragw/inc/loragw_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ struct lgw_pkt_rx_s {
uint8_t if_chain; /*!> by which IF chain was packet received */
uint8_t status; /*!> status of the received packet */
uint32_t count_us; /*!> internal concentrator counter for timestamping, 1 microsecond resolution */
uint32_t count_32; /*!> internal concentrator counter for timestamping, 1/32 microsecond resolution */
uint8_t rf_chain; /*!> through which RF chain the packet was received */
uint8_t modem_id;
uint8_t modulation; /*!> modulation used by the packet */
Expand Down
1 change: 1 addition & 0 deletions libloragw/src/loragw_sx1302.c
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,7 @@ int sx1302_parse(lgw_context_t * context, struct lgw_pkt_rx_s * p) {

/* Packet timestamp corrected */
p->count_us = p->count_us - timestamp_correction;
p->count_32 = p->count_us * 32 + pkt.timestamp_cnt % 32;

/* Packet CRC status */
p->crc = pkt.rx_crc16_value;
Expand Down
6 changes: 3 additions & 3 deletions packet_forwarder/src/lora_pkt_fwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ License: Revised BSD License, see LICENSE.TXT file include in the project
#define STD_FSK_PREAMB 5

#define STATUS_SIZE 200
#define TX_BUFF_SIZE ((540 * NB_PKT_MAX) + 30 + STATUS_SIZE)
#define TX_BUFF_SIZE ((560 * NB_PKT_MAX) + 30 + STATUS_SIZE)
#define ACK_BUFF_SIZE 80

#define UNIX_GPS_EPOCH_OFFSET 315964800 /* Number of seconds ellapsed between 01.Jan.1970 00:00:00
Expand Down Expand Up @@ -1865,8 +1865,8 @@ void thread_up(void) {
exit(EXIT_FAILURE);
}

/* RAW timestamp, 8-17 useful chars */
j = snprintf((char *)(buff_up + buff_index), TX_BUFF_SIZE-buff_index, ",\"tmst\":%u", p->count_us);
/* RAW timestamp, 18-36 useful chars */
j = snprintf((char *)(buff_up + buff_index), TX_BUFF_SIZE-buff_index, ",\"tmst\":%u,\"tm32\":%u", p->count_us, p->count_32);
if (j > 0) {
buff_index += j;
} else {
Expand Down

0 comments on commit 45a783b

Please sign in to comment.