diff options
author | xengineering <me@xengineering.eu> | 2024-03-11 21:00:36 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-03-11 21:06:56 +0100 |
commit | 14ae2e7d28d2d3f39a7067f7111257f119eef3e1 (patch) | |
tree | d25a8b4bb12e403a0192ddccbbb12079d6019738 | |
parent | 980bc6ab78c77af0f6353c339959ab3bbfd5a52d (diff) | |
download | radio-gateway-14ae2e7d28d2d3f39a7067f7111257f119eef3e1.tar radio-gateway-14ae2e7d28d2d3f39a7067f7111257f119eef3e1.tar.zst radio-gateway-14ae2e7d28d2d3f39a7067f7111257f119eef3e1.zip |
Make modem config global
-rw-r--r-- | src/main.c | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -14,6 +14,18 @@ const struct device *const lora_dev = DEVICE_DT_GET(DEFAULT_RADIO_NODE); #include <zephyr/logging/log.h> LOG_MODULE_REGISTER(lora); +static struct lora_modem_config modem_config = { + .frequency = 433175000, + .bandwidth = BW_125_KHZ, + .datarate = SF_10, + .preamble_len = 8, + .coding_rate = CR_4_5, + .iq_inverted = false, + .public_network = false, + .tx_power = 4, + .tx = true +}; + void lora_tx_cb(const struct shell *sh, size_t argc, char *argv[]) { if (argc != 2) { @@ -42,25 +54,12 @@ void lora_rx_cb(const struct device *dev, uint8_t *data, uint16_t size, int main(void) { - struct lora_modem_config config; - int ret; - if (!device_is_ready(lora_dev)) { LOG_ERR("%s Device not ready", lora_dev->name); return 0; } - config.frequency = 433175000; - config.bandwidth = BW_125_KHZ; - config.datarate = SF_10; - config.preamble_len = 8; - config.coding_rate = CR_4_5; - config.iq_inverted = false; - config.public_network = false; - config.tx_power = 4; - config.tx = true; - - ret = lora_config(lora_dev, &config); + int ret = lora_config(lora_dev, &modem_config); if (ret < 0) { LOG_ERR("LoRa config failed"); return 0; |