From 14ae2e7d28d2d3f39a7067f7111257f119eef3e1 Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 11 Mar 2024 21:00:36 +0100 Subject: Make modem config global --- src/main.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main.c b/src/main.c index 48d6371..7a35245 100644 --- a/src/main.c +++ b/src/main.c @@ -14,6 +14,18 @@ const struct device *const lora_dev = DEVICE_DT_GET(DEFAULT_RADIO_NODE); #include 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; -- cgit v1.2.3-70-g09d2