44 #include "dev/watchdog.h"
50 #include "dev/sht11/sht11.h"
51 #include "dev/light-sensor.h"
52 #include "dev/battery-sensor.h"
53 #include "dev/sht11/sht11-sensor.h"
56 #include "sys/node-id.h"
62 PROCESS(shell_nodeid_process,
"nodeid");
65 "nodeid: set node ID",
66 &shell_nodeid_process);
67 PROCESS(shell_sense_process,
"sense");
70 "sense: print out sensor data",
71 &shell_sense_process);
72 PROCESS(shell_senseconv_process,
"senseconv");
75 "senseconv: convert 'sense' data to human readable format",
76 &shell_senseconv_process);
77 PROCESS(shell_txpower_process,
"txpower");
80 "txpower <power>: change CC2420 transmission power (0 - 31)",
81 &shell_txpower_process);
82 PROCESS(shell_rfchannel_process,
"rfchannel");
85 "rfchannel <channel>: change CC2420 radio channel (11 - 26)",
86 &shell_rfchannel_process);
92 static struct spectrum rssi_samples[NUM_SAMPLES];
102 for(channel = 11; channel <= 26; ++channel) {
103 cc2420_set_channel(channel);
104 rssi_samples[sample].channel[channel - 11] = cc2420_rssi() + 53;
109 sample = (sample + 1) % NUM_SAMPLES;
114 for(channel = 0; channel < 16; ++channel) {
117 for(i = 0; i < NUM_SAMPLES; ++i) {
118 max = MAX(max, rssi_samples[i].channel[channel]);
140 struct sense_msg msg;
143 SENSORS_ACTIVATE(light_sensor);
144 SENSORS_ACTIVATE(battery_sensor);
145 SENSORS_ACTIVATE(sht11_sensor);
149 #if TIMESYNCH_CONF_ENABLED
152 msg.timesynch_time = 0;
154 msg.light1 = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
155 msg.light2 = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR);
156 msg.temp = sht11_sensor.value(SHT11_SENSOR_TEMP);
157 msg.humidity = sht11_sensor.value(SHT11_SENSOR_HUMIDITY);
158 msg.rssi = do_rssi();
159 msg.voltage = battery_sensor.value(0);
161 msg.rssi = do_rssi();
163 SENSORS_DEACTIVATE(light_sensor);
164 SENSORS_DEACTIVATE(battery_sensor);
165 SENSORS_DEACTIVATE(sht11_sensor);
174 struct sense_msg *msg;
180 if(input->len1 + input->len2 == 0) {
183 msg = (
struct sense_msg *)input->data1;
187 snprintf(buf,
sizeof(buf),
188 "%d", 10 * msg->light1 / 7);
190 snprintf(buf,
sizeof(buf),
191 "%d", 46 * msg->light2 / 10);
193 snprintf(buf,
sizeof(buf),
194 "%d.%d", (msg->temp / 10 - 396) / 10,
195 (msg->temp / 10 - 396) % 10);
197 snprintf(buf,
sizeof(buf),
198 "%d", (
int)(-4L + 405L * msg->humidity / 10000L));
200 snprintf(buf,
sizeof(buf),
203 snprintf(buf,
sizeof(buf),
204 "%d.%d", (msg->voltage / 819), (10 * msg->voltage / 819) % 10);
226 msg.txpower = cc2420_get_txpower();
228 cc2420_set_txpower(msg.txpower);
233 shell_output(&txpower_command, &msg,
sizeof(msg),
"", 0);
252 msg.channel = cc2420_get_channel();
254 cc2420_set_channel(msg.channel);
259 shell_output(&rfchannel_command, &msg,
sizeof(msg),
"", 0);
281 node_id_burn(nodeid);
284 leds_off(LEDS_RED + LEDS_BLUE);
288 snprintf(buf,
sizeof(buf),
"%d", nodeid);
rtimer_clock_t timesynch_time(void)
Get the current time-synchronized time.
CCIF clock_time_t clock_time(void)
Get the current clock time.
Default definitions of C compiler quirk work-arounds.
void shell_output_str(struct shell_command *c, char *text1, const char *text2)
Output strings from a shell command.
#define PROCESS_END()
Define the end of a process.
#define PROCESS(name, strname)
Declare a process.
static void input(void)
Process a received 6lowpan packet.
unsigned long shell_strtolong(const char *str, const char **retstr)
Convert a string to a number.
Header file for Tmote Sky-specific Contiki shell commands
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_EXIT()
Exit the currently running process.
void shell_output(struct shell_command *c, void *data1, int len1, const void *data2, int len2)
Output data from a shell command.
void watchdog_stop(void)
Stops the WDT such that it won't timeout and cause MCU reset.
#define SHELL_COMMAND(name, command, description, process)
Define a shell command.
int shell_event_input
The event number for shell input data.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
void shell_register_command(struct shell_command *c)
Register a command with the shell.
Header file for the Rime stack
#define NULL
The null pointer.
Structure for shell input data.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
Header file for a simple time synchronization mechanism
Include file for the Contiki low-layer network stack (NETSTACK)
#define PROCESS_BEGIN()
Define the beginning of a process.