Atmel AVR2070 User Manual

Page of 93
 
52 
AVR2070 
8240B-AVR-06/09 
B.3 6LoWPAN API  
This group of functions is used to send a UDP packet to a node either on the wireless 
network (‘iplocal’) or somewhere outside the wireless network (‘ipglobal’). The source 
and destination ports are set, the payload loaded, and finally the UDP packet is sent. 
The Doxygen documentation provides specific examples. 
• uint8_t 
sixlowpan_hc01_udp_setup_ipglobal(void)  
• void 
sixlowpan_hc01_udp_setup_iplocal(uint16_t addr)  
• void 
sixlowpan_hc01_udp_setup_ports(uint16_t srcport, uint16_t  destport
• uint8_t 
sixlowpan_hc01_udp_get_payloadptr(void)  
• void 
sixlowpan_hc01_udp_set_payloadsize(uint8_t size)  
• void 
sixlowpan_hc01_udp_send(void) 
This function below is called on the AVR when a UDP frame is received. The UDP 
payload is pointed to by payload and is of length payloadlen.  After the frame is 
processed, a message can be sent back to the source port and IP address by 
copying a new payload into the payload pointer. The return value indicates how many 
bytes to send back – a return of zero results in no response sent back. The 
payloadmax parameter indicates the maximum allowable payload that could be sent. 
This function is written by the user, an example is provided in the 
sixlowpan_application_example.c file. 
• uint8_t 
sixlowpan_udp_usercall (uint16_t  sourceport, uint16_t  destport
uint8_t *  payload, uint8_t  payloadlen, uint8_t  payloadmax
The following group of functions is used to send an ICMP Echo Request (ping) to a 
remote IP address. The Doxygen documentation contains an example of how to use 
this to ping an end node. 
• uint8_t 
sixlowpan_hc01_ping_setup_ipglobal (uint8_t  sequence)  
• void 
sixlowpan_hc01_ping_send (void) 
The next function is called when an ICMP Echo Response is received. The sequence 
holds the sequence number of the returned ping. 
• void 
sixlowpan_ping_usercall (uint8_t sequence
This function below handles an incoming RUM frame that is flagged as containing 
6LoWPAN data. It copies the frame to another buffer, and calls the 
sixlowpan_hc01_process() function on the AVR. This function performs any needed 
actions – responding to Neighbor Solicitation, storing information from Router 
Advertisements, responding to Echo Requests, and calling user functions if data is 
received. The 6LoWPAN and IPv6 stack on the ARM device are based on uIPv6 
integrated into Contiki. See 
www.sics.se/contiki
 and the RUM source code for 
integration details. This process is shown for AVR devices in figure B-7 and for ARM 
devices in figure B-8. 
• void 
sixlowpan_DataIndication(ftData * frame, uint8_t payloadlen