From a794edd9f299344a7dd0678475098d6c0ac92ea3 Mon Sep 17 00:00:00 2001 From: eduazocar Date: Thu, 13 Oct 2022 15:15:09 -0400 Subject: [PATCH] Added radio set_txpwer with acting netopt --- firmware/network/radio/radio.c | 10 +++++++++- tests/driver_radio/main.c | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/firmware/network/radio/radio.c b/firmware/network/radio/radio.c index 461172352..f6e8b42e6 100644 --- a/firmware/network/radio/radio.c +++ b/firmware/network/radio/radio.c @@ -122,6 +122,7 @@ int8_t get_netopt_channel(uint16_t *channel) { int8_t set_netopt_tx_power(int16_t txpower) { int res; int index = get_ieee802154_iface(); + uint16_t channel = 0; if (index < 0) { return -1; } @@ -131,8 +132,15 @@ int8_t set_netopt_tx_power(int16_t txpower) { TX_POWER_MAX); return -1; } - + if (get_netopt_channel(&channel) < 0){ + return -1; + } res = netif_set_opt(iface, NETOPT_TX_POWER, 0, &txpower, sizeof(txpower)); + if (res < 0) + { + return -1; + } + res = set_netopt_channel(channel); if (res >= 0) { DEBUG(" TX-Power: %" PRIi16 "dBm \n", txpower); } else { diff --git a/tests/driver_radio/main.c b/tests/driver_radio/main.c index e8c43786d..2c2f6a8cc 100644 --- a/tests/driver_radio/main.c +++ b/tests/driver_radio/main.c @@ -17,6 +17,7 @@ * @brief Radio file * * @author RocioRojas + * @author eduazocar */ #include #include @@ -65,8 +66,8 @@ Test *tests_radio_module(void) { EMB_UNIT_TESTFIXTURES(fixtures){ new_TestFixture(test_get_ieee802154_iface), new_TestFixture(test_set_netopt_tx_power), - new_TestFixture(test_set_netopt_channel), new_TestFixture(test_get_netopt_tx_power), + new_TestFixture(test_set_netopt_channel), new_TestFixture(test_get_netopt_channel), new_TestFixture(test_initial_radio_setup), };