36 #include "dev/button-sensor.h"
38 #include "dev/flash.h"
42 #include "dev/uart1.h"
43 #include "dev/watchdog.h"
45 #include "lib/random.h"
46 #include "lib/sensors.h"
52 #include "sys/node-id.h"
54 #include "duty-cycle-scroller.h"
56 #if NETSTACK_CONF_WITH_IPV6
64 #define PRINTF(...) printf(__VA_ARGS__)
69 extern unsigned char node_mac[8];
79 memset(&addr, 0,
sizeof(linkaddr_t));
80 #if NETSTACK_CONF_WITH_IPV6
81 memcpy(addr.u8, node_mac,
sizeof(addr.u8));
84 for(i = 0; i <
sizeof(linkaddr_t); ++i) {
85 addr.u8[i] = node_mac[7 - i];
88 addr.u8[0] = node_id & 0xff;
89 addr.u8[1] = node_id >> 8;
94 for(i = 0; i <
sizeof(addr.u8) - 1; i++) {
95 printf(
"%u.", addr.u8[i]);
97 printf(
"%u\n", addr.u8[i]);
101 print_processes(
struct process *
const processes[])
105 while(*processes !=
NULL) {
106 printf(
" %s", (*processes)->name);
113 main(
int argc,
char **argv)
125 #if NETSTACK_CONF_WITH_IPV4
136 PRINTF(CONTIKI_VERSION_STRING
"\n");
157 node_id = *((
unsigned short *)0x1800);
159 memset(node_mac, 0,
sizeof(node_mac));
160 node_mac[6] = node_id >> 8;
161 node_mac[7] = node_id & 0xff;
166 uint8_t ieee[] = { MAC_1, MAC_2, MAC_3, MAC_4, MAC_5, MAC_6, MAC_7, MAC_8 };
167 memcpy(node_mac, ieee,
sizeof(
uip_lladdr.addr));
189 memset(longaddr, 0,
sizeof(longaddr));
191 printf(
"MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
192 longaddr[0], longaddr[1], longaddr[2], longaddr[3],
193 longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
195 cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
201 PRINTF(
"Node id %u.\n", node_id);
203 PRINTF(
"Node id not set.\n");
206 #if NETSTACK_CONF_WITH_IPV6
214 NETSTACK_NETWORK.init();
216 printf(
"%s %lu %u\n",
218 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
219 NETSTACK_RDC.channel_check_interval()),
220 CC2420_CONF_CHANNEL);
228 lladdr = uip_ds6_get_link_local(-1);
229 for(i = 0; i < 7; ++i) {
230 printf(
"%02x%02x:", lladdr->ipaddr.u8[i * 2],
231 lladdr->ipaddr.u8[i * 2 + 1]);
233 printf(
"%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
236 if(!UIP_CONF_IPV6_RPL) {
239 uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
242 printf(
"Tentative global IPv6 address ");
243 for(i = 0; i < 7; ++i) {
245 ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
248 ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
255 NETSTACK_NETWORK.init();
257 printf(
"%s %lu %u\n",
259 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
260 NETSTACK_RDC.channel_check_interval()),
261 CC2420_CONF_CHANNEL);
264 #if !NETSTACK_CONF_WITH_IPV6
269 #if TIMESYNCH_CONF_ENABLED
279 ENERGEST_ON(ENERGEST_TYPE_CPU);
281 print_processes(autostart_processes);
282 autostart_start(autostart_processes);
307 static unsigned long irq_energest = 0;
310 ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
314 energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
316 _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF);
326 irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
329 ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
void flash_setup(void)
Setup function to be called before any of the flash programming functions.
void timesynch_set_authority_level(int level)
Set the authority level of the current time.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
Header file for IPv6-related data structures.
void uart1_init(unsigned long ubr)
Initalize the RS232 port.
void watchdog_stop(void)
Stops the WDT such that it won't timeout and cause MCU reset.
void clock_init(void)
Initialize the clock library.
int process_run(void)
Run the system once - call poll handlers and process one event.
Unicast address structure.
void slip_arch_init(unsigned long ubr)
Initalize the RS232 port and the SLIP driver.
Header file for the Rime stack
#define NULL
The null pointer.
802.15.4 frame creation and parsing functions
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
void watchdog_periodic(void)
Writes the WDT clear sequence.
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
#define CLOCK_SECOND
A second, measured in system clock time.
void flash_write(unsigned short *ptr, unsigned short word)
Write a 16-bit word to flash ROM.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
void process_start(struct process *p, process_data_t data)
Start a process.
uip_ds6_addr_t * uip_ds6_addr_add(uip_ipaddr_t *ipaddr, unsigned long vlifetime, uint8_t type)
Add a unicast address to the interface.
void flash_done(void)
Function that is to be called after flashing is done.
Header file for module for automatically starting and exiting a list of processes.
void timesynch_init(void)
Initialize the timesynch module.
void rtimer_init(void)
Initialize the real-time scheduler.
Generic serial I/O process header filer.
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
int process_nevents(void)
Number of events waiting to be processed.
void process_init(void)
Initialize the process module.
void ctimer_init(void)
Initialize the callback timer library.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
void flash_clear(unsigned short *ptr)
Clear a 16-bit word in flash ROM.
int serial_line_input_byte(unsigned char c)
Get one byte of input from the serial driver.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
int lcd_init(void)
This function will initialize the proper settings for the LCD driver.
Include file for the Contiki low-layer network stack (NETSTACK)
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