2 #include "contiki-lib.h"
3 #include "contiki-net.h"
15 #define COMMAND_NONE 0
18 MEMB(conns,
struct cmdd_state, 1);
20 PROCESS(cmdd_process,
"Command server");
23 static char send_udp = 0;
24 static const char *prompt =
"contiki> ";
28 n(uint16_t num,
char *ptr)
38 for(d = 10000; d >= 1; d /= 10) {
67 PT_THREAD(handle_connection(
struct cmdd_state *s))
74 s->command != COMMAND_NONE);
78 if(strncmp(s->inputbuf,
"quit", 4) == 0) {
90 }
else if(strncmp(s->inputbuf,
"send", 4) == 0) {
108 struct cmdd_state *s = (
struct cmdd_state *)state;
126 PSOCK_INIT(&s->s, s->inputbuf,
sizeof(s->inputbuf) - 1);
128 handle_connection(s);
130 }
else if(s !=
NULL) {
139 handle_connection(s);
161 }
else if(ev == PROCESS_EVENT_EXIT) {
#define PSOCK_READTO(psock, c)
Read data up to a specified character.
void memb_init(struct memb *m)
Initialize a memory block that was declared with MEMB().
#define PSOCK_CLOSE_EXIT(psock)
Close a protosocket and exit the protosocket's protothread.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PSOCK_BEGIN(psock)
Start the protosocket protothread in a function.
Representation of a uIP TCP connection.
#define uip_aborted()
Has the connection been aborted by the other end?
CCIF struct uip_udp_conn * udp_new(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate)
Create a new UDP connection.
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
char memb_free(struct memb *m, void *ptr)
Deallocate a memory block from a memory block previously declared with MEMB().
void * memb_alloc(struct memb *m)
Allocate a memory block from a block of memory declared with MEMB().
#define NULL
The null pointer.
#define uip_poll()
Is the connection being polled by uIP?
#define uip_udp_send(len)
Send a UDP datagram of length len on the current connection.
#define UIP_HTONS(n)
Convert 16-bit quantity from host byte order to network byte order.
#define PT_THREAD(name_args)
Declaration of a protothread.
#define uip_connected()
Has the connection just been connected?
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
#define PSOCK_WAIT_UNTIL(psock, condition)
Wait until a condition is true.
#define uip_abort()
Abort the current connection.
#define PSOCK_INIT(psock, buffer, buffersize)
Initialize a protosocket.
#define LOADER_UNLOAD()
Unload a program from memory.
#define MEMB(name, structure, num)
Declare a memory block.
#define PSOCK_SEND(psock, data, datalen)
Send data.
The representation of a protosocket.
#define PSOCK_END(psock)
Declare the end of a protosocket's protothread.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
#define uip_udpconnection()
Is the current connection a UDP connection?
#define PROCESS(name, strname)
Declare a process.
process_event_t tcpip_event
The uIP event.
#define uip_timedout()
Has the connection timed out?
#define PSOCK_NEWDATA(psock)
Check if new data has arrived on a protosocket.
CCIF void tcp_listen(uint16_t port)
Open a TCP port.
#define uip_closed()
Has the connection been closed by the other end?
Representation of a uIP UDP connection.
#define CC_FASTCALL
Configure if the C compiler supports fastcall function declarations.
#define uip_ipaddr(addr, addr0, addr1, addr2, addr3)
Construct an IP address from four bytes.
int timer_expired(struct timer *t)
Check if a timer has expired.
void process_exit(struct process *p)
Cause a process to exit.
void timer_reset(struct timer *t)
Reset the timer with the same interval.
#define CLOCK_SECOND
A second, measured in system clock time.