41 #include "contiki-conf.h"
46 #include "lib/random.h"
56 int snprintf(
char *str,
size_t size,
const char *format, ...);
60 #define COLLECT_MSG_HDRSIZE 2
66 static struct runicast_conn ruc;
68 PROCESS(shell_runicast_process,
"runicast");
71 "runicast <node addr>: reliably unicast data to specific neighbor",
72 &shell_runicast_process);
77 static linkaddr_t receiver;
80 struct collect_msg *msg;
86 if(nextptr == data || *nextptr !=
'.') {
88 "runicast <receiver>: recevier must be specified",
"");
94 snprintf(buf,
sizeof(buf),
"%d.%d", receiver.u8[0], receiver.u8[1]);
101 len = input->len1 + input->len2;
111 memcpy(msg->data, input->data1, input->len1);
112 memcpy(msg->data + input->len1, input->data2, input->len2);
113 #if TIMESYNCH_CONF_ENABLED
119 runicast_send(&ruc, &receiver, 4);
125 recv_ruc(
struct runicast_conn *c,
const linkaddr_t *from, uint8_t seqno)
127 struct collect_msg *msg;
128 rtimer_clock_t latency;
129 #if TIMESYNCH_CONF_ENABLED
130 rtimer_clock_t timestamp;
135 #if TIMESYNCH_CONF_ENABLED
136 memcpy(×tamp, &msg->timestamp,
sizeof(timestamp));
142 printf(
"runicast message received from %d.%d, latency %lu ms, seqno %d, data '%.*s'\n",
143 from->u8[0], from->u8[1],
144 (1000L * latency) / RTIMER_ARCH_SECOND,
150 sent_ruc(
struct runicast_conn *c,
const linkaddr_t *to, uint8_t tx)
152 printf(
"runicast message sent to %d.%d, %d transmissions\n",
153 to->u8[0], to->u8[1],
157 timedout_ruc(
struct runicast_conn *c,
const linkaddr_t *to, uint8_t tx)
159 printf(
"runicast message to %d.%d timed out after %d transmissions\n",
160 to->u8[0], to->u8[1],
163 static const struct runicast_callbacks runicast_callbacks = {recv_ruc,
168 shell_rime_debug_runicast_init(
void)
170 runicast_open(&ruc, SHELL_RIME_CHANNEL_RUNICAST,
171 &runicast_callbacks);
void shell_output_str(struct shell_command *c, char *text1, const char *text2)
Output strings from a shell command.
#define PROCESS_EXIT()
Exit the currently running process.
#define PROCESS_BEGIN()
Define the beginning of a process.
Header file for a simple time synchronization mechanism
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.
Header file for the Rime stack
rtimer_clock_t timesynch_time(void)
Get the current time-synchronized time.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
unsigned long shell_strtolong(const char *str, const char **retstr)
Convert a string to a number.
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.
void packetbuf_clear(void)
Clear and reset the packetbuf.
Header file for Trickle (reliable single source flooding) for Rime
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
#define SHELL_COMMAND(name, command, description, process)
Define a shell command.
A brief description of what this file is.
Header file for the Rime route table