bugfix set tx power from shell

This commit is contained in:
Harald Pichler 2017-09-12 11:12:53 +02:00
parent df2b297d91
commit fedd9cb0d7
4 changed files with 18 additions and 20 deletions

View file

@ -1877,18 +1877,22 @@ rf230_read(void *buf, unsigned short bufsize)
return len - AUX_LEN; return len - AUX_LEN;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static uint8_t powertmp;
void void
rf230_set_txpower(uint8_t power) rf230_set_txpower(uint8_t power)
{ {
set_txpower(power); set_txpower(power);
powertmp = power;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
uint8_t uint8_t
rf230_get_txpower(void) rf230_get_txpower(void)
{ {
uint8_t power = TX_PWR_UNDEFINED; // uint8_t power = TX_PWR_UNDEFINED;
uint8_t power = powertmp;
if (hal_get_slptr()) { if (hal_get_slptr()) {
PRINTF("rf230_get_txpower:Sleeping"); PRINTF("rf230_get_txpower:Sleeping");
// power = powertmp;
} else { } else {
power = hal_subregister_read(SR_TX_PWR); power = hal_subregister_read(SR_TX_PWR);
} }

View file

@ -46,7 +46,6 @@ struct rf_consts {
}; };
static struct rf_consts consts; static struct rf_consts consts;
static radio_value_t tmpv;
void void
print_64bit_addr(const uint8_t *addr) print_64bit_addr(const uint8_t *addr)
@ -116,12 +115,9 @@ radio_result_t
get_param(radio_param_t param, radio_value_t *value) get_param(radio_param_t param, radio_value_t *value)
{ {
radio_result_t rv; radio_result_t rv;
if(param == RADIO_PARAM_TXPOWER){
value = tmpv;
rv = RADIO_RESULT_OK;
} else {
rv = NETSTACK_RADIO.get_value(param, value); rv = NETSTACK_RADIO.get_value(param, value);
}
switch(rv) { switch(rv) {
case RADIO_RESULT_ERROR: case RADIO_RESULT_ERROR:
printf("Radio returned an error\n"); printf("Radio returned an error\n");
@ -146,9 +142,7 @@ radio_result_t
set_param(radio_param_t param, radio_value_t value) set_param(radio_param_t param, radio_value_t value)
{ {
radio_result_t rv; radio_result_t rv;
if(param == RADIO_PARAM_TXPOWER){
tmpv = value;
}
rv = NETSTACK_RADIO.set_value(param, value); rv = NETSTACK_RADIO.set_value(param, value);
switch(rv) { switch(rv) {

View file

@ -88,12 +88,11 @@ PROCESS_THREAD(shell_txpower_process, ev, data)
if(newptr == data) { if(newptr == data) {
if(get_param(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) { if(get_param(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) {
} }
// value = params_get_txpower();
} else { } else {
set_param(RADIO_PARAM_TXPOWER, value); set_param(RADIO_PARAM_TXPOWER, value);
} }
snprintf(buf, sizeof(buf), "%3d dBm", value); snprintf(buf, sizeof(buf), "%3d", value);
shell_output_str(&txpower_command, "TX Power: ", buf); shell_output_str(&txpower_command, "TX Power: ", buf);
PROCESS_END(); PROCESS_END();

View file

@ -31,7 +31,7 @@
*/ */
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) #define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#define DEBUG 1 #define DEBUG 0
#if DEBUG #if DEBUG
#define PRINTD(FORMAT,args...) printf_P(PSTR(FORMAT),##args) #define PRINTD(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#else #else
@ -266,6 +266,7 @@ uint8_t
params_get_txpower(void) { params_get_txpower(void) {
uint8_t x; uint8_t x;
size_t size = 1; size_t size = 1;
PRINTD("params_get_txpower\n",x);
if (settings_get(SETTINGS_KEY_TXPOWER, 0,(unsigned char*)&x, &size) == SETTINGS_STATUS_OK) { if (settings_get(SETTINGS_KEY_TXPOWER, 0,(unsigned char*)&x, &size) == SETTINGS_STATUS_OK) {
PRINTD("<-Get tx power of %d (0=max)\n",x); PRINTD("<-Get tx power of %d (0=max)\n",x);
} else { } else {
@ -298,9 +299,9 @@ params_save_panid(void) {
settings_status_t rx=SETTINGS_STATUS_OK; settings_status_t rx=SETTINGS_STATUS_OK;
if(NETSTACK_RADIO.get_value(RADIO_PARAM_PAN_ID, &value) == RADIO_RESULT_OK) { if(NETSTACK_RADIO.get_value(RADIO_PARAM_PAN_ID, &value) == RADIO_RESULT_OK) {
printf("%d\n", value); PRINTD("%04x\n", value);
if(settings_set_uint16(SETTINGS_KEY_PAN_ID, value) != SETTINGS_STATUS_OK) { if(settings_set_uint16(SETTINGS_KEY_PAN_ID, value) != SETTINGS_STATUS_OK) {
printf("settings-panid: `save` failed: \n"); PRINTD("settings-panid: `save` failed: \n");
rx = SETTINGS_STATUS_FAILURE; rx = SETTINGS_STATUS_FAILURE;
} }
} else { } else {
@ -315,9 +316,9 @@ params_save_channel(void) {
settings_status_t rx=SETTINGS_STATUS_OK; settings_status_t rx=SETTINGS_STATUS_OK;
if(NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, &value) == RADIO_RESULT_OK) { if(NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, &value) == RADIO_RESULT_OK) {
printf("%d\n", value); PRINTD("%d\n", value);
if(settings_set_uint8(SETTINGS_KEY_CHANNEL, value) != SETTINGS_STATUS_OK) { if(settings_set_uint8(SETTINGS_KEY_CHANNEL, value) != SETTINGS_STATUS_OK) {
printf("settings-channel: `save` failed: \n"); PRINTD("settings-channel: `save` failed: \n");
rx = SETTINGS_STATUS_FAILURE; rx = SETTINGS_STATUS_FAILURE;
} }
} else { } else {
@ -332,9 +333,9 @@ params_save_txpower(void) {
settings_status_t rx=SETTINGS_STATUS_OK; settings_status_t rx=SETTINGS_STATUS_OK;
if(NETSTACK_RADIO.get_value(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) { if(NETSTACK_RADIO.get_value(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) {
printf("%d\n", value); PRINTD("%d\n", value);
if(settings_set_uint8(SETTINGS_KEY_TXPOWER, value) != SETTINGS_STATUS_OK) { if(settings_set_uint8(SETTINGS_KEY_TXPOWER, value) != SETTINGS_STATUS_OK) {
printf("settings-txpower: `save` failed: \n"); PRINTD("settings-txpower: `save` failed: \n");
rx = SETTINGS_STATUS_FAILURE; rx = SETTINGS_STATUS_FAILURE;
} }
} else { } else {