Merge pull request #10868 from jia200x/pr/pkg_loramac_calibration

pkg/semtech-loramac: add timer calibration
This commit is contained in:
Alexandre Abadie 2019-01-25 15:55:03 +01:00 committed by GitHub
commit cee830bd97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 79 additions and 30 deletions

View File

@ -433,10 +433,14 @@ void _init_loramac(semtech_loramac_t *mac,
semtech_loramac_set_class(mac, LORAMAC_DEFAULT_DEVICE_CLASS); semtech_loramac_set_class(mac, LORAMAC_DEFAULT_DEVICE_CLASS);
semtech_loramac_set_tx_port(mac, LORAMAC_DEFAULT_TX_PORT); semtech_loramac_set_tx_port(mac, LORAMAC_DEFAULT_TX_PORT);
semtech_loramac_set_tx_mode(mac, LORAMAC_DEFAULT_TX_MODE); semtech_loramac_set_tx_mode(mac, LORAMAC_DEFAULT_TX_MODE);
semtech_loramac_set_system_max_rx_error(mac,
LORAMAC_DEFAULT_SYSTEM_MAX_RX_ERROR);
semtech_loramac_set_min_rx_symbols(mac, LORAMAC_DEFAULT_MIN_RX_SYMBOLS);
mac->link_chk.available = false; mac->link_chk.available = false;
#ifdef MODULE_PERIPH_EEPROM #ifdef MODULE_PERIPH_EEPROM
_read_loramac_config(mac); _read_loramac_config(mac);
#endif #endif
} }
static void _join_otaa(semtech_loramac_t *mac) static void _join_otaa(semtech_loramac_t *mac)

View File

@ -253,6 +253,26 @@ uint8_t semtech_loramac_get_tx_mode(semtech_loramac_t *mac)
return mac->cnf; return mac->cnf;
} }
void semtech_loramac_set_system_max_rx_error(semtech_loramac_t *mac, int error)
{
MibRequestConfirm_t mibReq;
mutex_lock(&mac->lock);
mibReq.Type = MIB_SYSTEM_MAX_RX_ERROR;
mibReq.Param.SystemMaxRxError = error;
LoRaMacMibSetRequestConfirm(&mibReq);
mutex_unlock(&mac->lock);
}
void semtech_loramac_set_min_rx_symbols(semtech_loramac_t *mac, int min_rx)
{
MibRequestConfirm_t mibReq;
mutex_lock(&mac->lock);
mibReq.Type = MIB_MIN_RX_SYMBOLS;
mibReq.Param.MinRxSymbols = min_rx;
LoRaMacMibSetRequestConfirm(&mibReq);
mutex_unlock(&mac->lock);
}
static void _semtech_loramac_set_rx2_params(semtech_loramac_channel_params_t params) static void _semtech_loramac_set_rx2_params(semtech_loramac_channel_params_t params)
{ {
Rx2ChannelParams_t p; Rx2ChannelParams_t p;

View File

@ -96,7 +96,7 @@ void SX127XSetRxConfig(RadioModems_t modem, uint32_t bandwidth,
sx127x_set_freq_hop(&sx127x, freqHopOn); sx127x_set_freq_hop(&sx127x, freqHopOn);
sx127x_set_hop_period(&sx127x, hopPeriod); sx127x_set_hop_period(&sx127x, hopPeriod);
sx127x_set_iq_invert(&sx127x, iqInverted); sx127x_set_iq_invert(&sx127x, iqInverted);
sx127x_set_symbol_timeout(&sx127x, 2 * symbTimeout); sx127x_set_symbol_timeout(&sx127x, symbTimeout);
sx127x_set_rx_single(&sx127x, !rxContinuous); sx127x_set_rx_single(&sx127x, !rxContinuous);
} }

View File

@ -60,12 +60,7 @@ void TimerSetValue(TimerEvent_t *obj, uint32_t value)
xtimer_remove(&(obj->dev)); xtimer_remove(&(obj->dev));
} }
/* According to the lorawan specifications, the data sent from the gateway obj->timeout = value * US_PER_MS;
could arrive with a short shift in time of +/- 20ms. Here the timeout is
triggered 50ms in advance to make sure the radio switches to RX mode on
time and doesn't miss any downlink messages, taking in consideration
possible xtimer inaccuracies. */
obj->timeout = (value - 50) * US_PER_MS;
} }
TimerTime_t TimerGetCurrentTime(void) TimerTime_t TimerGetCurrentTime(void)

View File

@ -388,6 +388,22 @@ uint8_t semtech_loramac_get_tx_power(semtech_loramac_t *mac);
*/ */
void semtech_loramac_set_tx_port(semtech_loramac_t *mac, uint8_t port); void semtech_loramac_set_tx_port(semtech_loramac_t *mac, uint8_t port);
/**
* @brief Sets the maximum system overall timing error for RX (in ms)
*
* @param[in] mac Pointer to the mac
* @param[in] error The maximum rx timing error
*/
void semtech_loramac_set_system_max_rx_error(semtech_loramac_t *mac, int error);
/**
* @brief Sets the minimum required number of symbols to detect a frame
*
* @param[in] mac Pointer to the mac
* @param[in] min_rx The minimum rx symbols
*/
void semtech_loramac_set_min_rx_symbols(semtech_loramac_t *mac, int min_rx);
/** /**
* @brief Gets the TX application port * @brief Gets the TX application port
* *

View File

@ -261,6 +261,20 @@ extern "C" {
#ifndef LORAMAC_DEFAULT_ADR_TIMEOUT #ifndef LORAMAC_DEFAULT_ADR_TIMEOUT
#define LORAMAC_DEFAULT_ADR_TIMEOUT (3U) #define LORAMAC_DEFAULT_ADR_TIMEOUT (3U)
#endif #endif
/**
* @brief Default maximum system overall timing error
*/
#ifndef LORAMAC_DEFAULT_SYSTEM_MAX_RX_ERROR
#define LORAMAC_DEFAULT_SYSTEM_MAX_RX_ERROR (50)
#endif
/**
* @brief Default minimum RX symbols to detect a frame
*/
#ifndef LORAMAC_DEFAULT_MIN_RX_SYMBOLS
#define LORAMAC_DEFAULT_MIN_RX_SYMBOLS (12)
#endif
/** @} */ /** @} */
/** /**