43 #include "dev/watchdog.h"
49 #include "dev/sht11/sht11.h"
50 #include "dev/light-sensor.h"
51 #include "dev/battery-sensor.h"
52 #include "dev/sht11/sht11-sensor.h"
55 #include "sys/node-id.h"
61 PROCESS(shell_nodeid_process,
"nodeid");
64 "nodeid: set node ID",
65 &shell_nodeid_process);
66 PROCESS(shell_sense_process,
"sense");
69 "sense: print out sensor data",
70 &shell_sense_process);
71 PROCESS(shell_senseconv_process,
"senseconv");
74 "senseconv: convert 'sense' data to human readable format",
75 &shell_senseconv_process);
76 PROCESS(shell_txpower_process,
"txpower");
79 "txpower <power>: change CC2420 transmission power (0 - 31)",
80 &shell_txpower_process);
81 PROCESS(shell_rfchannel_process,
"rfchannel");
84 "rfchannel <channel>: change CC2420 radio channel (11 - 26)",
85 &shell_rfchannel_process);
87 #define MAX(a, b) ((a) > (b)? (a): (b))
88 #define MIN(a, b) ((a) < (b)? (a): (b))
93 static struct spectrum rssi_samples[NUM_SAMPLES];
103 for(channel = 11; channel <= 26; ++channel) {
104 cc2420_set_channel(channel);
105 rssi_samples[sample].channel[channel - 11] = cc2420_rssi() + 53;
110 sample = (sample + 1) % NUM_SAMPLES;
115 for(channel = 0; channel < 16; ++channel) {
118 for(i = 0; i < NUM_SAMPLES; ++i) {
119 max = MAX(max, rssi_samples[i].channel[channel]);
141 struct sense_msg msg;
144 SENSORS_ACTIVATE(light_sensor);
145 SENSORS_ACTIVATE(battery_sensor);
146 SENSORS_ACTIVATE(sht11_sensor);
150 #if TIMESYNCH_CONF_ENABLED
153 msg.timesynch_time = 0;
155 msg.light1 = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
156 msg.light2 = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR);
157 msg.temp = sht11_sensor.value(SHT11_SENSOR_TEMP);
158 msg.humidity = sht11_sensor.value(SHT11_SENSOR_HUMIDITY);
159 msg.rssi = do_rssi();
160 msg.voltage = battery_sensor.value(0);
162 msg.rssi = do_rssi();
164 SENSORS_DEACTIVATE(light_sensor);
165 SENSORS_DEACTIVATE(battery_sensor);
166 SENSORS_DEACTIVATE(sht11_sensor);
175 struct sense_msg *msg;
181 if(input->len1 + input->len2 == 0) {
184 msg = (
struct sense_msg *)input->data1;
188 snprintf(buf,
sizeof(buf),
189 "%d", 10 * msg->light1 / 7);
191 snprintf(buf,
sizeof(buf),
192 "%d", 46 * msg->light2 / 10);
194 snprintf(buf,
sizeof(buf),
195 "%d.%d", (msg->temp / 10 - 396) / 10,
196 (msg->temp / 10 - 396) % 10);
198 snprintf(buf,
sizeof(buf),
199 "%d", (
int)(-4L + 405L * msg->humidity / 10000L));
201 snprintf(buf,
sizeof(buf),
204 snprintf(buf,
sizeof(buf),
205 "%d.%d", (msg->voltage / 819), (10 * msg->voltage / 819) % 10);
227 msg.txpower = cc2420_get_txpower();
229 cc2420_set_txpower(msg.txpower);
234 shell_output(&txpower_command, &msg,
sizeof(msg),
"", 0);
253 msg.channel = cc2420_get_channel();
255 cc2420_set_channel(msg.channel);
260 shell_output(&rfchannel_command, &msg,
sizeof(msg),
"", 0);
282 node_id_burn(nodeid);
289 snprintf(buf,
sizeof(buf),
"%d", nodeid);
void shell_output_str(struct shell_command *c, char *text1, const char *text2)
Output strings from a shell command.
#define LEDS_RED
LED1 (Red) -> PC0.
#define PROCESS_EXIT()
Exit the currently running process.
#define PROCESS_BEGIN()
Define the beginning of a process.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
#define NULL
The null pointer.
Header file for Tmote Sky-specific Contiki shell commands
Header file for a simple time synchronization mechanism
Header file for the Rime stack
rtimer_clock_t timesynch_time(void)
Get the current time-synchronized time.
void shell_output(struct shell_command *c, void *data1, int len1, const void *data2, int len2)
Output data from a shell command.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
CCIF clock_time_t clock_time(void)
Get the current clock time.
unsigned long shell_strtolong(const char *str, const char **retstr)
Convert a string to a number.
void watchdog_stop(void)
In watchdog mode, the WDT can not be stopped.
Structure for shell input data.
void shell_register_command(struct shell_command *c)
Register a command with the shell.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
#define PROCESS(name, strname)
Declare a process.
int shell_event_input
The event number for shell input data.
#define SHELL_COMMAND(name, command, description, process)
Define a shell command.
Include file for the Contiki low-layer network stack (NETSTACK)