mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 14:33:52 +01:00
drivers/sx127x: add functions required for loramac
This commit is contained in:
parent
ef3c6022f2
commit
b543d0b5da
@ -281,6 +281,26 @@ uint32_t sx127x_random(sx127x_t *dev);
|
||||
*/
|
||||
void sx127x_start_cad(sx127x_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Checks that channel is free with specified RSSI threshold.
|
||||
*
|
||||
* @param[in] dev The sx127x device structure pointer
|
||||
* @param[in] freq channel RF frequency
|
||||
* @param[in] rssi_threshold RSSI threshold
|
||||
*
|
||||
* @return true if channel is free, false otherwise
|
||||
*/
|
||||
bool sx127x_is_channel_free(sx127x_t *dev, uint32_t freq, int16_t rssi_threshold);
|
||||
|
||||
/**
|
||||
* @brief Reads the current RSSI value.
|
||||
*
|
||||
* @param[in] dev The sx127x device structure pointer
|
||||
*
|
||||
* @return the current value of RSSI (in dBm)
|
||||
*/
|
||||
int16_t sx127x_read_rssi(const sx127x_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Gets current state of transceiver.
|
||||
*
|
||||
|
||||
@ -109,7 +109,7 @@ uint8_t sx127x_get_syncword(const sx127x_t *dev)
|
||||
|
||||
void sx127x_set_syncword(sx127x_t *dev, uint8_t syncword)
|
||||
{
|
||||
DEBUG("[DEBUG] Set syncword: %d\n", syncword);
|
||||
DEBUG("[DEBUG] Set syncword: %02x\n", syncword);
|
||||
|
||||
sx127x_reg_write(dev, SX127X_REG_LR_SYNCWORD, syncword);
|
||||
}
|
||||
|
||||
@ -224,3 +224,18 @@ void sx127x_start_cad(sx127x_t *dev)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool sx127x_is_channel_free(sx127x_t *dev, uint32_t freq, int16_t rssi_threshold)
|
||||
{
|
||||
int16_t rssi = 0;
|
||||
|
||||
sx127x_set_channel(dev, freq);
|
||||
sx127x_set_op_mode(dev, SX127X_RF_OPMODE_RECEIVER);
|
||||
|
||||
xtimer_usleep(1000); /* wait 1 millisecond */
|
||||
|
||||
rssi = sx127x_read_rssi(dev);
|
||||
sx127x_set_sleep(dev);
|
||||
|
||||
return (rssi <= rssi_threshold);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user