14 #include "debug-uart.h"
19 #include "cc1120-arch.h"
22 #include "dev/watchdog.h"
23 #include "sys/clock.h"
24 #include "lib/random.h"
28 #if NETSTACK_CONF_WITH_IPV6
34 #include "sys/node-id.h"
39 #define PRINTF(...) printf(__VA_ARGS__)
44 #ifndef NETSTACK_CONF_WITH_IPV4
45 #define NETSTACK_CONF_WITH_IPV4 0
48 #if NETSTACK_CONF_WITH_IPV4
51 #include "net/uip-fw-drv.h"
56 {
UIP_FW_NETIF(172, 16, 0, 0, 255, 255, 0, 0, uip_over_mesh_send) };
60 #define UIP_OVER_MESH_CHANNEL 8
61 #if NETSTACK_CONF_WITH_IPV4
62 static uint8_t is_gateway;
65 unsigned short node_id = 0x55;
66 unsigned char node_mac[8];
68 unsigned int idle_count = 0;
82 memset(&addr, 0,
sizeof(linkaddr_t));
83 #if NETSTACK_CONF_WITH_IPV6
84 memcpy(addr.u8, node_mac,
sizeof(addr.u8));
87 for(i = 0; i <
sizeof(linkaddr_t); ++i) {
88 addr.u8[i] = node_mac[7 - i];
91 addr.u8[0] = node_id & 0xff;
92 addr.u8[1] = node_id >> 8;
104 port_enable(PORTB_EN_MASK | PORTC_EN_MASK | PORTD_EN_MASK | PORTE_EN_MASK);
127 node_mac[6] = (uint8_t)(12345678 >> 8);
128 node_mac[7] = (uint8_t)(12345678 & 0xff);
138 NETSTACK_CONF_RADIO.init();
142 printf(CONTIKI_VERSION_STRING
" started. ");
155 PRINTF(
" Net: %s\n", NETSTACK_NETWORK.name);
157 printf(
"%s %s, channel check rate %d Hz, radio channel %d\n",
158 NETSTACK_MAC.name, NETSTACK_RDC.name,
159 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
160 NETSTACK_RDC.channel_check_interval()),
166 printf(
"Tentative link-local IPv6 address ");
170 lladdr = uip_ds6_get_link_local(-1);
172 for(i = 0; i < 7; ++i) {
173 printf(
"%02x%02x:", lladdr->ipaddr.u8[i * 2],
174 lladdr->ipaddr.u8[i * 2 + 1]);
177 printf(
"%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
180 if(!UIP_CONF_IPV6_RPL) {
186 printf(
"Tentative global IPv6 address ");
188 for(i = 0; i < 7; ++i) {
190 ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
193 ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
203 printf(
"%s %s, channel check rate %lu Hz, radio channel %u\n",
204 NETSTACK_MAC.name, NETSTACK_RDC.name,
205 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
206 NETSTACK_RDC.channel_check_interval()),
210 #if NETSTACK_CONF_WITH_IPV4
214 uip_ipaddr_t hostaddr,
netmask;
219 rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
225 uip_over_mesh_set_net(&hostaddr, &netmask);
229 uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
230 printf(
"uIP started with IP address %d.%d.%d.%d\n",
238 ENERGEST_ON(ENERGEST_TYPE_CPU);
240 leds_off(LEDS_GREEN);
242 autostart_start(autostart_processes);
void uip_log(char *m)
Print out a uIP log message.
void gpio_init()
Initialise the GPIO module.
#define uip_sethostaddr(addr)
Set the IP address of this host.
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
#define uip_ipaddr(addr, addr0, addr1, addr2, addr3)
Construct an IP address from four bytes.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
uint8_t slip_send(void)
Send an IP packet from the uIP buffer with SLIP.
Header file for IPv6-related data structures.
uip_ipaddr_t ipaddr
The IP address of this interface.
void watchdog_stop(void)
Stops the WDT such that it won't timeout and cause MCU reset.
Header file for tunnelling uIP over Rime mesh
void clock_init(void)
Initialize the clock library.
CMSIS Peripheral Access Layer for MKL25Z4.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
int process_run(void)
Run the system once - call poll handlers and process one event.
Unicast address structure.
uip_ipaddr_t netmask
The netmask of the interface.
Header file for the Rime stack
#define uip_setnetmask(addr)
Set the netmask.
#define NULL
The null pointer.
#define uip_ipaddr_to_quad(a)
Convert an IP address to four bytes separated by commas.
802.15.4 frame creation and parsing functions
uIP packet forwarding header file.
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
#define UIP_FW_NETIF(ip1, ip2, ip3, ip4, nm1, nm2, nm3, nm4, outputfunc)
Instantiating macro for a uIP network interface.
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.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
Header file for the uIP TCP/IP stack.
void process_start(struct process *p, process_data_t data)
Start a process.
int main(void)
This is main...
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.
Header file for module for automatically starting and exiting a list of processes.
void rtimer_init(void)
Initialize the real-time scheduler.
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
void uip_init(void)
uIP initialization function.
void process_init(void)
Initialize the process module.
void ctimer_init(void)
Initialize the callback timer library.
Platform configuration for the Z1-feshie platform
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
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
void uip_fw_default(struct uip_fw_netif *netif)
Register a default network interface.
Representation of a uIP network interface.