enabled download and sendcmd commands + cleanup
This commit is contained in:
parent
f4755f649f
commit
71c3c8e86c
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: sky-checkpoint.c,v 1.2 2009/03/12 21:58:21 adamdunkels Exp $
|
||||
* $Id: sky-checkpoint.c,v 1.3 2009/04/20 13:08:56 fros4943 Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -62,155 +62,14 @@
|
|||
#include <io.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define DEBUG_SNIFFERS 0
|
||||
#include "cfs/cfs.h"
|
||||
#include "cfs/cfs-coffee.h"
|
||||
#include "lib/checkpoint.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(sky_shell_process, "Sky Contiki shell");
|
||||
AUTOSTART_PROCESSES(&sky_shell_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if DEBUG_SNIFFERS
|
||||
static void
|
||||
input_sniffer(void)
|
||||
{
|
||||
int i;
|
||||
uint8_t *dataptr;
|
||||
|
||||
printf("x %d ", packetbuf_totlen());
|
||||
dataptr = packetbuf_dataptr();
|
||||
printf("%02x ", dataptr[0]);
|
||||
/* if(dataptr[0] == 18) {*/
|
||||
for(i = 1; i < packetbuf_totlen(); ++i) {
|
||||
printf("%02x ", dataptr[i]);
|
||||
}
|
||||
/* }*/
|
||||
printf("\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
output_sniffer(void)
|
||||
{
|
||||
uint8_t *dataptr;
|
||||
printf("- %d ", packetbuf_totlen());
|
||||
dataptr = packetbuf_dataptr();
|
||||
printf("%02x\n", dataptr[0]);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
RIME_SNIFFER(s, input_sniffer, output_sniffer);
|
||||
#endif /* DEBUG_SNIFFERS */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if 0
|
||||
PROCESS(shell_sky_alldata_process, "sky-alldata");
|
||||
SHELL_COMMAND(sky_alldata_command,
|
||||
"sky-alldata",
|
||||
"sky-alldata: sensor data, power consumption, network stats",
|
||||
&shell_sky_alldata_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define MAX(a, b) ((a) > (b)? (a): (b))
|
||||
#define MIN(a, b) ((a) < (b)? (a): (b))
|
||||
struct spectrum {
|
||||
int channel[16];
|
||||
};
|
||||
#define NUM_SAMPLES 4
|
||||
static struct spectrum rssi_samples[NUM_SAMPLES];
|
||||
static int
|
||||
do_rssi(void)
|
||||
{
|
||||
static int sample;
|
||||
int channel;
|
||||
|
||||
rime_mac->off(0);
|
||||
|
||||
cc2420_on();
|
||||
for(channel = 11; channel <= 26; ++channel) {
|
||||
cc2420_set_channel(channel);
|
||||
rssi_samples[sample].channel[channel - 11] = cc2420_rssi() + 53;
|
||||
}
|
||||
|
||||
rime_mac->on();
|
||||
|
||||
sample = (sample + 1) % NUM_SAMPLES;
|
||||
|
||||
{
|
||||
int channel, tot;
|
||||
tot = 0;
|
||||
for(channel = 0; channel < 16; ++channel) {
|
||||
int max = -256;
|
||||
int i;
|
||||
for(i = 0; i < NUM_SAMPLES; ++i) {
|
||||
max = MAX(max, rssi_samples[i].channel[channel]);
|
||||
}
|
||||
tot += max / 20;
|
||||
}
|
||||
return tot;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct sky_alldata_msg {
|
||||
uint16_t len;
|
||||
uint16_t clock;
|
||||
uint16_t timesynch_time;
|
||||
uint16_t light1;
|
||||
uint16_t light2;
|
||||
uint16_t temp;
|
||||
uint16_t humidity;
|
||||
uint16_t rssi;
|
||||
uint16_t cpu;
|
||||
uint16_t lpm;
|
||||
uint16_t transmit;
|
||||
uint16_t listen;
|
||||
rimeaddr_t best_neighbor;
|
||||
uint16_t best_neighbor_etx;
|
||||
uint16_t best_neighbor_rtmetric;
|
||||
uint16_t battery_voltage;
|
||||
uint16_t battery_indicator;
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(shell_sky_alldata_process, ev, data)
|
||||
{
|
||||
static unsigned long last_cpu, last_lpm, last_transmit, last_listen;
|
||||
struct sky_alldata_msg msg;
|
||||
struct neighbor *n;
|
||||
PROCESS_BEGIN();
|
||||
|
||||
|
||||
msg.len = sizeof(struct sky_alldata_msg) / sizeof(uint16_t);
|
||||
msg.clock = clock_time();
|
||||
msg.timesynch_time = timesynch_time();
|
||||
msg.light1 = sensors_light1();
|
||||
msg.light2 = sensors_light2();
|
||||
msg.temp = sht11_temp();
|
||||
msg.humidity = sht11_humidity();
|
||||
msg.rssi = do_rssi();
|
||||
|
||||
energest_flush();
|
||||
|
||||
msg.cpu = energest_type_time(ENERGEST_TYPE_CPU) - last_cpu;
|
||||
msg.lpm = energest_type_time(ENERGEST_TYPE_LPM) - last_lpm;
|
||||
msg.transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT) - last_transmit;
|
||||
msg.listen = energest_type_time(ENERGEST_TYPE_LISTEN) - last_listen;
|
||||
|
||||
|
||||
last_cpu = energest_type_time(ENERGEST_TYPE_CPU);
|
||||
last_lpm = energest_type_time(ENERGEST_TYPE_LPM);
|
||||
last_transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT);
|
||||
last_listen = energest_type_time(ENERGEST_TYPE_LISTEN);
|
||||
|
||||
rimeaddr_copy(&msg.best_neighbor, &rimeaddr_null);
|
||||
msg.best_neighbor_etx =
|
||||
msg.best_neighbor_rtmetric = 0;
|
||||
n = neighbor_best();
|
||||
if(n != NULL) {
|
||||
rimeaddr_copy(&msg.best_neighbor, &n->addr);
|
||||
msg.best_neighbor_etx = neighbor_etx(n);
|
||||
msg.best_neighbor_rtmetric = n->rtmetric;
|
||||
}
|
||||
msg.battery_voltage = battery_sensor.value(0);
|
||||
msg.battery_indicator = sht11_sreg() & 0x40? 1: 0;
|
||||
shell_output(&sky_alldata_command, &msg, sizeof(msg), "", 0);
|
||||
PROCESS_END();
|
||||
}
|
||||
#endif /* 0 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(sky_shell_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
@ -222,23 +81,17 @@ PROCESS_THREAD(sky_shell_process, ev, data)
|
|||
shell_ps_init();
|
||||
shell_reboot_init();
|
||||
shell_rime_init();
|
||||
shell_rime_netcmd_init();
|
||||
shell_rime_ping_init();
|
||||
/*shell_rime_netcmd_init();*/
|
||||
/*shell_rime_ping_init();*/
|
||||
/*shell_rime_debug_init();*/
|
||||
/* shell_rime_sniff_init();*/
|
||||
/*shell_rime_sniff_init();*/
|
||||
shell_rime_sendcmd_init();
|
||||
shell_download_init();
|
||||
shell_sky_init();
|
||||
shell_text_init();
|
||||
shell_time_init();
|
||||
shell_checkpoint_init();
|
||||
|
||||
#if 0
|
||||
shell_register_command(&sky_alldata_command);
|
||||
#endif /* 0 */
|
||||
|
||||
#if DEBUG_SNIFFERS
|
||||
rime_sniffer_add(&s);
|
||||
#endif /* DEBUG_SNIFFERS */
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue