51 #include <contiki-net.h>
56 #include <lib/random.h>
64 #define PRINTF(...) printf(__VA_ARGS__)
71 init_net(uint8_t node_id)
83 memset(&shortaddr, 0,
sizeof(shortaddr));
84 memset(&longaddr, 0,
sizeof(longaddr));
85 *((uint8_t *)&shortaddr) = node_id >> 8;
86 *((uint8_t *)&shortaddr + 1) = node_id;
87 *((uint8_t *)&longaddr) = node_id >> 8;
88 *((uint8_t *)&longaddr + 1) = node_id;
89 for(i = 2; i <
sizeof(longaddr); ++i) {
93 PRINTF(
"SHORT MAC ADDRESS %02x:%02x\n",
94 *((uint8_t *) & shortaddr), *((uint8_t *) & shortaddr + 1));
96 PRINTF(
"EXTENDED MAC ADDRESS %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
97 *((uint8_t *)&longaddr),
98 *((uint8_t *)&longaddr + 1),
99 *((uint8_t *)&longaddr + 2),
100 *((uint8_t *)&longaddr + 3),
101 *((uint8_t *)&longaddr + 4),
102 *((uint8_t *)&longaddr + 5),
103 *((uint8_t *)&longaddr + 6),
104 *((uint8_t *)&longaddr + 7));
106 memset(&addr, 0,
sizeof(linkaddr_t));
108 for(i = 0; i <
sizeof(addr.u8); ++i) {
109 addr.u8[i] = ((uint8_t *)&longaddr)[i];
114 PRINTF(
"Rime started with address: ");
115 for(i = 0; i <
sizeof(addr.u8) - 1; ++i) {
116 PRINTF(
"%d.", addr.u8[i]);
118 PRINTF(
"%d\n", addr.u8[i]);
122 NETSTACK_RADIO.init();
131 NETSTACK_NETWORK.init();
133 PRINTF(
"%s %s, channel check rate %d Hz, radio channel %u\n",
134 NETSTACK_MAC.name, NETSTACK_RDC.name,
135 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 :
136 NETSTACK_RDC.channel_check_interval()), RF_CHANNEL);
140 #if LINKADDR_CONF_SIZE == 2
144 memcpy(&
uip_lladdr.addr[6], &shortaddr,
sizeof(shortaddr));
151 lladdr = uip_ds6_get_link_local(-1);
153 PRINTF(
"Tentative link-local IPv6 address ");
155 for(i = 0; i < 7; ++i) {
156 PRINTF(
"%02x%02x:", lladdr->ipaddr.u8[i * 2], lladdr->ipaddr.u8[i * 2 + 1]);
159 PRINTF(
"%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
161 if(!UIP_CONF_IPV6_RPL) {
162 uip_ip6addr(&ipaddr, 0x2001, 0x1418, 0x100, 0x823c, 0, 0, 0, 0);
166 PRINTF(
"Tentative global IPv6 address ");
168 for(i = 0; i < 7; ++i) {
169 PRINTF(
"%02x%02x:", ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
172 PRINTF(
"%02x%02x\n", ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
void mrf24j40_set_short_mac_addr(uint16_t addr)
Store short MAC address.
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
802.15.4 frame creation and parsing functions
Unicast address structure.
uip_ipaddr_t ipaddr
The IP address of this interface.
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 mrf24j40_set_channel(uint16_t ch)
Set the channel.
#define NULL
The null pointer.
void mrf24j40_set_panid(uint16_t id)
Store MAC PAN ID.
void mrf24j40_set_extended_mac_addr(uint64_t addr)
Store extended MAC address.
Header file for the Rime queue buffer management
void process_start(struct process *p, process_data_t data)
Start a process.
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
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.
unsigned short random_rand(void)
Generate the next state and return the upper part of it.
Include file for the Contiki low-layer network stack (NETSTACK)
#define CLOCK_SECOND
A second, measured in system clock time.