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"
64 #define PRINTF(...) printf(__VA_ARGS__)
69 extern unsigned char node_mac[8];
79 memset(&addr, 0,
sizeof(linkaddr_t));
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)
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");
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) {
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);
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_OFF(ENERGEST_TYPE_CPU);
311 ENERGEST_ON(ENERGEST_TYPE_LPM);
315 energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
317 _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF);
327 irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
330 ENERGEST_OFF(ENERGEST_TYPE_LPM);
331 ENERGEST_ON(ENERGEST_TYPE_CPU);
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.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
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 LEDS_RED
LED1 (Red) -> PC0.
Unicast address structure.
void timesynch_init(void)
Initialize the timesynch module.
void flash_clear(unsigned short *ptr)
Clear a 16-bit word in flash ROM.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
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)
#define NULL
The null pointer.
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 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.
void ctimer_init(void)
Initialize the callback timer library.
void flash_done(void)
Function that is to be called after flashing is done.
void flash_write(unsigned short *ptr, unsigned short word)
Write a 16-bit word to flash ROM.
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.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
int lcd_init(void)
This function will initialize the proper settings for the LCD driver.
void flash_setup(void)
Setup function to be called before any of the flash programming functions.
Include file for the Contiki low-layer network stack (NETSTACK)
#define CLOCK_SECOND
A second, measured in system clock time.