Exemplo n.º 1
0
bool LoRaPHYUS915::tx_config(tx_config_params_t* config, int8_t* tx_power,
                             lorawan_time_t* tx_toa)
{
    int8_t phy_dr = datarates_US915[config->datarate];
    int8_t tx_power_limited = limit_tx_power(config->tx_power,
                                             bands[channels[config->channel].band].max_tx_pwr,
                                             config->datarate);

    uint32_t bandwidth = get_bandwidth(config->datarate);
    int8_t phy_tx_power = 0;

    // Calculate physical TX power
    phy_tx_power = compute_tx_power( tx_power_limited, US915_DEFAULT_MAX_ERP, 0 );

    _radio->lock();

    _radio->set_channel(channels[config->channel].frequency);

    _radio->set_tx_config(MODEM_LORA, phy_tx_power, 0, bandwidth, phy_dr, 1, 8,
                          false, true, 0, 0, false, 3000);

    // Setup maximum payload lenght of the radio driver
    _radio->set_max_payload_length(MODEM_LORA, config->pkt_len);

    // Get the time-on-air of the next tx frame
    *tx_toa = _radio->time_on_air(MODEM_LORA, config->pkt_len);

    _radio->unlock();

    *tx_power = tx_power_limited;

    return true;
}
Exemplo n.º 2
0
void LoRaPHYUS915Hybrid::set_tx_cont_mode(cw_mode_params_t* params, uint32_t given_frequency)
{
    (void)given_frequency;

    int8_t tx_power_limited = limit_tx_power(params->tx_power,
                                           bands[channels[params->channel].band].max_tx_pwr,
                                           params->datarate);

    int8_t phy_tx_power = 0;
    uint32_t frequency = channels[params->channel].frequency;

    // Calculate physical TX power
    phy_tx_power = compute_tx_power(tx_power_limited, US915_HYBRID_DEFAULT_MAX_ERP, 0);

    _radio->lock();
    _radio->set_tx_continuous_wave(frequency, phy_tx_power, params->timeout);
    _radio->unlock();
}
Exemplo n.º 3
0
bool LoRaPHYKR920::tx_config(tx_config_params_t* config, int8_t* tx_power,
                             lorawan_time_t* tx_toa)
{
    int8_t phy_dr = datarates_KR920[config->datarate];

    if (config->tx_power > bands[channels[config->channel].band].max_tx_pwr) {
        config->tx_power = bands[channels[config->channel].band].max_tx_pwr;
    }

    uint32_t bandwidth = get_bandwidth(config->datarate);
    float max_eirp = get_max_eirp(channels[config->channel].frequency);
    int8_t phy_tx_power = 0;

    // Take the minimum between the max_eirp and txConfig->MaxEirp.
    // The value of txConfig->MaxEirp could have changed during runtime, e.g. due to a MAC command.
    max_eirp = MIN(config->max_eirp, max_eirp);

    // Calculate physical TX power
    phy_tx_power = compute_tx_power(config->tx_power, max_eirp, config->antenna_gain);

    // Setup the radio frequency
    _radio->lock();

    _radio->set_channel(channels[config->channel].frequency);

    _radio->set_tx_config(MODEM_LORA, phy_tx_power, 0, bandwidth, phy_dr, 1, 8,
                          false, true, 0, 0, false, 3000 );

    // Setup maximum payload lenght of the radio driver
    _radio->set_max_payload_length(MODEM_LORA, config->pkt_len);
    // Get the time-on-air of the next tx frame
    *tx_toa =_radio->time_on_air(MODEM_LORA, config->pkt_len);

    _radio->unlock();

    *tx_power = config->tx_power;
    return true;
}
Exemplo n.º 4
0
bool LoRaPHYCN470::tx_config(tx_config_params_t* config, int8_t* tx_power,
                             lorawan_time_t* tx_toa)
{
    int8_t phy_dr = datarates_CN470[config->datarate];

    if (config->tx_power > bands[channels[config->channel].band].max_tx_pwr) {
        config->tx_power = bands[channels[config->channel].band].max_tx_pwr;
    }

    int8_t phy_tx_power = 0;

    // Calculate physical TX power
    phy_tx_power = compute_tx_power(config->tx_power, config->max_eirp,
                                    config->antenna_gain);

    // acquire lock to radio
    _radio->lock();

    _radio->set_channel(channels[config->channel].frequency);

   _radio->set_tx_config(MODEM_LORA, phy_tx_power, 0, 0, phy_dr, 1,
                         MBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH, false, true,
                         0, 0, false, 3000);
    // Setup maximum payload lenght of the radio driver
    _radio->set_max_payload_length(MODEM_LORA, config->pkt_len);

    // Get the time-on-air of the next tx frame
    *tx_toa = _radio->time_on_air(MODEM_LORA, config->pkt_len);

    // release lock to radio
    _radio->unlock();

    *tx_power = config->tx_power;

    return true;
}
Exemplo n.º 5
0
void LoRaPHYKR920::set_tx_cont_mode(cw_mode_params_t* params, uint32_t given_frequency)
{
    (void)given_frequency;

    if (params->tx_power > bands[channels[params->channel].band].max_tx_pwr) {
        params->tx_power = bands[channels[params->channel].band].max_tx_pwr;
    }

    float max_eirp = get_max_eirp(channels[params->channel].frequency);
    int8_t phy_tx_power = 0;
    uint32_t frequency = channels[params->channel].frequency;

    // Take the minimum between the max_eirp and params->max_eirp.
    // The value of params->max_eirp could have changed during runtime,
    // e.g. due to a MAC command.
    max_eirp = MIN (params->max_eirp, max_eirp);

    // Calculate physical TX power
    phy_tx_power = compute_tx_power(params->tx_power, max_eirp, params->antenna_gain);

    _radio->lock();
    _radio->set_tx_continuous_wave(frequency, phy_tx_power, params->timeout);
    _radio->unlock();
}