add shell-merkur

This commit is contained in:
Harald Pichler 2017-09-05 22:24:56 +02:00
parent 8c5b66d715
commit 2ef7438131
4 changed files with 28 additions and 37 deletions

View file

@ -12,7 +12,7 @@ CONTIKI_WITH_IPV6 = 1
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
CFLAGS += -DCONTIKI_CONF_SETTINGS_MANAGER=1 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 # automatically build RESTful resources
REST_RESOURCES_DIR = ./resources REST_RESOURCES_DIR = ./resources

View file

@ -35,14 +35,6 @@
#ifndef EXTENDED_RF_API_H_ #ifndef EXTENDED_RF_API_H_
#define 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); 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 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); radio_result_t set_object(radio_param_t param, void *src, size_t size);

View file

@ -48,7 +48,8 @@
#include "net/rime/timesynch.h" #include "net/rime/timesynch.h"
#include "dev/radio.h" #include "dev/radio.h"
#include "sys/node-id.h" #include "sys/node-id.h"
#include "lib/settings.h"
#include "extended-rf-api.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -56,69 +57,66 @@
PROCESS(shell_txpower_process, "txpower"); PROCESS(shell_txpower_process, "txpower");
SHELL_COMMAND(txpower_command, SHELL_COMMAND(txpower_command,
"txpower", "txpower",
"txpower <power>: change CC2420 transmission power (0 - 31)", "txpower <power>: change transmission power 0 (3dbm, default) to 15 (-17.2dbm)",
&shell_txpower_process); &shell_txpower_process);
PROCESS(shell_rfchannel_process, "rfchannel"); PROCESS(shell_rfchannel_process, "rfchannel");
SHELL_COMMAND(rfchannel_command, SHELL_COMMAND(rfchannel_command,
"rfchannel", "rfchannel",
"rfchannel <channel>: change CC2420 radio channel (11 - 26)", "rfchannel <channel>: change radio channel (11 - 26)",
&shell_rfchannel_process); &shell_rfchannel_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_txpower_process, ev, data) PROCESS_THREAD(shell_txpower_process, ev, data)
{ {
struct { radio_value_t value;
uint16_t len; char buf[20];
uint16_t txpower;
} msg;
const char *newptr; const char *newptr;
PROCESS_BEGIN(); 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 /* If no transmission power was given on the command line, we print
out the current txpower. */ out the current txpower. */
if(newptr == data) {
if(newptr == data) { if(get_param(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) {
msg.txpower = rf230_get_txpower();
}
} else { } else {
rf230_set_txpower(msg.txpower); set_param(RADIO_PARAM_TXPOWER, value);
} }
msg.len = 1; snprintf(buf, sizeof(buf), "%3d", value);
shell_output_str(&txpower_command, "dBm: ", buf);
shell_output(&txpower_command, &msg, sizeof(msg), "", 0);
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_rfchannel_process, ev, data) PROCESS_THREAD(shell_rfchannel_process, ev, data)
{ {
struct { radio_value_t value;
uint16_t len; char buf[20];
uint16_t channel;
} msg;
const char *newptr; const char *newptr;
PROCESS_BEGIN(); 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 /* If no channel was given on the command line, we print out the
current channel. */ current channel. */
if(newptr == data) { if(newptr == data) {
msg.channel = rf230_get_channel(); if(get_param(RADIO_PARAM_CHANNEL, &value) == RADIO_RESULT_OK) {
}
} else { } else {
rf230__set_channel(msg.channel); set_param(RADIO_PARAM_CHANNEL, value);
} }
msg.len = 1; snprintf(buf, sizeof(buf), "%d", value);
shell_output_str(&rfchannel_command, "Channel: ", buf);
shell_output(&rfchannel_command, &msg, sizeof(msg), "", 0);
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
shell_sky_init(void) shell_merkur_init(void)
{ {
shell_register_command(&txpower_command); shell_register_command(&txpower_command);
shell_register_command(&rfchannel_command); shell_register_command(&rfchannel_command);

View file

@ -215,13 +215,14 @@ void setup (void)
shell_reboot_init(); shell_reboot_init();
// shell_text_init(); // shell_text_init();
// shell_time_init(); // shell_time_init();
// shell_merkur_init(); shell_merkur_init();
#if COFFEE #if COFFEE
shell_coffee_init(); shell_coffee_init();
shell_file_init(); shell_file_init();
#endif #endif
get_rf_consts();
print_rf_values(); print_rf_values();
// init coap resourcen // init coap resourcen
rest_init_engine (); rest_init_engine ();