# Two Way Ranging Protocol

The two way ranging protocol allows a tag to measure its distance to an anchor. The protocol contains 4 messages, two are sent by the tag and two by the anchor. The message sequence is as follow:

The time of flight is calculated using the formula:

TWR packet IDs

ID Description
0x01 TWR_POLL
0x03 TWR_FINAL
0x04 TWR_REPORT

## TWR_POLL

Format:

0 SEQ 1 Byte sequence number, is repeated in subsequent packet of the same TWR transaction

Format:

0 SEQ 1 Byte sequence number, matches the POLL sequence number
1.. LPP management message Optional LPP management data

The optional management data can be any LPP management packet deemed useful for the tag. Currently this is used to send the anchor position from the anchor to the tag using the LPP Short anchor position packet

## TWR_FINAL

Format:

0 SEQ 1 Byte sequence number, matches the POLL sequence number

## TWR_REPORT

Format:

0 SEQ 1 Byte sequence number, matches the POLL sequence number
1.. Report Report structure, see format bellow

Report structure format:

typedef struct {
uint8_t pollRx[5];      // R1 timestamp