From 0dfd7d54bdc196d720e86cbe11de553aa65cfd8c Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 29 Apr 2019 09:14:50 -0400 Subject: [PATCH] Remove extra beacon debug setting Was only used to print bad beacon frames --- .../lorawan/lorastack/mac/LoRaMacClassB.cpp | 39 +++++++------------ features/lorawan/mbed_lib.json | 6 +-- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/features/lorawan/lorastack/mac/LoRaMacClassB.cpp b/features/lorawan/lorastack/mac/LoRaMacClassB.cpp index eaed20b59d..b5c1b415aa 100644 --- a/features/lorawan/lorastack/mac/LoRaMacClassB.cpp +++ b/features/lorawan/lorastack/mac/LoRaMacClassB.cpp @@ -60,15 +60,6 @@ LoRaMacClassB LoRaMacClassB::_loramac_class_b; #define LORA_BEACON_INTERVAL_MILLIS (LORA_BEACON_INTERVAL*1000UL) -/*! - * Extra beacon debug logging that can be enabled with a json option - */ -#if MBED_CONF_LORA_CLASS_B_EXTRA_DEBUG_TRACE_LEVEL > 0 -#define BEACON_DBG(format, ...) do{ printf(format, ## __VA_ARGS__);}while(0) -#else -#define BEACON_DBG(format, ...) -#endif - LoRaMacClassB::LoRaMacClassB() : _lora_phy(NULL), _lora_time(NULL), @@ -232,13 +223,7 @@ bool LoRaMacClassB::schedule_beacon_window(void) _lora_time->start(_beacon_timer, delay); } - BEACON_DBG("\nSchedule Beacon\n"); - BEACON_DBG("\tNext Beacon : %llu\n", next_beacon_time); - BEACON_DBG("\tDevice Time : %llu\n", current_time); - BEACON_DBG("\tBeacon Delay : %ld\n", delay); - BEACON_DBG("\tWindow Offset : %ld\n", window_offset); - BEACON_DBG("\tSymbol Timeout : %ld\n", _beacon.rx_config.window_timeout); - BEACON_DBG("\tFrequency : %lu\n", _beacon.rx_config.frequency); + tr_debug("Next beacon time = %llu in %ld ms", next_beacon_time/1000, delay); } return true; @@ -419,15 +404,6 @@ uint32_t LoRaMacClassB::process_beacon_frame(const uint8_t *const frame, uint16_ } } -#if MBED_CONF_LORA_CLASS_B_EXTRA_DEBUG_TRACE_LEVEL > 0 - if (beacon_time == 0) { - BEACON_DBG("Bad beacon frame: "); - for (uint16_t i = 0; i < size; i++) { - BEACON_DBG("%02x", frame[i]); - } - BEACON_DBG("\n"); - } -#endif return beacon_time; } @@ -455,6 +431,8 @@ void LoRaMacClassB::expand_window(void) if (_beacon.expansion.movement > MBED_CONF_LORA_CLASS_B_EXPANSION_OFFSET_MAX) { _beacon.expansion.movement = MBED_CONF_LORA_CLASS_B_EXPANSION_OFFSET_MAX; } + tr_debug("Expand beacon window timeout=%u, movement=%u", + _beacon.expansion.timeout, _beacon.expansion.movement); // ping slot symbol timeout _ping.expansion.timeout *= MBED_CONF_LORA_CLASS_B_EXPANSION_TIMEOUT_FACTOR; @@ -467,6 +445,8 @@ void LoRaMacClassB::expand_window(void) if (_ping.expansion.movement > MBED_CONF_LORA_CLASS_B_EXPANSION_OFFSET_MAX) { _ping.expansion.movement = MBED_CONF_LORA_CLASS_B_EXPANSION_OFFSET_MAX; } + tr_debug("Expand ping slot timeout=%u, movement=%u", + _ping.expansion.timeout, _ping.expansion.movement); } bool LoRaMacClassB::compute_ping_offset(uint32_t beacon_time, uint32_t address, uint16_t ping_period, uint16_t &ping_offset) @@ -521,7 +501,14 @@ lorawan_gps_time_t LoRaMacClassB::compute_ping_slot(uint32_t beacon_time, lorawa // For window timeout select the larger of the phy computed and class-b window expanded rx_config.window_timeout = MAX(_ping.expansion.timeout, rx_config.window_timeout); - slot_time = slot_time + rx_config.window_offset; + // PHY layer computes window offset adjusting for minimum preamble, + // timing errors, receiver wakeup time + int32_t window_offset = 0;// rx_config.window_offset; + + // Expand PHY offset by class b window expansion + window_offset -= _ping.expansion.movement; + + slot_time += window_offset; next_slot_nb = slot_nb; return slot_time; } diff --git a/features/lorawan/mbed_lib.json b/features/lorawan/mbed_lib.json index 6a74980268..b55c984760 100644 --- a/features/lorawan/mbed_lib.json +++ b/features/lorawan/mbed_lib.json @@ -166,7 +166,7 @@ "value": 1023 }, "class-b-expansion-ping-timeout-max":{ - "help": "Class B ping slot exapsnion maximum symbol timeout, Default: 30", + "help": "Class B ping slot expansion maximum symbol timeout, Default: 30", "value": 30 }, "class-b-expansion-offset-default":{ @@ -181,10 +181,6 @@ "help": "Class B reception slot offset expansion factor, Default: 2", "value": 2 }, - "class-b-extra-debug-trace-level":{ - "help": "Set extra Class B debug tracing level. Disabled=0, Beacon=1, Beacon&Ping=2. Default: 0", - "value": 0 - }, "class-b-multicast-address-max-count":{ "help": "Maximum number of Class B ping slot enabled multicast addresses. Default:1", "value": 1