35 #include "dev/ds2411/ds2411.h"
39 #include "dev/uart1.h"
40 #include "dev/watchdog.h"
42 #include "lib/random.h"
52 #include "sys/node-id.h"
59 #ifndef UIP_ROUTER_MODULE
60 #ifdef UIP_CONF_ROUTER_MODULE
61 #define UIP_ROUTER_MODULE UIP_CONF_ROUTER_MODULE
63 #define UIP_ROUTER_MODULE rimeroute
67 extern const struct uip_router UIP_ROUTER_MODULE;
70 #if DCOSYNCH_CONF_ENABLED
71 static struct timer mgt_timer;
73 extern int msp430_dco_required;
82 #include "net/ipv4/uip-fw-drv.h"
87 {
UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
91 #define UIP_OVER_MESH_CHANNEL 8
93 static uint8_t is_gateway;
96 #ifdef EXPERIMENT_SETUP
97 #include "experiment-setup.h"
102 #define PRINTF(...) printf(__VA_ARGS__)
107 void init_platform(
void);
112 force_float_inclusion()
114 extern int __fixsfsi;
115 extern int __floatsisf;
119 return __fixsfsi + __floatsisf + __mulsf3 + __subsf3;
128 force_inclusion(
int d1,
int d2)
130 snprintf(
NULL, 0,
"%d", d1 % d2);
140 memset(&addr, 0,
sizeof(linkaddr_t));
142 memcpy(addr.u8, ds2411_id,
sizeof(addr.u8));
145 for(i = 0; i <
sizeof(linkaddr_t); ++i) {
146 addr.u8[i] = ds2411_id[7 - i];
149 addr.u8[0] = node_id & 0xff;
150 addr.u8[1] = node_id >> 8;
154 PRINTF(
"Rime started with address ");
155 for(i = 0; i <
sizeof(addr.u8) - 1; i++) {
156 PRINTF(
"%d.", addr.u8[i]);
158 PRINTF(
"%d\n", addr.u8[i]);
161 #if !PROCESS_CONF_NO_PROCESS_NAMES
163 print_processes(
struct process *
const processes[])
167 while(*processes !=
NULL) {
168 printf(
" '%s'", (*processes)->name);
181 PRINTF(
"%d.%d: making myself the IP network gateway.\n\n",
183 PRINTF(
"IPv4 address of the gateway: %d.%d.%d.%d\n\n",
186 uip_over_mesh_make_announced_gateway();
193 start_autostart_processes()
195 #if !PROCESS_CONF_NO_PROCESS_NAMES
196 print_processes(autostart_processes);
198 autostart_start(autostart_processes);
205 NETSTACK_NETWORK.init();
210 PRINTF(
"Tentative link-local IPv6 address ");
214 lladdr = uip_ds6_get_link_local(-1);
215 for(i = 0; i < 7; ++i) {
216 PRINTF(
"%02x%02x:", lladdr->ipaddr.u8[i * 2],
217 lladdr->ipaddr.u8[i * 2 + 1]);
219 PRINTF(
"%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
223 if(!UIP_CONF_IPV6_RPL) {
229 PRINTF(
"Tentative global IPv6 address ");
230 for(i = 0; i < 7; ++i) {
232 ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
235 ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
241 start_network_layer()
246 start_autostart_processes();
251 #if WITH_TINYOS_AUTO_IDS
252 uint16_t TOS_NODE_ID = 0x1234;
253 uint16_t TOS_LOCAL_ADDRESS = 0x1234;
256 main(
int argc,
char **argv)
275 ds2411_id[2] &= 0xfe;
289 ENERGEST_ON(ENERGEST_TYPE_CPU);
291 #if WITH_TINYOS_AUTO_IDS
292 node_id = TOS_NODE_ID;
299 #ifdef IEEE_802154_MAC_ADDRESS
301 uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
302 memcpy(ds2411_id, ieee,
sizeof(
uip_lladdr.addr));
303 ds2411_id[7] = node_id & 0xff;
333 memset(longaddr, 0,
sizeof(longaddr));
335 PRINTF(
"MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
336 longaddr[0], longaddr[1], longaddr[2], longaddr[3],
337 longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
339 cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
342 PRINTF(CONTIKI_VERSION_STRING
" started. ");
344 PRINTF(
"Node id is set to %u.\n", node_id);
346 PRINTF(
"Node id is not set.\n");
364 PRINTF(
"%s %s %s, channel check rate %lu Hz, radio channel %u, CCA threshold %i\n",
365 NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
366 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
367 NETSTACK_RDC.channel_check_interval()),
369 CC2420_CONF_CCA_THRESH);
375 NETSTACK_NETWORK.init();
377 PRINTF(
"%s %s %s, channel check rate %lu Hz, radio channel %u\n",
378 NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
379 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
380 NETSTACK_RDC.channel_check_interval()),
381 CC2420_CONF_CHANNEL);
384 #if !WITH_UIP && !WITH_UIP6
391 #if TIMESYNCH_CONF_ENABLED
401 slip_set_input_callback(set_gateway);
404 uip_ipaddr_t hostaddr,
netmask;
415 uip_over_mesh_set_net(&hostaddr, &netmask);
417 uip_over_mesh_set_gateway_netif(&slipif);
419 uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
420 PRINTF(
"uIP started with IP address %d.%d.%d.%d\n",
427 NETSTACK_LLSEC.bootstrap(start_network_layer);
432 #if DCOSYNCH_CONF_ENABLED
453 static unsigned long irq_energest = 0;
455 #if DCOSYNCH_CONF_ENABLED
461 #if CC2420_CONF_SFD_TIMESTAMPS
462 cc2420_arch_sfd_init();
468 ENERGEST_OFF(ENERGEST_TYPE_CPU);
469 ENERGEST_ON(ENERGEST_TYPE_LPM);
473 energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
476 if (msp430_dco_required) {
477 _BIS_SR(GIE | CPUOFF);
479 _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF);
489 irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
492 ENERGEST_OFF(ENERGEST_TYPE_LPM);
493 ENERGEST_ON(ENERGEST_TYPE_CPU);
502 log_message(
char *m1,
char *m2)
504 printf(
"%s%s\n", m1, m2);
Coffee architecture-dependent header for the Tmote Sky platform.
void uart1_init(unsigned long ubr)
Initalize the RS232 port.
int serial_line_input_byte(unsigned char c)
Get one byte of input from the serial driver.
#define uip_sethostaddr(addr)
Set the IP address of this host.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
uIP packet forwarding header file.
int process_nevents(void)
Number of events waiting to be processed.
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
802.15.4 frame creation and parsing functions
#define UIP_FW_NETIF(ip1, ip2, ip3, ip4, nm1, nm2, nm3, nm4, outputfunc)
Instantiating macro for a uIP network interface.
Representation of a uIP network interface.
#define LEDS_RED
LED1 (Red) -> PC0.
Unicast address structure.
void timesynch_init(void)
Initialize the timesynch module.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
uip_ipaddr_t ipaddr
The IP address of this interface.
Header file for the uIP TCP/IP stack.
void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr)
set the last 64 bits of an IP address based on the MAC address
void rtimer_init(void)
Initialize the real-time scheduler.
Network interface and stateless autoconfiguration (RFC 4862)
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
#define NULL
The null pointer.
void uip_log(char *msg)
Print out a uIP log message.
Header file for tunnelling uIP over Rime mesh
void clock_init(void)
Initialize the clock library.
int main(void)
This is main...
void process_init(void)
Initialize the process module.
Header file for the Rime stack
void timesynch_set_authority_level(int level)
Set the authority level of the current time.
#define LEDS_GREEN
LED3 (Green) -> PC2.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
void random_init(unsigned short seed)
Seed the cc2430 random number generator.
void slip_arch_init(unsigned long ubr)
Initalize the RS232 port and the SLIP driver.
void watchdog_stop(void)
In watchdog mode, the WDT can not be stopped.
Generic serial I/O process header filer.
void watchdog_periodic(void)
Writes the WDT clear sequence.
Header file for module for automatically starting and exiting a list of processes.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
void ctimer_init(void)
Initialize the callback timer library.
#define uip_ipaddr_to_quad(a)
Convert an IP address to four bytes separated by commas.
void uip_init(void)
uIP initialization function.
void uip_fw_default(struct uip_fw_netif *netif)
Register a default network interface.
uip_ipaddr_t netmask
The netmask of the interface.
void process_start(struct process *p, process_data_t data)
Start a process.
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
int process_run(void)
Run the system once - call poll handlers and process one event.
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
Header for the Coffee file system.
#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.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
#define uip_setnetmask(addr)
Set the netmask.
void timer_reset(struct timer *t)
Reset the timer with the same interval.
Include file for the Contiki low-layer network stack (NETSTACK)
#define CLOCK_SECOND
A second, measured in system clock time.