Skip to content

Commit

Permalink
Added radio set_txpwer with acting netopt
Browse files Browse the repository at this point in the history
  • Loading branch information
eduazocar committed Oct 13, 2022
1 parent e0e2b5a commit a794edd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion firmware/network/radio/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion tests/driver_radio/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @brief Radio file
*
* @author RocioRojas <[email protected]>
* @author eduazocar <[email protected]>
*/
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -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),
};
Expand Down

0 comments on commit a794edd

Please sign in to comment.