Radio#
- group bsp_radio
Control the radio peripheral.
This radio driver supports BLE 1MBit, 2MBit, Long Range 125KBit and Long Range 500KBit.
- Author
Said Alvarado-Marin said-alexander.alvarado-marin@inria.fr
- Author
Alexandre Abadie alexandre.abadie@inria.fr
- Copyright
Inria, 2022-2023
Defines
-
DEFAULT_NETWORK_ADDRESS#
Default network address.
Typedefs
-
typedef void (*radio_cb_t)(uint8_t *packet, uint8_t length)#
Function pointer to the callback function called on packet receive.
Enums
Functions
-
void db_radio_init(radio_cb_t callback, db_radio_ble_mode_t mode)#
Initializes the RADIO peripheral.
After this function you must explicitly set the frequency of the radio with the db_radio_set_frequency function.
- Parameters:
callback – [in] pointer to a function that will be called each time a packet is received.
mode – [in] BLE mode used by the radio (1MBit, 2MBit, LR125KBit, LR500Kbit)
-
void db_radio_set_frequency(uint8_t freq)#
Set the tx-rx frequency of the radio, by the following formula.
Radio frequency 2400 + freq (MHz) [0, 100]
- Parameters:
freq – [in] Frequency of the radio [0, 100]
-
void db_radio_set_channel(uint8_t channel)#
Set the physical channel used of the radio.
Channels 37, 38 and 39 are BLE advertising channels.
- Parameters:
channel – [in] BLE channel used by the radio [0-39]
-
void db_radio_set_network_address(uint32_t addr)#
Set the network address used to send/receive radio packets.
- Parameters:
addr – [in] Network address
-
void db_radio_tx(const uint8_t *packet, uint8_t length)#
Sends a single packet through the Radio.
NOTE: Must configure the radio and the frequency before calling this function. (with the functions db_radio_init db_radio_set_frequency).
NOTE: The radio must not be receiving packets when calling this function. (first call db_radio_disable if needed)
- Parameters:
packet – [in] pointer to the array of data to send over the radio (max size = 32)
length – [in] Number of bytes to send (max size = 32)
-
void db_radio_rx(void)#
Starts Receiving packets through the Radio.
NOTE: Must configure the radio and the frequency before calling this function. (with the functions db_radio_init db_radio_set_frequency).
-
int8_t db_radio_rssi(void)#
Reads the RSSI of a received packet.
Should be called after a packet is received, e.g. in the radio callback
-
void db_radio_disable(void)#
Disables the radio, no packet can be received and energy consumption is minimal.