Exemple #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;
}
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();
}