41 #include "contiki-conf.h"
46 #include "lib/random.h"
56 int snprintf(
char *str,
size_t size,
const char *format, ...);
60 #define MAX_DATALEN 32
61 #define UNICAST_MSG_HDRSIZE 2
64 uint8_t data[MAX_DATALEN];
67 static uint8_t is_receiving;
68 static struct unicast_conn uc;
70 PROCESS(shell_unicast_send_process,
"unicast-send");
73 "unicast-send <node addr>: send data to specific neighbor",
74 &shell_unicast_send_process);
75 PROCESS(shell_unicast_recv_process,
"unicast-recv");
78 "unicast-recv: receive data that neighbors send with unicast-send",
79 &shell_unicast_recv_process);
84 static linkaddr_t receiver;
87 struct unicast_msg *msg;
92 if(nextptr == data || *nextptr !=
'.') {
94 "unicast <receiver>: recevier must be specified",
"");
107 len = input->len1 + input->len2;
113 if(len < MAX_DATALEN) {
118 memcpy(msg->data, input->data1, input->len1);
119 memcpy(msg->data + input->len1, input->data2, input->len2);
121 #if TIMESYNCH_CONF_ENABLED
127 unicast_send(&uc, &receiver);
134 recv_uc(
struct unicast_conn *c,
const linkaddr_t *from)
136 struct unicast_msg *msg;
137 #define OUTPUT_BLOB_HDRSIZE 6
142 uint16_t data[MAX_DATALEN];
145 if(is_receiving == 0) {
151 #if TIMESYNCH_CONF_ENABLED
154 output_blob.latency = 0;
170 static const struct unicast_callbacks unicast_callbacks = {recv_uc};
188 shell_rime_unicast_init(
void)
190 unicast_open(&uc, SHELL_RIME_CHANNEL_UNICAST,
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.
#define NULL
The null pointer.
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.
void shell_output(struct shell_command *c, void *data1, int len1, const void *data2, int len2)
Output data from a shell command.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
#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.
#define PROCESS_EXITHANDLER(handler)
Specify an action when a process exits.
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_WAIT_EVENT()
Wait for an event to be posted to the process.
#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
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