add shell macconfig
This commit is contained in:
parent
aaf1e8b2b1
commit
8b2ee08d55
|
@ -67,6 +67,11 @@ SHELL_COMMAND(ccathresholds_command,
|
|||
"ccathresholds",
|
||||
"ccathresholds <threshold: change cca thresholds -91 to -61 dBm (default -77)",
|
||||
&shell_ccathresholds_process);
|
||||
PROCESS(shell_macconf_process, "macconf");
|
||||
SHELL_COMMAND(macconf_command,
|
||||
"macconf",
|
||||
"macconf <conf>: change mac layer 0 -> do nothing; 1 -> Radio allways on",
|
||||
&shell_macconf_process);
|
||||
PROCESS(shell_saverfparam_process, "saverfparam");
|
||||
SHELL_COMMAND(saverfparam_command,
|
||||
"saverfparam",
|
||||
|
@ -148,6 +153,29 @@ PROCESS_THREAD(shell_ccathresholds_process, ev, data)
|
|||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(shell_macconf_process, ev, data)
|
||||
{
|
||||
radio_value_t value;
|
||||
char buf[20];
|
||||
const char *newptr;
|
||||
PROCESS_BEGIN();
|
||||
|
||||
value = shell_strtolong(data, &newptr);
|
||||
|
||||
/* If no transmission power was given on the command line, we print
|
||||
out the current macconf. */
|
||||
if(newptr == data) {
|
||||
value = params_get_macconf();
|
||||
} else {
|
||||
params_set_macconf(value);
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%3d", value);
|
||||
shell_output_str(&txpower_command, "macconf: ", buf);
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(shell_panid_process, ev, data)
|
||||
{
|
||||
radio_value_t value;
|
||||
|
@ -185,6 +213,8 @@ PROCESS_THREAD(shell_saverfparam_process, ev, data)
|
|||
|
||||
/* Save panid */
|
||||
params_save_panid();
|
||||
/* Save macconf */
|
||||
params_save_macconf();
|
||||
|
||||
shell_output_str(&rfchannel_command, "saverfparam done ", 0);
|
||||
|
||||
|
@ -200,6 +230,7 @@ shell_merkur_init(void)
|
|||
shell_register_command(&rfchannel_command);
|
||||
shell_register_command(&ccathresholds_command);
|
||||
shell_register_command(&panid_command);
|
||||
shell_register_command(&macconf_command);
|
||||
shell_register_command(&saverfparam_command);
|
||||
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ typedef uint16_t settings_length_t;
|
|||
|
||||
#define SETTINGS_KEY_RDC_INDEX TCC('R','D') /*!< RDC index, uint8_t */
|
||||
#define SETTINGS_KEY_CHANNEL_MASK TCC('C','M') /*!< Channel mask, uint16_t */
|
||||
|
||||
#define SETTINGS_KEY_MAC_CONF TCC('M','C') /*!< MAC Layer Config, uint8_t */
|
||||
/*****************************************************************************/
|
||||
// MARK: - Constants
|
||||
|
||||
|
|
|
@ -303,6 +303,11 @@ uint8_t i;
|
|||
NETSTACK_MAC.init();
|
||||
NETSTACK_NETWORK.init();
|
||||
|
||||
if(params_get_macconf() == 1){
|
||||
NETSTACK_MAC.off(1);
|
||||
PRINTA("Switch Reciver always on\n");
|
||||
}
|
||||
|
||||
#if ANNOUNCE_BOOT
|
||||
PRINTA("%s %s, channel %u , check rate %u Hz tx power %u\n",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(),
|
||||
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:NETSTACK_RDC.channel_check_interval()),
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||
|
||||
#define DEBUG 0
|
||||
#define DEBUG 1
|
||||
#if DEBUG
|
||||
#define PRINTD(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||
#else
|
||||
|
@ -292,6 +292,32 @@ params_get_ccathresholds(void) {
|
|||
return x;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
params_get_macconf(void) {
|
||||
uint8_t x;
|
||||
size_t size = 1;
|
||||
if (settings_get(SETTINGS_KEY_MAC_CONF, 0,(unsigned char*)&x, &size) == SETTINGS_STATUS_OK) {
|
||||
PRINTD("<-Get macconf of %d (0 -> do nothing)\n",x);
|
||||
} else {
|
||||
x=PARAMS_MACCONF;
|
||||
if (settings_add_uint8(SETTINGS_KEY_MAC_CONF,x)==SETTINGS_STATUS_OK) {
|
||||
PRINTD("->Set EEPROM macconf of %d (0 -> do nothing)\n",x);
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
settings_status_t
|
||||
params_set_macconf(radio_value_t value){
|
||||
settings_status_t rx=SETTINGS_STATUS_OK;
|
||||
PRINTD("%d\n", value);
|
||||
if(settings_set_uint8(SETTINGS_KEY_MAC_CONF, value) != SETTINGS_STATUS_OK) {
|
||||
PRINTD("settings-mac-conf: `save` failed: \n");
|
||||
rx = SETTINGS_STATUS_FAILURE;
|
||||
}
|
||||
return rx;
|
||||
}
|
||||
|
||||
settings_status_t
|
||||
params_save_panid(void) {
|
||||
radio_value_t value;
|
||||
|
@ -344,6 +370,20 @@ params_save_txpower(void) {
|
|||
return rx;
|
||||
}
|
||||
|
||||
settings_status_t
|
||||
params_save_macconf(void) {
|
||||
radio_value_t value;
|
||||
settings_status_t rx=SETTINGS_STATUS_OK;
|
||||
|
||||
value = params_get_macconf();
|
||||
PRINTD("%d\n", value);
|
||||
if(settings_set_uint8(SETTINGS_KEY_MAC_CONF, value) != SETTINGS_STATUS_OK) {
|
||||
PRINTD("settings-mac-conf: `save` failed: \n");
|
||||
rx = SETTINGS_STATUS_FAILURE;
|
||||
}
|
||||
return rx;
|
||||
}
|
||||
|
||||
radio_result_t
|
||||
get_param(radio_param_t param, radio_value_t *value)
|
||||
{
|
||||
|
|
|
@ -81,6 +81,9 @@ extern uint8_t eemem_domain_name[30];
|
|||
#else
|
||||
#define PARAMS_TXPOWER 0
|
||||
#endif
|
||||
#ifdef NETSTACK_CONF_RDC
|
||||
#define PARAMS_MACCONF 0
|
||||
#endif
|
||||
#ifdef EUI64_ADDRESS
|
||||
#define PARAMS_EUI64ADDR EUI64_ADDRESS
|
||||
#else
|
||||
|
@ -106,6 +109,7 @@ uint8_t params_get_eui64(uint8_t *eui64);
|
|||
#define params_get_panid(...) PARAMS_PANID
|
||||
#define params_get_panaddr(...) PARAMS_PANADDR
|
||||
#define params_get_txpower(...) PARAMS_TXPOWER
|
||||
#define params_get_macconf(...) PARAMS_MACCONF
|
||||
#else
|
||||
/* Parameters stored in eeprom */
|
||||
uint16_t params_get_nodeid(void);
|
||||
|
@ -113,11 +117,14 @@ uint8_t params_get_channel(void);
|
|||
uint16_t params_get_panid(void);
|
||||
uint16_t params_get_panaddr(void);
|
||||
uint8_t params_get_txpower(void);
|
||||
uint8_t params_get_macconf(void);
|
||||
settings_status_t params_set_macconf(radio_value_t value);
|
||||
settings_status_t params_save_nodeid(void);
|
||||
settings_status_t params_save_channel(void);
|
||||
settings_status_t params_save_panid(void);
|
||||
settings_status_t params_save_panaddr(void);
|
||||
settings_status_t params_save_txpower(void);
|
||||
settings_status_t params_save_macconf(void);
|
||||
radio_result_t get_param(radio_param_t param, radio_value_t *value);
|
||||
radio_result_t set_param(radio_param_t param, radio_value_t value);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue