1 #include "contiki-net.h"
3 #include "net/ip/dhcpc.h"
9 AUTOSTART_PROCESSES(&dhcp_process);
12 static struct ctk_button getbutton =
14 static struct ctk_label statuslabel =
18 static struct ctk_label ipaddrlabel =
20 static char ipaddr[17];
21 static struct ctk_textentry ipaddrentry =
23 static struct ctk_label netmasklabel =
25 static char netmask[17];
26 static struct ctk_textentry netmaskentry =
28 static struct ctk_label gatewaylabel =
30 static char gateway[17];
31 static struct ctk_textentry gatewayentry =
33 static struct ctk_label dnsserverlabel =
35 static char dnsserver[17];
36 static struct ctk_textentry dnsserverentry =
44 set_statustext(
char *text)
51 makebyte(uint8_t byte,
char *str)
54 *str++ = (byte / 100 ) % 10 +
'0';
57 *str++ = (byte / 10) % 10 +
'0';
59 *str++ = (byte % 10) +
'0';
65 makeaddr(uip_ipaddr_t *addr,
char *str)
67 str = makebyte(addr->u8[0], str);
69 str = makebyte(addr->u8[1], str);
71 str = makebyte(addr->u8[2], str);
73 str = makebyte(addr->u8[3], str);
80 uip_ipaddr_t addr, *addrptr;
83 makeaddr(&addr, ipaddr);
86 makeaddr(&addr, netmask);
89 makeaddr(&addr, gateway);
91 addrptr = resolv_getserver();
93 makeaddr(addrptr, dnsserver);
124 if(data == (process_data_t)&getbutton) {
126 set_statustext(
"Requesting...");
129 dhcpc_appcall(ev, data);
130 }
else if(ev == PROCESS_EVENT_EXIT ||
135 }
else if(ev == SHOWCONFIG) {
145 dhcpc_configured(
const struct dhcpc_state *s)
150 resolv_conf(&s->dnsaddr);
151 set_statustext(
"Configured.");
156 dhcpc_unconfigured(
const struct dhcpc_state *s)
158 set_statustext(
"Unconfigured.");
#define PROCESS_CURRENT()
Get a pointer to the currently running process.
#define CTK_WIDGET_ADD(win, widg)
Add a widget to a window.
process_event_t ctk_signal_window_close
Emitted when a window is closed.
#define uip_sethostaddr(addr)
Set the IP address of this host.
#define uip_gethostaddr(addr)
Get the IP address of this host.
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
void ctk_window_open(CC_REGISTER_ARG struct ctk_window *w)
Open a window, or bring window to front if already open.
#define CTK_WIDGET_FOCUS(win, widg)
Set focus to a widget.
void ctk_window_close(struct ctk_window *w)
Close a window if it is open.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define ctk_label_set_text(l, t)
Set the text of a label.
#define NULL
The null pointer.
void ctk_window_redraw(struct ctk_window *w)
Redraw a window.
#define uip_getdraddr(addr)
Get the default router's IP address.
int process_post(struct process *p, process_event_t ev, process_data_t data)
Post an asynchronous event.
#define uip_setdraddr(addr)
Set the default router's IP address.
#define CTK_LABEL(x, y, w, h, text)
Instantiating macro for the ctk_label widget.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
void ctk_window_new(struct ctk_window *window, unsigned char w, unsigned char h, char *title)
Create a new window.
#define LOADER_UNLOAD()
Unload a program from memory.
#define uip_getnetmask(addr)
Get the netmask.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
#define PROCESS(name, strname)
Declare a process.
process_event_t ctk_signal_widget_activate
Emitted when a widget is activated (pressed).
process_event_t tcpip_event
The uIP event.
#define CTK_BUTTON(x, y, w, text)
Instantiating macro for the ctk_button widget.
Representation of a CTK window.
#define CTK_WIDGET_REDRAW(widg)
Add a widget to the redraw queue.
#define uip_setnetmask(addr)
Set the netmask.
void process_exit(struct process *p)
Cause a process to exit.