add shell-merkur
This commit is contained in:
parent
8c5b66d715
commit
2ef7438131
|
@ -12,7 +12,7 @@ CONTIKI_WITH_IPV6 = 1
|
|||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
CFLAGS += -DCONTIKI_CONF_SETTINGS_MANAGER=1
|
||||
|
||||
PROJECT_SOURCEFILES += ${SKETCH}.cpp extended-rf-api.c
|
||||
PROJECT_SOURCEFILES += ${SKETCH}.cpp shell-merkur.c extended-rf-api.c
|
||||
|
||||
# automatically build RESTful resources
|
||||
REST_RESOURCES_DIR = ./resources
|
||||
|
|
|
@ -35,14 +35,6 @@
|
|||
#ifndef EXTENDED_RF_API_H_
|
||||
#define EXTENDED_RF_API_H_
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/netstack.h"
|
||||
#include "dev/radio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
void print_64bit_addr(const uint8_t *addr);
|
||||
radio_result_t get_object(radio_param_t param, void *dest, size_t size);
|
||||
radio_result_t set_object(radio_param_t param, void *src, size_t size);
|
||||
|
|
|
@ -48,7 +48,8 @@
|
|||
#include "net/rime/timesynch.h"
|
||||
#include "dev/radio.h"
|
||||
#include "sys/node-id.h"
|
||||
|
||||
#include "lib/settings.h"
|
||||
#include "extended-rf-api.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -56,69 +57,66 @@
|
|||
PROCESS(shell_txpower_process, "txpower");
|
||||
SHELL_COMMAND(txpower_command,
|
||||
"txpower",
|
||||
"txpower <power>: change CC2420 transmission power (0 - 31)",
|
||||
"txpower <power>: change transmission power 0 (3dbm, default) to 15 (-17.2dbm)",
|
||||
&shell_txpower_process);
|
||||
PROCESS(shell_rfchannel_process, "rfchannel");
|
||||
SHELL_COMMAND(rfchannel_command,
|
||||
"rfchannel",
|
||||
"rfchannel <channel>: change CC2420 radio channel (11 - 26)",
|
||||
"rfchannel <channel>: change radio channel (11 - 26)",
|
||||
&shell_rfchannel_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(shell_txpower_process, ev, data)
|
||||
{
|
||||
struct {
|
||||
uint16_t len;
|
||||
uint16_t txpower;
|
||||
} msg;
|
||||
radio_value_t value;
|
||||
char buf[20];
|
||||
const char *newptr;
|
||||
PROCESS_BEGIN();
|
||||
|
||||
msg.txpower = shell_strtolong(data, &newptr);
|
||||
value = shell_strtolong(data, &newptr);
|
||||
|
||||
/* If no transmission power was given on the command line, we print
|
||||
out the current txpower. */
|
||||
|
||||
if(newptr == data) {
|
||||
msg.txpower = rf230_get_txpower();
|
||||
if(get_param(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) {
|
||||
|
||||
}
|
||||
} else {
|
||||
rf230_set_txpower(msg.txpower);
|
||||
set_param(RADIO_PARAM_TXPOWER, value);
|
||||
}
|
||||
|
||||
msg.len = 1;
|
||||
|
||||
shell_output(&txpower_command, &msg, sizeof(msg), "", 0);
|
||||
snprintf(buf, sizeof(buf), "%3d", value);
|
||||
shell_output_str(&txpower_command, "dBm: ", buf);
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(shell_rfchannel_process, ev, data)
|
||||
{
|
||||
struct {
|
||||
uint16_t len;
|
||||
uint16_t channel;
|
||||
} msg;
|
||||
radio_value_t value;
|
||||
char buf[20];
|
||||
const char *newptr;
|
||||
PROCESS_BEGIN();
|
||||
|
||||
msg.channel = shell_strtolong(data, &newptr);
|
||||
value = shell_strtolong(data, &newptr);
|
||||
|
||||
/* If no channel was given on the command line, we print out the
|
||||
current channel. */
|
||||
if(newptr == data) {
|
||||
msg.channel = rf230_get_channel();
|
||||
if(get_param(RADIO_PARAM_CHANNEL, &value) == RADIO_RESULT_OK) {
|
||||
|
||||
}
|
||||
} else {
|
||||
rf230__set_channel(msg.channel);
|
||||
set_param(RADIO_PARAM_CHANNEL, value);
|
||||
}
|
||||
|
||||
msg.len = 1;
|
||||
|
||||
shell_output(&rfchannel_command, &msg, sizeof(msg), "", 0);
|
||||
snprintf(buf, sizeof(buf), "%d", value);
|
||||
shell_output_str(&rfchannel_command, "Channel: ", buf);
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
shell_sky_init(void)
|
||||
shell_merkur_init(void)
|
||||
{
|
||||
shell_register_command(&txpower_command);
|
||||
shell_register_command(&rfchannel_command);
|
||||
|
|
|
@ -215,13 +215,14 @@ void setup (void)
|
|||
shell_reboot_init();
|
||||
// shell_text_init();
|
||||
// shell_time_init();
|
||||
// shell_merkur_init();
|
||||
shell_merkur_init();
|
||||
|
||||
#if COFFEE
|
||||
shell_coffee_init();
|
||||
shell_file_init();
|
||||
#endif
|
||||
|
||||
get_rf_consts();
|
||||
print_rf_values();
|
||||
// init coap resourcen
|
||||
rest_init_engine ();
|
||||
|
|
Loading…
Reference in a new issue