mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-13 10:29:27 +00:00
Import of the contiki-2.x development code from the SICS internal CVS server
This commit is contained in:
commit
c9e808d638
128
Makefile.include
Normal file
128
Makefile.include
Normal file
@ -0,0 +1,128 @@
|
||||
ifndef CONTIKI
|
||||
$(error CONTIKI not defined! You must specify where CONTIKI resides!)
|
||||
endif
|
||||
|
||||
OBJECTDIR = obj_$(TARGET)
|
||||
|
||||
|
||||
ifeq ($(TARGET),)
|
||||
-include Makefile.target
|
||||
ifeq ($(TARGET),)
|
||||
$(warning TARGET not defined, using netsim target)
|
||||
TARGET=netsim
|
||||
else
|
||||
$(warning using saved target '$(TARGET)')
|
||||
endif
|
||||
endif
|
||||
|
||||
usage:
|
||||
@echo "make MAKETARGETS... [TARGET=(TARGET)] [savetarget]"
|
||||
|
||||
savetarget:
|
||||
-@rm -f Makefile.target
|
||||
@echo >Makefile.target "TARGET = $(TARGET)"
|
||||
|
||||
ifeq (${wildcard $(OBJECTDIR)},)
|
||||
DUMMY := ${shell mkdir $(OBJECTDIR)}
|
||||
endif
|
||||
|
||||
SYSTEM = process.c procinit.c service.c autostart.c
|
||||
THREADS = mt.c
|
||||
LIBS = memb.c timer.c list.c etimer.c
|
||||
CFS = cfs.c cfs-ram.c
|
||||
CTK = ctk.c
|
||||
UIP = uip.c uiplib.c resolv.c tcpip.c psock.c hc.c uip-split.c \
|
||||
uip-fw.c uip-fw-service.c uipbuf.c uip_arp.c uiplib.c tcpdump.c \
|
||||
uip-neighbor.c
|
||||
NET = $(UIP) uaodv.c uaodv-rt.c
|
||||
|
||||
CTKVNC = $(CTK) ctk-vncserver.c libconio.c vnc-server.c vnc-out.c \
|
||||
ctk-vncfont.c
|
||||
CTKTERM = $(CTK) libconio.c ctk-term.c ctk-term-in.c ctk-term-out.c \
|
||||
ctk-termtelnet.c
|
||||
|
||||
CONTIKIFILES = $(SYSTEM) $(THREADS) $(CFS) $(LIBS) $(NET) $(DHCP)
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKIFILES)
|
||||
|
||||
# contiki.a: ${addprefix $(OBJECTDIR)/, $(CONTIKIFILES:.c=.o)}
|
||||
# @$(AR) rcf $@ $^
|
||||
|
||||
# contikiapps.a: ${addprefix $(OBJECTDIR)/, $(APPSFILES:.c=.o)}
|
||||
# @$(AR) rcf $@ $^
|
||||
|
||||
CONTIKIDIRS = ${addprefix $(CONTIKI)/core/,dev lib net sys \
|
||||
cfs ctk lib/ctk loader . }
|
||||
#APPDIRS += ${filter-out $(CONTIKI)/apps/CVS,${wildcard ${addprefix $(CONTIKI)/,apps/*}}}
|
||||
|
||||
PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,$(PROJECT_SOURCEFILES:.c=.o)}
|
||||
|
||||
### Include application makefiles
|
||||
|
||||
ifdef APPS
|
||||
APPDIRS += $(addprefix $(CONTIKI)/apps/, $(APPS))
|
||||
APPINCLUDES = $(foreach APP, $(APPS), $(CONTIKI)/apps/$(APP)/Makefile.$(APP))
|
||||
-include $(APPINCLUDES)
|
||||
CONTIKI_SOURCEFILES += $(APP_SOURCES) $(DSC_SOURCES)
|
||||
endif
|
||||
|
||||
### Include target makefile (TODO Unsafe?)
|
||||
include $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET)
|
||||
|
||||
### Automatic dependency generation
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.d) \
|
||||
$(PROJECT_SOURCEFILES:.c=.d))
|
||||
endif
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *~ *core core *.srec node-id.c \
|
||||
*.lst *.map \
|
||||
*.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \
|
||||
*.ce *.co
|
||||
-rm -rf $(OBJECTDIR)
|
||||
|
||||
%.ce: %.c
|
||||
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
||||
$(STRIP) --strip-unneeded -g -x $@
|
||||
|
||||
$(OBJECTDIR)/%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.co: %.c
|
||||
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
||||
|
||||
contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/, $(CONTIKI_SOURCEFILES:.c=.o)}
|
||||
$(AR) rcf $@ $^
|
||||
|
||||
|
||||
ifndef CCDEP
|
||||
CCDEP = $(CC)
|
||||
endif
|
||||
ifndef CDEPFLAGS
|
||||
CDEPFLAGS = $(CFLAGS)
|
||||
endif
|
||||
|
||||
$(OBJECTDIR)/%.d: %.c
|
||||
@set -e; rm -f $@; \
|
||||
$(CCDEP) -MM $(CDEPFLAGS) $< > $@.$$$$; \
|
||||
sed 's,\($*\)\.o[ :]*,$(OBJECTDIR)/\1.o $@ : ,g' < $@.$$$$ > $@; \
|
||||
rm -f $@.$$$$
|
||||
|
||||
|
||||
# The line below is needed so that GNU make does not remove the
|
||||
# generated file.
|
||||
.PRECIOUS: %.$(TARGET)
|
||||
|
||||
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a
|
||||
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(filter-out %.a,$^) $(filter %.a,$^)
|
||||
|
||||
# The target below looks weird, but I had to add the @ to avoid complaints
|
||||
# from GNU make about "*** No rule to make target `XXX'. Stop."
|
||||
%: %.$(TARGET)
|
||||
@
|
2
apps/about/Makefile.about
Normal file
2
apps/about/Makefile.about
Normal file
@ -0,0 +1,2 @@
|
||||
APP_SOURCES += about.c
|
||||
DSC_SOURCES += about-dsc.c
|
74
apps/about/about-dsc.c
Normal file
74
apps/about/about-dsc.c
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: about-dsc.c,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sys/dsc.h"
|
||||
|
||||
extern struct ctk_icon about_icon;
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
DSC(about_dsc,
|
||||
"About Contiki",
|
||||
"about.prg",
|
||||
about_process,
|
||||
&about_icon);
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if CTK_CONF_ICON_BITMAPS
|
||||
static unsigned char abouticon_bitmap[3*3*8] = {
|
||||
0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
|
||||
0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
|
||||
0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
|
||||
|
||||
0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
|
||||
0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
|
||||
0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
|
||||
|
||||
0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
|
||||
0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
|
||||
0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_BITMAPS */
|
||||
|
||||
#if CTK_CONF_ICON_TEXTMAPS
|
||||
static char abouticon_textmap[9] = {
|
||||
' ', ' ', 'c',
|
||||
' ', '?', ' ',
|
||||
'.', ' ', ' '
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_TEXTMAPS */
|
||||
|
||||
#if CTK_CONF_ICONS
|
||||
static struct ctk_icon about_icon =
|
||||
{CTK_ICON("About Contiki", abouticon_bitmap, abouticon_textmap)};
|
||||
#endif /* CTK_CONF_ICONS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
42
apps/about/about-dsc.h
Normal file
42
apps/about/about-dsc.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: about-dsc.h,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __ABOUT_DSC_H__
|
||||
#define __ABOUT_DSC_H__
|
||||
|
||||
#include "sys/dsc.h"
|
||||
|
||||
DSC_HEADER(about_dsc);
|
||||
|
||||
#endif /* __ABOUT_DSC_H__ */
|
127
apps/about/about.c
Normal file
127
apps/about/about.c
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: about.c,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "contiki.h"
|
||||
#include "ctk/ctk.h"
|
||||
|
||||
static struct ctk_window aboutdialog;
|
||||
static struct ctk_label aboutlabel1 =
|
||||
{CTK_LABEL(2, 0, 28, 1, "The Contiki Operating System")};
|
||||
static struct ctk_label aboutlabel2 =
|
||||
{CTK_LABEL(3, 2, 28, 1, "A modern, Internet-enabled")};
|
||||
static struct ctk_label aboutlabel3 =
|
||||
{CTK_LABEL(6, 3, 20, 1, "operating system and")};
|
||||
static struct ctk_label aboutlabel4 =
|
||||
{CTK_LABEL(6, 4, 20, 1, "desktop environment.")};
|
||||
|
||||
static char abouturl_petscii[] = "http://www.sics.se/~adam/contiki/";
|
||||
static char abouturl_ascii[40];
|
||||
static struct ctk_hyperlink abouturl =
|
||||
{CTK_HYPERLINK(0, 6, 32, "http://www.sics.se/~adam/contiki/",
|
||||
abouturl_ascii)};
|
||||
static struct ctk_button aboutclose =
|
||||
{CTK_BUTTON(12, 8, 5, "Close")};
|
||||
|
||||
|
||||
PROCESS(about_process, "About Contiki");
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
about_quit(void)
|
||||
{
|
||||
ctk_dialog_close();
|
||||
process_exit(&about_process);
|
||||
LOADER_UNLOAD();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(about_process, ev, data)
|
||||
{
|
||||
unsigned char width;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
width = ctk_desktop_width(NULL);
|
||||
|
||||
strcpy(abouturl_ascii, abouturl_petscii);
|
||||
petsciiconv_toascii(abouturl_ascii, sizeof(abouturl_ascii));
|
||||
|
||||
if(width > 34) {
|
||||
ctk_dialog_new(&aboutdialog, 32, 9);
|
||||
} else {
|
||||
ctk_dialog_new(&aboutdialog, width - 2, 9);
|
||||
}
|
||||
CTK_WIDGET_ADD(&aboutdialog, &aboutlabel1);
|
||||
CTK_WIDGET_ADD(&aboutdialog, &aboutlabel2);
|
||||
CTK_WIDGET_ADD(&aboutdialog, &aboutlabel3);
|
||||
CTK_WIDGET_ADD(&aboutdialog, &aboutlabel4);
|
||||
if(width > 34) {
|
||||
CTK_WIDGET_ADD(&aboutdialog, &abouturl);
|
||||
CTK_WIDGET_SET_FLAG(&abouturl, CTK_WIDGET_FLAG_MONOSPACE);
|
||||
} else {
|
||||
CTK_WIDGET_SET_XPOS(&aboutlabel1, 0);
|
||||
CTK_WIDGET_SET_XPOS(&aboutlabel2, 0);
|
||||
CTK_WIDGET_SET_XPOS(&aboutlabel3, 0);
|
||||
CTK_WIDGET_SET_XPOS(&aboutlabel4, 0);
|
||||
|
||||
CTK_WIDGET_SET_XPOS(&aboutclose, 0);
|
||||
}
|
||||
CTK_WIDGET_ADD(&aboutdialog, &aboutclose);
|
||||
CTK_WIDGET_FOCUS(&aboutdialog, &aboutclose);
|
||||
|
||||
ctk_dialog_open(&aboutdialog);
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
if(ev == PROCESS_EVENT_EXIT) {
|
||||
about_quit();
|
||||
PROCESS_EXIT();
|
||||
} else if(ev == ctk_signal_button_activate) {
|
||||
if(data == (process_data_t)&aboutclose) {
|
||||
about_quit();
|
||||
PROCESS_EXIT();
|
||||
}
|
||||
} else if(ev == ctk_signal_hyperlink_activate) {
|
||||
if((struct ctk_widget *)data == (struct ctk_widget *)&abouturl) {
|
||||
about_quit();
|
||||
PROCESS_EXIT();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
2
apps/calc/Makefile.calc
Normal file
2
apps/calc/Makefile.calc
Normal file
@ -0,0 +1,2 @@
|
||||
APP_SOURCES += calc.c
|
||||
DSC_SOURCES += calc-dsc.c
|
74
apps/calc/calc-dsc.c
Normal file
74
apps/calc/calc-dsc.c
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: calc-dsc.c,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sys/dsc.h"
|
||||
|
||||
extern struct ctk_icon calc_icon;
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
DSC(calc_dsc,
|
||||
"Simple calculator",
|
||||
"calc.prg",
|
||||
calc_process,
|
||||
&calc_icon);
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if CTK_CONF_ICON_BITMAPS
|
||||
static unsigned char calcicon_bitmap[3*3*8] = {
|
||||
0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
|
||||
0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
|
||||
0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
|
||||
|
||||
0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
|
||||
0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
|
||||
0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
|
||||
|
||||
0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
|
||||
0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
|
||||
0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_BITMAPS */
|
||||
|
||||
#if CTK_CONF_ICON_TEXTMAPS
|
||||
static char calcicon_textmap[9] = {
|
||||
'+', ' ', '-',
|
||||
' ', '*', ' ',
|
||||
'=', ' ', '/'
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_TEXTMAPS */
|
||||
|
||||
#if CTK_CONF_ICONS
|
||||
static struct ctk_icon calc_icon =
|
||||
{CTK_ICON("Calculator", calcicon_bitmap, calcicon_textmap)};
|
||||
#endif /* CTK_CONF_ICONS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
42
apps/calc/calc-dsc.h
Normal file
42
apps/calc/calc-dsc.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: calc-dsc.h,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __CALC_DSC_H__
|
||||
#define __CALC_DSC_H__
|
||||
|
||||
#include "sys/dsc.h"
|
||||
|
||||
DSC_HEADER(calc_dsc);
|
||||
|
||||
#endif /* __CALC_DSC_H__ */
|
293
apps/calc/calc.c
Normal file
293
apps/calc/calc.c
Normal file
@ -0,0 +1,293 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This an example program for the Contiki desktop OS
|
||||
*
|
||||
* $Id: calc.c,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "ctk/ctk.h"
|
||||
|
||||
static struct ctk_window window;
|
||||
|
||||
static char input[16];
|
||||
static struct ctk_label inputlabel =
|
||||
{CTK_LABEL(0, 0, 12, 1, input)};
|
||||
|
||||
static struct ctk_button button7 =
|
||||
{CTK_BUTTON(0, 3, 1, "7")};
|
||||
static struct ctk_button button8 =
|
||||
{CTK_BUTTON(3, 3, 1, "8")};
|
||||
static struct ctk_button button9 =
|
||||
{CTK_BUTTON(6, 3, 1, "9")};
|
||||
static struct ctk_button button4 =
|
||||
{CTK_BUTTON(0, 4, 1, "4")};
|
||||
static struct ctk_button button5 =
|
||||
{CTK_BUTTON(3, 4, 1, "5")};
|
||||
static struct ctk_button button6 =
|
||||
{CTK_BUTTON(6, 4, 1, "6")};
|
||||
static struct ctk_button button1 =
|
||||
{CTK_BUTTON(0, 5, 1, "1")};
|
||||
static struct ctk_button button2 =
|
||||
{CTK_BUTTON(3, 5, 1, "2")};
|
||||
static struct ctk_button button3 =
|
||||
{CTK_BUTTON(6, 5, 1, "3")};
|
||||
static struct ctk_button button0 =
|
||||
{CTK_BUTTON(0, 6, 3, " 0 ")};
|
||||
|
||||
static struct ctk_button cbutton =
|
||||
{CTK_BUTTON(0, 2, 1, "C")};
|
||||
|
||||
static struct ctk_button divbutton =
|
||||
{CTK_BUTTON(9, 2, 1, "/")};
|
||||
static struct ctk_button mulbutton =
|
||||
{CTK_BUTTON(9, 3, 1, "*")};
|
||||
|
||||
static struct ctk_button subbutton =
|
||||
{CTK_BUTTON(9, 4, 1, "-")};
|
||||
static struct ctk_button addbutton =
|
||||
{CTK_BUTTON(9, 5, 1, "+")};
|
||||
static struct ctk_button calcbutton =
|
||||
{CTK_BUTTON(9, 6, 1, "=")};
|
||||
|
||||
PROCESS(calc_process, "Calculator");
|
||||
|
||||
static unsigned long operand1, operand2;
|
||||
static unsigned char op;
|
||||
#define OP_ADD 1
|
||||
#define OP_SUB 2
|
||||
#define OP_MUL 3
|
||||
#define OP_DIV 4
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
calc_quit(void)
|
||||
{
|
||||
process_exit(&calc_process);
|
||||
LOADER_UNLOAD();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
add_to_input(char c)
|
||||
{
|
||||
unsigned char i;
|
||||
|
||||
for(i = 0; i < 11; ++i) {
|
||||
input[i] = input[i + 1];
|
||||
}
|
||||
input[11] = c;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
clear_input(void)
|
||||
{
|
||||
unsigned char i;
|
||||
|
||||
for(i = 0; i < sizeof(input); ++i) {
|
||||
input[i] = ' ';
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
input_to_operand1(void)
|
||||
{
|
||||
unsigned int m;
|
||||
unsigned char i;
|
||||
|
||||
operand1 = 0;
|
||||
for(m = 1, i = 11;
|
||||
i > 7; --i, m *= 10) {
|
||||
if(input[i] >= '0' &&
|
||||
input[i] <= '9') {
|
||||
operand1 += (input[i] - '0') * m;
|
||||
}
|
||||
}
|
||||
clear_input();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
operand2_to_input(void)
|
||||
{
|
||||
unsigned char i;
|
||||
|
||||
input[7] = (operand2/10000) % 10 + '0';
|
||||
input[8] = (operand2/1000) % 10 + '0';
|
||||
input[9] = (operand2/100) % 10 + '0';
|
||||
input[10] = (operand2/10) % 10 + '0';
|
||||
input[11] = operand2 % 10 + '0';
|
||||
|
||||
for(i = 0; i < 4; ++i) {
|
||||
if(input[7 + i] == '0') {
|
||||
input[7 + i] = ' ';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
calculate(void)
|
||||
{
|
||||
operand2 = operand1;
|
||||
input_to_operand1();
|
||||
switch(op) {
|
||||
case OP_ADD:
|
||||
operand2 = operand2 + operand1;
|
||||
break;
|
||||
case OP_SUB:
|
||||
operand2 = operand2 - operand1;
|
||||
break;
|
||||
case OP_MUL:
|
||||
operand2 = operand2 * operand1;
|
||||
break;
|
||||
case OP_DIV:
|
||||
operand2 = operand2 / operand1;
|
||||
break;
|
||||
}
|
||||
operand2_to_input();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(calc_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
ctk_window_new(&window, 12, 7, "Calc");
|
||||
|
||||
CTK_WIDGET_ADD(&window, &inputlabel);
|
||||
CTK_WIDGET_SET_FLAG(&inputlabel, CTK_WIDGET_FLAG_MONOSPACE);
|
||||
|
||||
CTK_WIDGET_ADD(&window, &cbutton);
|
||||
|
||||
CTK_WIDGET_ADD(&window, &divbutton);
|
||||
|
||||
CTK_WIDGET_ADD(&window, &button7);
|
||||
CTK_WIDGET_ADD(&window, &button8);
|
||||
CTK_WIDGET_ADD(&window, &button9);
|
||||
|
||||
CTK_WIDGET_ADD(&window, &mulbutton);
|
||||
|
||||
|
||||
|
||||
CTK_WIDGET_ADD(&window, &button4);
|
||||
CTK_WIDGET_ADD(&window, &button5);
|
||||
CTK_WIDGET_ADD(&window, &button6);
|
||||
|
||||
CTK_WIDGET_ADD(&window, &subbutton);
|
||||
|
||||
CTK_WIDGET_ADD(&window, &button1);
|
||||
CTK_WIDGET_ADD(&window, &button2);
|
||||
CTK_WIDGET_ADD(&window, &button3);
|
||||
|
||||
CTK_WIDGET_ADD(&window, &addbutton);
|
||||
|
||||
CTK_WIDGET_ADD(&window, &button0);
|
||||
|
||||
CTK_WIDGET_ADD(&window, &calcbutton);
|
||||
|
||||
clear_input();
|
||||
|
||||
ctk_window_open(&window);
|
||||
|
||||
while(1) {
|
||||
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if(ev == ctk_signal_keypress) {
|
||||
if((char)data >= '0' &&
|
||||
(char)data <= '9') {
|
||||
add_to_input((char)data);
|
||||
} else if((char)data == ' ') {
|
||||
clear_input();
|
||||
} else if((char)data == '+') {
|
||||
input_to_operand1();
|
||||
op = OP_ADD;
|
||||
} else if((char)data == '-') {
|
||||
input_to_operand1();
|
||||
op = OP_SUB;
|
||||
} else if((char)data == '*') {
|
||||
input_to_operand1();
|
||||
op = OP_MUL;
|
||||
} else if((char)data == '/') {
|
||||
input_to_operand1();
|
||||
op = OP_DIV;
|
||||
} else if((char)data == '=' ||
|
||||
(char)data == CH_ENTER) {
|
||||
calculate();
|
||||
}
|
||||
|
||||
CTK_WIDGET_REDRAW(&inputlabel);
|
||||
} else if(ev == ctk_signal_button_activate) {
|
||||
if(data == (process_data_t)&button0) {
|
||||
add_to_input('0');
|
||||
} else if(data == (process_data_t)&button1) {
|
||||
add_to_input('1');
|
||||
} else if(data == (process_data_t)&button2) {
|
||||
add_to_input('2');
|
||||
} else if(data == (process_data_t)&button3) {
|
||||
add_to_input('3');
|
||||
} else if(data == (process_data_t)&button4) {
|
||||
add_to_input('4');
|
||||
} else if(data == (process_data_t)&button5) {
|
||||
add_to_input('5');
|
||||
} else if(data == (process_data_t)&button6) {
|
||||
add_to_input('6');
|
||||
} else if(data == (process_data_t)&button7) {
|
||||
add_to_input('7');
|
||||
} else if(data == (process_data_t)&button8) {
|
||||
add_to_input('8');
|
||||
} else if(data == (process_data_t)&button9) {
|
||||
add_to_input('9');
|
||||
} else if(data == (process_data_t)&cbutton) {
|
||||
clear_input();
|
||||
} else if(data == (process_data_t)&calcbutton) {
|
||||
calculate();
|
||||
} else if(data == (process_data_t)&addbutton) {
|
||||
input_to_operand1();
|
||||
op = OP_ADD;
|
||||
} else if(data == (process_data_t)&subbutton) {
|
||||
input_to_operand1();
|
||||
op = OP_SUB;
|
||||
} else if(data == (process_data_t)&mulbutton) {
|
||||
input_to_operand1();
|
||||
op = OP_MUL;
|
||||
} else if(data == (process_data_t)&divbutton) {
|
||||
input_to_operand1();
|
||||
op = OP_DIV;
|
||||
}
|
||||
CTK_WIDGET_REDRAW(&inputlabel);
|
||||
} else if(ev == ctk_signal_window_close &&
|
||||
data == (process_data_t)&window) {
|
||||
calc_quit();
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
2
apps/cmdd/Makefile.cmdd
Normal file
2
apps/cmdd/Makefile.cmdd
Normal file
@ -0,0 +1,2 @@
|
||||
APP_SOURCES += cmdd.c
|
||||
DSC_SOURCES +=
|
168
apps/cmdd/cmdd.c
Normal file
168
apps/cmdd/cmdd.c
Normal file
@ -0,0 +1,168 @@
|
||||
#include "contiki.h"
|
||||
#include "psock.h"
|
||||
#include "memb.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct cmdd_state {
|
||||
struct psock s;
|
||||
char inputbuf[8];
|
||||
struct timer timer;
|
||||
int i;
|
||||
char command;
|
||||
};
|
||||
|
||||
#define COMMAND_NONE 0
|
||||
#define COMMAND_PS 1
|
||||
|
||||
MEMB(conns, struct cmdd_state, 1);
|
||||
|
||||
PROCESS(cmdd_process, "Command server");
|
||||
|
||||
static struct uip_udp_conn *udpconn;
|
||||
static char send_udp = 0;
|
||||
static const char *prompt = "contiki> ";
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static char * CC_FASTCALL
|
||||
n(u16_t num, char *ptr)
|
||||
{
|
||||
u16_t d;
|
||||
u8_t a, f;
|
||||
|
||||
if(num == 0) {
|
||||
*ptr = '0';
|
||||
return ptr + 1;
|
||||
} else {
|
||||
f = 0;
|
||||
for(d = 10000; d >= 1; d /= 10) {
|
||||
a = (num / d) % 10;
|
||||
if(f == 1 || a > 0) {
|
||||
*ptr = a + '0';
|
||||
++ptr;
|
||||
f = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
ps_generate(void *state)
|
||||
{
|
||||
struct ek_proc *p = (struct ek_proc *)state;
|
||||
char *ptr = (char *)uip_appdata;
|
||||
|
||||
ptr = n(EK_PROC_ID(p), ptr);
|
||||
|
||||
*ptr++ = ' ';
|
||||
strncpy(ptr, p->name, 40);
|
||||
ptr += strlen(p->name);
|
||||
*ptr++ = '\n';
|
||||
|
||||
return ptr - (char *)uip_appdata;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(handle_connection(struct cmdd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->s);
|
||||
|
||||
while(1) {
|
||||
PSOCK_SEND(&s->s, prompt, strlen(prompt));
|
||||
PSOCK_WAIT_UNTIL(&s->s, PSOCK_NEWDATA(&s->s) ||
|
||||
s->command != COMMAND_NONE);
|
||||
|
||||
if(PSOCK_NEWDATA(&s->s)) {
|
||||
PSOCK_READTO(&s->s, '\n');
|
||||
if(strncmp(s->inputbuf, "quit", 4) == 0) {
|
||||
PSOCK_CLOSE_EXIT(&s->s);
|
||||
memb_free(&conns, s);
|
||||
tcp_markconn(uip_conn, NULL);
|
||||
} else if(strncmp(s->inputbuf, "ps", 2) == 0) {
|
||||
PSOCK_GENERATOR_SEND(&s->s, ps_generate, ek_procs);
|
||||
|
||||
for(s->i = 0; s->i < 40; s->i++) {
|
||||
if(ek_process(s->i) != NULL) {
|
||||
PSOCK_GENERATOR_SEND(&s->s, ps_generate, ek_process(s->i));
|
||||
}
|
||||
}
|
||||
} else if(strncmp(s->inputbuf, "send", 4) == 0) {
|
||||
send_udp = 1;
|
||||
PSOCK_WAIT_UNTIL(&s->s, send_udp == 0);
|
||||
} else {
|
||||
PSOCK_SEND(&s->s, "?\n", 2);
|
||||
}
|
||||
} else {
|
||||
switch(s->command) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
PSOCK_END(&s->s);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
appcall(void *state)
|
||||
{
|
||||
struct cmdd_state *s = (struct cmdd_state *)state;
|
||||
|
||||
if(uip_udpconnection()) {
|
||||
if(send_udp) {
|
||||
uip_udp_send(8);
|
||||
send_udp = 0;
|
||||
}
|
||||
} else {
|
||||
if(uip_closed() || uip_timedout() || uip_aborted()) {
|
||||
if(state != NULL) {
|
||||
memb_free(&conns, state);
|
||||
}
|
||||
} else if(uip_connected()) {
|
||||
s = (struct cmdd_state *)memb_alloc(&conns);
|
||||
if(s == NULL) {
|
||||
uip_abort();
|
||||
} else {
|
||||
tcp_markconn(uip_conn, s);
|
||||
PSOCK_INIT(&s->s, s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
timer_set(&s->timer, CLOCK_SECOND * 60);
|
||||
handle_connection(s);
|
||||
}
|
||||
} else if(s != NULL) {
|
||||
if(uip_poll()) {
|
||||
if(timer_expired(&s->timer)) {
|
||||
memb_free(&conns, state);
|
||||
uip_abort();
|
||||
return;
|
||||
}
|
||||
}
|
||||
timer_reset(&s->timer);
|
||||
handle_connection(s);
|
||||
} else {
|
||||
uip_abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(cmdd_process, ev, data)
|
||||
{
|
||||
u16_t ipaddr[2];
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
tcp_listen(HTONS(6581));
|
||||
memb_init(&conns);
|
||||
uip_ipaddr(ipaddr, 255,255,255,255);
|
||||
udpconn = udp_new(ipaddr, HTONS(6712), NULL);
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
if(ev == tcpip_event) {
|
||||
appcall(data);
|
||||
} else if(ev == PROCESS_EVENT_EXIT) {
|
||||
process_exit(&cmdd_process);
|
||||
LOADER_UNLOAD();
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
10
apps/cmdd/cmdd.h
Normal file
10
apps/cmdd/cmdd.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef __CMDD_H__
|
||||
#define __CMDD_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
/*EK_PROCESS_INIT(cmdd_init, arg);*/
|
||||
|
||||
PROCESS_NAME(cmdd_process);
|
||||
|
||||
#endif /* __CMDD_H__ */
|
2
apps/dhcp/Makefile.dhcp
Normal file
2
apps/dhcp/Makefile.dhcp
Normal file
@ -0,0 +1,2 @@
|
||||
APP_SOURCES += dhcp.c dhcpc.c
|
||||
DSC_SOURCES += dhcp-dsc.c
|
74
apps/dhcp/dhcp-dsc.c
Normal file
74
apps/dhcp/dhcp-dsc.c
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: dhcp-dsc.c,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sys/dsc.h"
|
||||
|
||||
extern struct ctk_icon dhcp_icon;
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
DSC(dhcp_dsc,
|
||||
"Obtain IP address automatically",
|
||||
"dhcp.prg",
|
||||
dhcp_process,
|
||||
&dhcp_icon);
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if CTK_CONF_ICON_BITMAPS
|
||||
static unsigned char tcpipconficon_bitmap[3*3*8] = {
|
||||
0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
|
||||
0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
|
||||
0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
|
||||
|
||||
0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
|
||||
0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
|
||||
0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_BITMAPS */
|
||||
|
||||
#if CTK_CONF_ICON_TEXTMAPS
|
||||
static char tcpipconficon_textmap[9] = {
|
||||
'T', 'C', 'P',
|
||||
'/', 'I', 'P',
|
||||
'C', 'f', 'g'
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_TEXTMAPS */
|
||||
|
||||
#if CTK_CONF_ICONS
|
||||
static struct ctk_icon dhcp_icon =
|
||||
{CTK_ICON("DHCP client", tcpipconficon_bitmap, tcpipconficon_textmap)};
|
||||
#endif /* CTK_CONF_ICONS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
42
apps/dhcp/dhcp-dsc.h
Normal file
42
apps/dhcp/dhcp-dsc.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: dhcp-dsc.h,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __DHCP_DSC_H__
|
||||
#define __DHCP_DSC_H__
|
||||
|
||||
#include "sys/dsc.h"
|
||||
|
||||
DSC_HEADER(dhcp_dsc);
|
||||
|
||||
#endif /* __DHCP_DSC_H__ */
|
153
apps/dhcp/dhcp.c
Normal file
153
apps/dhcp/dhcp.c
Normal file
@ -0,0 +1,153 @@
|
||||
#include "contiki-net.h"
|
||||
#include "ctk/ctk.h"
|
||||
#include "net/dhcpc.h"
|
||||
|
||||
|
||||
|
||||
PROCESS(dhcp_process, "DHCP");
|
||||
|
||||
static struct ctk_window window;
|
||||
static struct ctk_button getbutton =
|
||||
{CTK_BUTTON(0, 0, 16, "Request address")};
|
||||
static struct ctk_label statuslabel =
|
||||
{CTK_LABEL(0, 1, 16, 1, "")};
|
||||
|
||||
|
||||
static struct ctk_label ipaddrlabel =
|
||||
{CTK_LABEL(0, 3, 10, 1, "IP address")};
|
||||
static char ipaddr[17];
|
||||
static struct ctk_textentry ipaddrentry =
|
||||
{CTK_LABEL(11, 3, 16, 1, ipaddr)};
|
||||
static struct ctk_label netmasklabel =
|
||||
{CTK_LABEL(0, 4, 10, 1, "Netmask")};
|
||||
static char netmask[17];
|
||||
static struct ctk_textentry netmaskentry =
|
||||
{CTK_LABEL(11, 4, 16, 1, netmask)};
|
||||
static struct ctk_label gatewaylabel =
|
||||
{CTK_LABEL(0, 5, 10, 1, "Gateway")};
|
||||
static char gateway[17];
|
||||
static struct ctk_textentry gatewayentry =
|
||||
{CTK_LABEL(11, 5, 16, 1, gateway)};
|
||||
static struct ctk_label dnsserverlabel =
|
||||
{CTK_LABEL(0, 6, 10, 1, "DNS server")};
|
||||
static char dnsserver[17];
|
||||
static struct ctk_textentry dnsserverentry =
|
||||
{CTK_LABEL(11, 6, 16, 1, dnsserver)};
|
||||
|
||||
enum {
|
||||
SHOWCONFIG
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
set_statustext(char *text)
|
||||
{
|
||||
ctk_label_set_text(&statuslabel, text);
|
||||
CTK_WIDGET_REDRAW(&statuslabel);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static char *
|
||||
makebyte(u8_t byte, char *str)
|
||||
{
|
||||
if(byte >= 100) {
|
||||
*str++ = (byte / 100 ) % 10 + '0';
|
||||
}
|
||||
if(byte >= 10) {
|
||||
*str++ = (byte / 10) % 10 + '0';
|
||||
}
|
||||
*str++ = (byte % 10) + '0';
|
||||
|
||||
return str;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
makeaddr(u16_t *addr, char *str)
|
||||
{
|
||||
str = makebyte(HTONS(addr[0]) >> 8, str);
|
||||
*str++ = '.';
|
||||
str = makebyte(HTONS(addr[0]) & 0xff, str);
|
||||
*str++ = '.';
|
||||
str = makebyte(HTONS(addr[1]) >> 8, str);
|
||||
*str++ = '.';
|
||||
str = makebyte(HTONS(addr[1]) & 0xff, str);
|
||||
*str++ = 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
makestrings(void)
|
||||
{
|
||||
u16_t addr[2], *addrptr;
|
||||
|
||||
uip_gethostaddr(addr);
|
||||
makeaddr(addr, ipaddr);
|
||||
|
||||
uip_getnetmask(addr);
|
||||
makeaddr(addr, netmask);
|
||||
|
||||
uip_getdraddr(addr);
|
||||
makeaddr(addr, gateway);
|
||||
|
||||
addrptr = resolv_getserver();
|
||||
if(addrptr != NULL) {
|
||||
makeaddr(addrptr, dnsserver);
|
||||
}
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(dhcp_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
ctk_window_new(&window, 28, 7, "DHCP");
|
||||
|
||||
CTK_WIDGET_ADD(&window, &getbutton);
|
||||
CTK_WIDGET_ADD(&window, &statuslabel);
|
||||
CTK_WIDGET_ADD(&window, &ipaddrlabel);
|
||||
CTK_WIDGET_ADD(&window, &ipaddrentry);
|
||||
CTK_WIDGET_ADD(&window, &netmasklabel);
|
||||
CTK_WIDGET_ADD(&window, &netmaskentry);
|
||||
CTK_WIDGET_ADD(&window, &gatewaylabel);
|
||||
CTK_WIDGET_ADD(&window, &gatewayentry);
|
||||
CTK_WIDGET_ADD(&window, &dnsserverlabel);
|
||||
CTK_WIDGET_ADD(&window, &dnsserverentry);
|
||||
|
||||
CTK_WIDGET_FOCUS(&window, &getbutton);
|
||||
|
||||
ctk_window_open(&window);
|
||||
dhcpc_init(uip_ethaddr.addr, sizeof(uip_ethaddr.addr));
|
||||
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if(ev == ctk_signal_widget_activate) {
|
||||
if(data == (process_data_t)&getbutton) {
|
||||
dhcpc_request();
|
||||
set_statustext("Requesting...");
|
||||
}
|
||||
} else if(ev == tcpip_event) {
|
||||
dhcpc_appcall(ev, data);
|
||||
} else if(ev == PROCESS_EVENT_EXIT ||
|
||||
ev == ctk_signal_window_close) {
|
||||
ctk_window_close(&window);
|
||||
process_exit(&dhcp_process);
|
||||
LOADER_UNLOAD();
|
||||
} else if(ev == SHOWCONFIG) {
|
||||
makestrings();
|
||||
ctk_window_redraw(&window);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
dhcpc_configured(const struct dhcpc_state *s)
|
||||
{
|
||||
uip_sethostaddr(s->ipaddr);
|
||||
uip_setnetmask(s->netmask);
|
||||
uip_setdraddr(s->default_router);
|
||||
resolv_conf(s->dnsaddr);
|
||||
set_statustext("Configured.");
|
||||
process_post(PROCESS_CURRENT(), SHOWCONFIG, NULL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
0
apps/dhcp/dhcp.h
Normal file
0
apps/dhcp/dhcp.h
Normal file
2
apps/directory/Makefile.directory
Normal file
2
apps/directory/Makefile.directory
Normal file
@ -0,0 +1,2 @@
|
||||
APP_SOURCES += directory.c
|
||||
DSC_SOURCES += directory-dsc.c
|
74
apps/directory/directory-dsc.c
Normal file
74
apps/directory/directory-dsc.c
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: directory-dsc.c,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sys/dsc.h"
|
||||
|
||||
extern struct ctk_icon directory_icon;
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
DSC(directory_dsc,
|
||||
"Directory reader",
|
||||
"directory.prg",
|
||||
directory_process,
|
||||
&directory_icon);
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if CTK_CONF_ICON_BITMAPS
|
||||
static unsigned char directoryicon_bitmap[3*3*8] = {
|
||||
0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
|
||||
0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
|
||||
0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
|
||||
|
||||
0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
|
||||
0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
|
||||
0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
|
||||
|
||||
0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
|
||||
0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
|
||||
0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_BITMAPS */
|
||||
|
||||
#if CTK_CONF_ICON_TEXTMAPS
|
||||
static char directoryicon_textmap[9] = {
|
||||
'+', '-', '+',
|
||||
'|', 'o', '|',
|
||||
'+', '-', '+'
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_TEXTMAPS */
|
||||
|
||||
#if CTK_CONF_ICONS
|
||||
static struct ctk_icon directory_icon =
|
||||
{CTK_ICON("Directory", directoryicon_bitmap, directoryicon_textmap)};
|
||||
#endif /* CTK_CONF_ICONS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
42
apps/directory/directory-dsc.h
Normal file
42
apps/directory/directory-dsc.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: directory-dsc.h,v 1.1 2006/06/17 22:41:10 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __DIRECTORY_DSC_H__
|
||||
#define __DIRECTORY_DSC_H__
|
||||
|
||||
#include "sys/dsc.h"
|
||||