bugix read tx power

This commit is contained in:
Harald Pichler 2017-09-10 22:13:07 +02:00
parent 4127d0993b
commit df2b297d91
5 changed files with 62 additions and 7 deletions

View file

@ -45,6 +45,11 @@ txpower <power>: change transmission power 0 (3dbm, default) to 15 (-17.2dbm)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
quit picocom, you need to press Ctrl-a , then Ctrl-q quit picocom, you need to press Ctrl-a , then Ctrl-q
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Read eeprom to disk:
avrdude -p m256rfr2 -c stk500v2 -P /dev/ttyUSB0 -b 57600 -U eeprom:r:eeprom_img.hex:i
Write eeprom to Merkurboard:
avrdude -p m256rfr2 -c stk500v2 -P /dev/ttyUSB0 -b 57600 -U eeprom:w:eeprom_img.hex:i
todo: todo:
bugfix: txpower <power>: change transmission power 0 (3dbm, default) to 15 (-17.2dbm) bugfix: txpower <power>: change transmission power 0 (3dbm, default) to 15 (-17.2dbm)

View file

@ -46,6 +46,7 @@ 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)
@ -115,9 +116,12 @@ 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");
@ -142,7 +146,9 @@ 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

@ -37,7 +37,9 @@
#define PLATFORM_HAS_BATTERY 1 #define PLATFORM_HAS_BATTERY 1
#define LOOP_INTERVAL (30 * CLOCK_SECOND) #define LOOP_INTERVAL (20 * CLOCK_SECOND)
//#define SETTINGS_MAX_SIZE 255
/* Save energy */ /* Save energy */
//#define RDC_CONF_PT_YIELD_OFF //#define RDC_CONF_PT_YIELD_OFF

View file

@ -87,8 +87,8 @@ PROCESS_THREAD(shell_txpower_process, ev, data)
out the current txpower. */ out the current txpower. */
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);
} }

View file

@ -17,6 +17,8 @@ extern "C" {
#include "serial-shell.h" #include "serial-shell.h"
#include "shell-merkur.h" #include "shell-merkur.h"
#include "lib/settings.h"
extern resource_t res_led, res_battery, res_cputemp; extern resource_t res_led, res_battery, res_cputemp;
uint8_t led_pin=4; uint8_t led_pin=4;
@ -25,6 +27,8 @@ uint8_t led_status;
void setup (void) void setup (void)
{ {
settings_status_t status;
// switch off the led // switch off the led
pinMode(led_pin, OUTPUT); pinMode(led_pin, OUTPUT);
digitalWrite(led_pin, HIGH); digitalWrite(led_pin, HIGH);
@ -46,6 +50,44 @@ void setup (void)
void loop (void) void loop (void)
{ {
int i;
settings_iter_t iter;
char hostname[30];
uint16_t panid;
uint16_t channel;
/*************************************************************************/
/* Iterating thru all settings */
for(iter = settings_iter_begin(); iter; iter = settings_iter_next(iter)) {
settings_length_t len = settings_iter_get_value_length(iter);
eeprom_addr_t addr = settings_iter_get_value_addr(iter);
uint8_t byte;
union {
settings_key_t key;
char bytes[0];
} u;
u.key = settings_iter_get_key(iter);
if(u.bytes[0] >= 32 && u.bytes[0] < 127
&& u.bytes[1] >= 32 && u.bytes[1] < 127
) {
printf("settings-example: [%c%c] = <",u.bytes[0],u.bytes[1]);
} else {
printf("settings-example: <0x%04X> = <",u.key);
}
for(; len; len--, addr++) {
eeprom_read(addr, &byte, 1);
printf("%02X", byte);
if(len != 1) {
printf(" ");
}
}
printf(">\n");
}
printf("settings-example: Done.\n");
} }