Skip to content

Commit

Permalink
Added SmartApp projects to Contiki-2.x (post-2.6).
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Kovatsch committed Oct 9, 2012
1 parent a3e5637 commit 28139eb
Show file tree
Hide file tree
Showing 58 changed files with 9,318 additions and 33 deletions.
2 changes: 1 addition & 1 deletion core/dev/cc2420.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const struct radio_driver cc2420_driver =
cc2420_transmit,
cc2420_send,
cc2420_read,
/* cc2420_set_channel, */
cc2420_set_channel,
/* detected_energy, */
cc2420_cca,
cc2420_receiving_packet,
Expand Down
2 changes: 1 addition & 1 deletion core/dev/cc2520.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const struct radio_driver cc2520_driver =
cc2520_transmit,
cc2520_send,
cc2520_read,
/* cc2520_set_channel, */
cc2520_set_channel,
/* detected_energy, */
cc2520_cca,
cc2520_receiving_packet,
Expand Down
7 changes: 7 additions & 0 deletions core/dev/nullradio.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,20 @@ off(void)
return 0;
}
/*---------------------------------------------------------------------------*/
static void
null_set_channel(unsigned short ch)
{
/* Dummy for a uniform API. */
}
/*---------------------------------------------------------------------------*/
const struct radio_driver nullradio_driver =
{
init,
prepare,
transmit,
send,
read,
null_set_channel,
channel_clear,
receiving_packet,
pending_packet,
Expand Down
3 changes: 3 additions & 0 deletions core/dev/radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ struct radio_driver {
/** Read a received packet into a buffer. */
int (* read)(void *buf, unsigned short buf_len);

/** Set the radio channel, e.g., 11-26 for 2.4GHz. */
void (* set_channel)(unsigned short ch);

/** Perform a Clear-Channel Assessment (CCA) to find out if there is
a packet in the air or not. */
int (* channel_clear)(void);
Expand Down
2 changes: 1 addition & 1 deletion cpu/arm/at91sam7s/Makefile.at91sam7s
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ symbols.c: $(CORE)

else
%.$(TARGET): %-nosyms.$(TARGET)
ln -sf $< $@
cp $< $@
endif

empty-symbols.c:
Expand Down
11 changes: 6 additions & 5 deletions cpu/avr/radio/rf230bb/rf230bb.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ const struct radio_driver rf230_driver =
rf230_transmit,
rf230_send,
rf230_read,
rf230_set_channel,
rf230_cca,
rf230_receiving_packet,
rf230_pending_packet,
Expand Down Expand Up @@ -1169,17 +1170,17 @@ rf230_get_channel(void)
}
/*---------------------------------------------------------------------------*/
void
rf230_set_channel(uint8_t c)
rf230_set_channel(unsigned short ch)
{
/* Wait for any transmission to end. */
PRINTF("rf230: Set Channel %u\n",c);
PRINTF("rf230: Set Channel %u\n", ch);
rf230_waitidle();
channel=c;
hal_subregister_write(SR_CHANNEL, c);
channel = ch;
hal_subregister_write(SR_CHANNEL, ch);
}
/*---------------------------------------------------------------------------*/
void
rf230_listen_channel(uint8_t c)
rf230_listen_channel(unsigned short c)
{
/* Same as set channel but forces RX_ON state for sniffer or energy scan */
// PRINTF("rf230: Listen Channel %u\n",c);
Expand Down
4 changes: 2 additions & 2 deletions cpu/avr/radio/rf230bb/rf230bb.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ void rf230_warm_reset(void);
void rf230_start_sneeze(void);
//int rf230_on(void);
//int rf230_off(void);
void rf230_set_channel(uint8_t channel);
void rf230_listen_channel(uint8_t channel);
void rf230_set_channel(unsigned short channel);
void rf230_listen_channel(unsigned short channel);
uint8_t rf230_get_channel(void);
void rf230_set_pan_addr(unsigned pan,unsigned addr,const uint8_t ieee_addr[8]);
void rf230_set_txpower(uint8_t power);
Expand Down
11 changes: 3 additions & 8 deletions cpu/cc2430/dev/cc2430_rf.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,11 @@ flush_rx()
/* channel freqdiv = (2048 + FSCTRL(9:0)) / 4
freq = (2048 + FSCTRL(9:0)) MHz */

int8_t
cc2430_rf_channel_set(uint8_t channel)
void
cc2430_rf_channel_set(unsigned short channel)
{
uint16_t freq;

if((channel < 11) || (channel > 26)) {
return -1;
}

cc2430_rf_command(ISSTOP); /*make sure CSP is not running*/
cc2430_rf_command(ISRFOFF);
/* Channel values: 11-26 */
Expand All @@ -198,8 +194,6 @@ cc2430_rf_channel_set(uint8_t channel)
cc2430_rf_command(ISRXON);

rf_channel = channel;

return (int8_t) channel;
}
/*---------------------------------------------------------------------------*/
uint8_t
Expand Down Expand Up @@ -693,6 +687,7 @@ const struct radio_driver cc2430_rf_driver =
transmit,
send,
read,

channel_clear,
receiving_packet,
pending_packet,
Expand Down
2 changes: 1 addition & 1 deletion cpu/cc2430/dev/cc2430_rf.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ typedef enum rf_address_mode_t
extern const struct radio_driver cc2430_rf_driver;

void cc2430_rf_command(uint8_t command);
int8_t cc2430_rf_channel_set(uint8_t channel);
void cc2430_rf_channel_set(unsigned short channel);
uint8_t cc2430_rf_channel_get();
uint8_t cc2430_rf_power_set(uint8_t new_power);
void cc2430_rf_set_addr(unsigned pan, unsigned addr, const uint8_t *ieee_addr);
Expand Down
4 changes: 2 additions & 2 deletions cpu/mc1322x/Makefile.mc1322x
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ CFLAGS += -I$(OBJECTDIR) -I$(CONTIKI_CPU)/board -DBOARD=$(TARGET)

$(OBJECTDIR)/board.h: $(OBJECTDIR)
ifeq ($(HOST_OS),Windows)
ln -f $(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h
cp $(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h
else
ln -sf ../$(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h
cp $(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h
endif


Expand Down
4 changes: 4 additions & 0 deletions examples/er-rest-example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ WITH_UIP6=1
# for some platforms
UIP_CONF_IPV6=1

# radio configuration
CFLAGS += -DRF_CHANNEL=20
CFLAGS += -DIEEE802154_CONF_PANID=0xBEEF

# variable for this Makefile
# configure CoAP implementation (3|7) (er-coap-07 also supports CoAP draft 08)
WITH_COAP=7
Expand Down
4 changes: 4 additions & 0 deletions examples/er-rest-example/project-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

#define SICSLOWPAN_CONF_FRAG 1


#undef IEEE802154_CONF_PANID
#define IEEE802154_CONF_PANID 0xBEEF

/* Disabling RDC for demo purposes. Core updates often require more memory. */
/* For projects, optimize memory and enable RDC again. */
#undef NETSTACK_CONF_RDC
Expand Down
3 changes: 3 additions & 0 deletions examples/ipv6/rpl-border-router/project-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#ifndef __PROJECT_ROUTER_CONF_H__
#define __PROJECT_ROUTER_CONF_H__

#undef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC nullrdc_driver

#ifndef UIP_FALLBACK_INTERFACE
#define UIP_FALLBACK_INTERFACE rpl_interface
#endif
Expand Down
2 changes: 1 addition & 1 deletion platform/avr-atmega128rfa1/contiki-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ uint8_t i;
NETSTACK_NETWORK.init();

#if ANNOUNCE_BOOT
PRINTA("%s %s, channel %u , check rate %u Hz tx power %u\n",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(),
PRINTA("%s %s, channel %u, panid 0x%X, check rate %u Hz tx power %u\n",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(), IEEE802154_PANID,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:NETSTACK_RDC.channel_check_interval()),
rf230_get_txpower());
#if UIP_CONF_IPV6_RPL
Expand Down
2 changes: 1 addition & 1 deletion platform/avr-raven/contiki-raven-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ uint8_t i;
NETSTACK_NETWORK.init();

#if ANNOUNCE_BOOT
PRINTA("%s %s, channel %u , check rate %u Hz tx power %u\n",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(),
PRINTA("%s %s, channel %u, panid 0x%X, check rate %u Hz tx power %u\n",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(), IEEE802154_PANID,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:NETSTACK_RDC.channel_check_interval()),
rf230_get_txpower());
#if UIP_CONF_IPV6_RPL
Expand Down
2 changes: 1 addition & 1 deletion platform/avr-ravenusb/contiki-raven-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ uint16_t p=(uint16_t)&__bss_end;

#if ANNOUNCE
PRINTA("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n\r",tmp_addr.u8[0],tmp_addr.u8[1],tmp_addr.u8[2],tmp_addr.u8[3],tmp_addr.u8[4],tmp_addr.u8[5],tmp_addr.u8[6],tmp_addr.u8[7]);
PRINTA("%s %s, channel %u",NETSTACK_MAC.name, NETSTACK_RDC.name,rf230_get_channel());
PRINTA("%s %s, channel %u, panid 0x%X",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(), IEEE802154_PANID);
if (NETSTACK_RDC.channel_check_interval) {
unsigned short tmp;
tmp=CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval == 0 ? 1:\
Expand Down
4 changes: 4 additions & 0 deletions platform/minimal-net/contiki-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ typedef unsigned short uip_stats_t;

#endif

#ifndef RF_CHANNEL
#define RF_CHANNEL 26
#endif /* RF_CHANNEL */

#define UIP_CONF_MAX_LISTENPORTS 40
#define UIP_CONF_MAX_CONNECTIONS 40
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
Expand Down
2 changes: 2 additions & 0 deletions platform/redbee-econotag/contiki-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ typedef unsigned long rtimer_clock_t;

#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0

#ifndef IEEE802154_CONF_PANID
#define IEEE802154_CONF_PANID 0xABCD
#endif /* IEEE802154_CONF_PANID */

#define PROFILE_CONF_ON 0
#define ENERGEST_CONF_ON 0
Expand Down
5 changes: 3 additions & 2 deletions platform/redbee-econotag/contiki-mc1322x-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,12 @@ uint32_t p=(uint32_t)&__heap_end__-4;
NETSTACK_MAC.init();
NETSTACK_NETWORK.init();

printf("%s %s, channel check rate %lu Hz, radio channel %u\n",
printf("%s %s, channel check rate %lu Hz, radio channel %u, panid 0x%X\n",
NETSTACK_MAC.name, NETSTACK_RDC.name,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
NETSTACK_RDC.channel_check_interval()),
RF_CHANNEL);
RF_CHANNEL,
IEEE802154_PANID);

process_start(&tcpip_process, NULL);

Expand Down
2 changes: 0 additions & 2 deletions platform/sky/contiki-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@

#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0

#define IEEE802154_CONF_PANID 0xABCD

#define SHELL_VARS_CONF_RAM_BEGIN 0x1100
#define SHELL_VARS_CONF_RAM_END 0x2000

Expand Down
5 changes: 3 additions & 2 deletions platform/sky/contiki-sky-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,12 @@ main(int argc, char **argv)
NETSTACK_MAC.init();
NETSTACK_NETWORK.init();

printf("%s %s, channel check rate %lu Hz, radio channel %u\n",
printf("%s %s, channel check rate %lu Hz, radio channel %u, panid 0x%X\n",
NETSTACK_MAC.name, NETSTACK_RDC.name,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
NETSTACK_RDC.channel_check_interval()),
RF_CHANNEL);
RF_CHANNEL,
IEEE802154_PANID);

process_start(&tcpip_process, NULL);

Expand Down
88 changes: 88 additions & 0 deletions projects/er-rest-example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
all: er-example-server er-example-client
# Use this target explicitly if requried: er-plugtest-server

CONTIKI=../..
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"

# for static routing, if enabled
ifneq ($(TARGET), minimal-net)
ifneq ($(TARGET), native)
ifneq ($(findstring avr,$(TARGET)), avr)
PROJECT_SOURCEFILES += static-routing.c
endif
endif
endif

# variable for root Makefile.include
WITH_UIP6=1
# for some platforms
UIP_CONF_IPV6=1

# variable for this Makefile
# configure CoAP implementation (3|7) (er-coap-07 also supports CoAP draft 08)
WITH_COAP=7

# new variable since slip-radio
ifneq ($(TARGET), minimal-net)
UIP_CONF_RPL=1
else
# minimal-net does not support RPL under Linux and is mostly used to test CoAP only
${info INFO: compiling without RPL}
UIP_CONF_RPL=0
CFLAGS += -DUIP_CONF_ND6_DEF_MAXDADNS=0
CFLAGS += -DHARD_CODED_ADDRESS=\"fdfd::10\"
CFLAGS += -DUIP_CONF_BUFFER_SIZE=1280
endif

# linker optimizations
SMALL=1

# REST framework, requires WITH_COAP
ifeq ($(WITH_COAP), 7)
${info INFO: compiling with CoAP-08}
CFLAGS += -DWITH_COAP=7
CFLAGS += -DREST=coap_rest_implementation
CFLAGS += -DUIP_CONF_TCP=0
APPS += er-coap-07
else ifeq ($(WITH_COAP), 3)
${info INFO: compiling with CoAP-03}
CFLAGS += -DWITH_COAP=3
CFLAGS += -DREST=coap_rest_implementation
CFLAGS += -DUIP_CONF_TCP=0
APPS += er-coap-03
else
${info INFO: compiling with HTTP}
CFLAGS += -DWITH_HTTP
CFLAGS += -DREST=http_rest_implementation
CFLAGS += -DUIP_CONF_TCP=1
APPS += er-http-engine
endif

APPS += erbium

# optional rules to get assembly
#CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
#CUSTOM_RULE_S_TO_OBJECTDIR_O = 1

include $(CONTIKI)/Makefile.include

# optional rules to get assembly
#$(OBJECTDIR)/%.o: asmdir/%.S
# $(CC) $(CFLAGS) -MMD -c $< -o $@
# @$(FINALIZE_DEPENDENCY)
#
#asmdir/%.S: %.c
# $(CC) $(CFLAGS) -MMD -S $< -o $@

# border router rules
$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c
(cd $(CONTIKI)/tools && $(MAKE) tunslip6)

connect-router: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 aaaa::1/64

connect-router-cooja: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 aaaa::1/64

tap0up:
sudo ip address add fdfd::1/64 dev tap0
Loading

0 comments on commit 28139eb

Please sign in to comment.