spoerk / contiki

BLEach: Exploiting the Full Potential of IPv6 over BLE in Constrained Embedded IoT Devices
Other
14 stars 12 forks source link

how to get timestamp information from a packet? #7

Open TayyabaZainab0807 opened 5 years ago

TayyabaZainab0807 commented 5 years ago

under the file ble-hal-cc26xx.c it's written "len = RX_ENTRY_DATA_LENGTH(param->rx_queue_current) - 6 - 2; / last 8 bytes are status, timestamp, ... / " I am interested in the timestamp information. T am not sure which byte contain this information.

spoerk commented 5 years ago

In case you want to get the timestamp when a BLE data packet was received during a connection event, you can use the output->timeStamp information stored in rfc_bleMasterSlaveOutput_t *output = (rfc_bleMasterSlaveOutput_t *)conn->output_buf;

See the code snippet in ble-hal-cc26xx.c in line 1256 and 1288.

TayyabaZainab0807 commented 5 years ago

Can we also retrieve this information through connection_event_master() in ble-hal-cc26xx.c ? As I am interested in the timestamp of received BLE data packet at master end.

spoerk commented 5 years ago

Sure, it works the same way as for connection_event_slave(). You just need to get the output buffer of the connection rfc_bleMasterSlaveOutput_t *output = (rfc_bleMasterSlaveOutput_t *)conn->output_buf; and get its time stamp.

TayyabaZainab0807 commented 5 years ago

tried with the following code:

connection_event_master(...) {... rfc_bleMasterSlaveOutput_t output = (rfc_bleMasterSlaveOutput_t )conn->output_buf; output->timeStamp; ...}

it's giving 0.

spoerk commented 5 years ago

Oh, according to the Technical Reference Manual of the TI CC2650, the timestamp of the first received packet is only available on the BLE slave.

You can configure the RX queue of the BLE radio core to append the timestamp. See the reference manual starting from page 1525.

TayyabaZainab0807 commented 5 years ago

Hi, Do we have SFD timestamping for BLE radio in cc2650?

spoerk commented 5 years ago

What do you mean with SFD timestamping?

TayyabaZainab0807 commented 5 years ago

With reference to Technical Reference Manual of the TI CC2650 page 1643 for 802.15.4 radio

If rxConfig.bAppendRssi is 1, a byte indicating the received RSSI value is appended. If rxConfig.bAppendCorrCrc is 1, a status byte of the type defined in Table 23-76 is appended. If rxConfig.bAppendSrcInd is 1, a byte giving the index of the first source matching entry that matches the header of the received packet is appended, or 0xFF if no match. If rxConfig.bAppendTimeStamp is 1, a timestamp indicating the start of the frame is appended. This timestamp is a 4-byte number from the radio timer. Though the timestamp is multibyte, no word-address alignment is made, so the timestamp must be written and read byte-wise. The timestamp is captured when SFD is found, but is adjusted to reflect the start of the frame (assuming 8 preamble bytes as per the standard), defined so that it corresponds to the time of the start trigger used on the transmit side. The adjustment is defined in the syncTimeAdjust firmware-defined parameter, and may be overridden.

TayyabaZainab0807 commented 5 years ago

I was able to capture the timestamp as described on page:1668 of the manual for BLE but I guess it's not reflecting the start of the frame.