commit
4ab0f92c6c
@ -47,7 +47,14 @@ typedef uint32_t rtimer_clock_t;
|
||||
#define RADIO_DELAY_BEFORE_DETECT 0
|
||||
#ifndef TSCH_CONF_BASE_DRIFT_PPM
|
||||
/* The drift compared to "true" 10ms slots.
|
||||
* Enable adaptive sync to enable compensation for this. */
|
||||
* Enable adaptive sync to enable compensation for this.
|
||||
* Slot length 10000 usec
|
||||
* 328 ticks
|
||||
* Tick duration 30.517578125 usec
|
||||
* Real slot duration 10009.765625 usec
|
||||
* Target - real duration = -9.765625 usec
|
||||
* TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
*/
|
||||
#define TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -110,8 +110,14 @@ typedef uint32_t rtimer_clock_t;
|
||||
|
||||
/* If the timer base a binary 32kHz clock, compensate for this base drift */
|
||||
#if RTIMER_USE_32KHZ && JN516X_EXTERNAL_CRYSTAL_OSCILLATOR
|
||||
/* Drift calculated using this formula:
|
||||
* ((US_TO_TICKS(10000) * 100) - RTIMER_SECOND) * 1e6 = 976.5625 ppm
|
||||
/* The drift compared to "true" 10ms slots.
|
||||
* Enable adaptive sync to enable compensation for this.
|
||||
* Slot length 10000 usec
|
||||
* 328 ticks
|
||||
* Tick duration 30.517578125 usec
|
||||
* Real slot duration 10009.765625 usec
|
||||
* Target - real duration = -9.765625 usec
|
||||
* TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
*/
|
||||
#define TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
#endif
|
||||
|
@ -86,7 +86,14 @@ typedef uint32_t rtimer_clock_t;
|
||||
#define RADIO_DELAY_BEFORE_DETECT 0
|
||||
#ifndef TSCH_CONF_BASE_DRIFT_PPM
|
||||
/* The drift compared to "true" 10ms slots.
|
||||
* Enable adaptive sync to enable compensation for this. */
|
||||
* Enable adaptive sync to enable compensation for this.
|
||||
* Slot length 10000 usec
|
||||
* 328 ticks
|
||||
* Tick duration 30.517578125 usec
|
||||
* Real slot duration 10009.765625 usec
|
||||
* Target - real duration = -9.765625 usec
|
||||
* TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
*/
|
||||
#define TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -280,7 +280,14 @@ typedef uint32_t rtimer_clock_t;
|
||||
|
||||
#ifndef TSCH_CONF_BASE_DRIFT_PPM
|
||||
/* The drift compared to "true" 10ms slots.
|
||||
* Enable adaptive sync to enable compensation for this. */
|
||||
* Enable adaptive sync to enable compensation for this.
|
||||
* Slot length 10000 usec
|
||||
* 328 ticks
|
||||
* Tick duration 30.517578125 usec
|
||||
* Real slot duration 10009.765625 usec
|
||||
* Target - real duration = -9.765625 usec
|
||||
* TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
*/
|
||||
#define TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
#endif
|
||||
|
||||
|
@ -84,7 +84,14 @@ typedef uint32_t rtimer_clock_t;
|
||||
#define RADIO_DELAY_BEFORE_DETECT 0
|
||||
#ifndef TSCH_CONF_BASE_DRIFT_PPM
|
||||
/* The drift compared to "true" 10ms slots.
|
||||
* Enable adaptive sync to enable compensation for this. */
|
||||
* Enable adaptive sync to enable compensation for this.
|
||||
* Slot length 10000 usec
|
||||
* 328 ticks
|
||||
* Tick duration 30.517578125 usec
|
||||
* Real slot duration 10009.765625 usec
|
||||
* Target - real duration = -9.765625 usec
|
||||
* TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
*/
|
||||
#define TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -68,7 +68,7 @@ tsch_adaptive_timesync_get_drift_ppm(void)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Add a value to a moving average estimator */
|
||||
static int32_t
|
||||
timesync_entry_add(int32_t val, uint32_t time_delta)
|
||||
timesync_entry_add(int32_t val)
|
||||
{
|
||||
#define NUM_TIMESYNC_ENTRIES 8
|
||||
static int32_t buffer[NUM_TIMESYNC_ENTRIES];
|
||||
@ -101,9 +101,9 @@ timesync_learn_drift_ticks(uint32_t time_delta_asn, int32_t drift_ticks)
|
||||
/* should fit in a 32-bit integer */
|
||||
int32_t time_delta_ticks = time_delta_asn * tsch_timing[tsch_ts_timeslot_length];
|
||||
int32_t real_drift_ticks = drift_ticks + compensated_ticks;
|
||||
int32_t last_drift_ppm = (int32_t)((int64_t)real_drift_ticks * TSCH_DRIFT_UNIT / time_delta_ticks);
|
||||
int32_t last_drift_ppm = (int32_t)(((int64_t)real_drift_ticks * TSCH_DRIFT_UNIT) / time_delta_ticks);
|
||||
|
||||
drift_ppm = timesync_entry_add(last_drift_ppm, time_delta_ticks);
|
||||
drift_ppm = timesync_entry_add(last_drift_ppm);
|
||||
|
||||
TSCH_LOG_ADD(tsch_log_message,
|
||||
snprintf(log->message, sizeof(log->message),
|
||||
|
@ -138,6 +138,7 @@ tsch_security_secure_frame(uint8_t *hdr, uint8_t *outbuf,
|
||||
uint8_t with_encryption;
|
||||
uint8_t mic_len;
|
||||
uint8_t nonce[16];
|
||||
struct ieee802154_ies ies;
|
||||
|
||||
uint8_t a_len;
|
||||
uint8_t m_len;
|
||||
@ -151,6 +152,13 @@ tsch_security_secure_frame(uint8_t *hdr, uint8_t *outbuf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
if(frame802154e_parse_information_elements(hdr + hdrlen, datalen, &ies) > 0) {
|
||||
/* put Header IEs into the header part which is not encrypted */
|
||||
hdrlen += ies.ie_payload_ie_offset;
|
||||
datalen -= ies.ie_payload_ie_offset;
|
||||
}
|
||||
|
||||
if(!frame.fcf.security_enabled) {
|
||||
/* Security is not enabled for this frame, we're done */
|
||||
return 0;
|
||||
@ -204,6 +212,7 @@ tsch_security_parse_frame(const uint8_t *hdr, int hdrlen, int datalen,
|
||||
uint8_t nonce[16];
|
||||
uint8_t a_len;
|
||||
uint8_t m_len;
|
||||
struct ieee802154_ies ies;
|
||||
|
||||
if(frame == NULL || hdr == NULL || hdrlen < 0 || datalen < 0) {
|
||||
return 0;
|
||||
@ -229,6 +238,12 @@ tsch_security_parse_frame(const uint8_t *hdr, int hdrlen, int datalen,
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
(void)frame802154e_parse_information_elements(hdr + hdrlen, datalen, &ies);
|
||||
/* put Header IEs into the header part which is not encrypted */
|
||||
hdrlen += ies.ie_payload_ie_offset;
|
||||
datalen -= ies.ie_payload_ie_offset;
|
||||
|
||||
tsch_security_init_nonce(nonce, sender, asn);
|
||||
|
||||
if(with_encryption) {
|
||||
|
@ -763,6 +763,12 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t))
|
||||
|
||||
packet_duration = TSCH_PACKET_DURATION(current_input->len);
|
||||
|
||||
if(!frame_valid) {
|
||||
TSCH_LOG_ADD(tsch_log_message,
|
||||
snprintf(log->message, sizeof(log->message),
|
||||
"!failed to parse frame %u %u", header_len, current_input->len));
|
||||
}
|
||||
|
||||
if(frame_valid) {
|
||||
if(frame.fcf.frame_type != FRAME802154_DATAFRAME
|
||||
&& frame.fcf.frame_type != FRAME802154_BEACONFRAME) {
|
||||
@ -786,11 +792,6 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t))
|
||||
"!failed to authenticate frame %u", current_input->len));
|
||||
frame_valid = 0;
|
||||
}
|
||||
} else {
|
||||
TSCH_LOG_ADD(tsch_log_message,
|
||||
snprintf(log->message, sizeof(log->message),
|
||||
"!failed to parse frame %u %u", header_len, current_input->len));
|
||||
frame_valid = 0;
|
||||
}
|
||||
#endif /* LLSEC802154_ENABLED */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user