Wireless Personal Area Network routines. More...
#include "wpan.h"
#include "pic_utils.h"
#include "pic_serial.h"
#include "debug.h"
Go to the source code of this file.
Defines | |
#define | debug_on |
Functions | |
void | mrf24j40_receive_callback () |
Callback is actioned when mrf24j40 has a packet received off air. | |
void | mrf24j40_transmit_callback (uns8 status, uns8 retries, uns8 channel_busy) |
Callback is actioned when mrf24j40 has finished transmitting a packet, or failed to do so. | |
void | wpan_handle_receive () |
Handle reception of packet. | |
void | wpan_init () |
Initialise this and lower layers ready for use. | |
void | wpan_print_address (wpan_address *addr) |
Print the address of the packet. | |
void | wpan_print_frame_type (uns8 frame_type) |
Print information about the WPAN frame type. | |
void | wpan_print_mac_command (uns8 *data) |
Debug routine that prints out the mac command type. | |
void | wpan_process () |
Process WPAN layer. | |
void | wpan_setup_io () |
Setup IO as requred. | |
Variables | |
uns8 | pkt_received = 0 |
uns8 | receive_lost = 0 |
uns8 | wpan_rx_buffer [50] |
uns8 | wpan_rx_count |
Definition in file wpan.c.
void mrf24j40_receive_callback | ( | ) |
Callback indicating the mrf24j40 has a packet ready.
Definition at line 56 of file wpan.c.
References debug_int, debug_str, mrf24j40_flush_receive_buffer(), mrf24j40_receive(), pkt_received, receive_lost, serial_putc(), wpan_rx_buffer, and wpan_rx_count.
Referenced by mrf24j40_handle_isr().
void mrf24j40_transmit_callback | ( | uns8 | status, | |
uns8 | retries, | |||
uns8 | channel_busy | |||
) |
Callback indicating the mrf24j40 has finished the transmission sequence.
status | Set to 0 for success or 1 for failure | |
retries | Set to the number of retries | |
channel_busy | Set to 1 if failure was due to the channel being busy. |
Definition at line 75 of file wpan.c.
References debug_int, debug_str, and wpan_data_transmitted_callback().
Referenced by mrf24j40_handle_isr().
void wpan_handle_receive | ( | ) |
Internal routine for WPAN layer to handle the reception of a packet.
Definition at line 225 of file wpan.c.
References wpan_address::dest_address_type, wpan_address::dest_ea, wpan_address::dest_pan_id, wpan_address::dest_sa, FRAME_TYPE_BEACON, FRAME_TYPE_DATA, FRAME_TYPE_MAC_COMMAND, pkt_received, wpan_address::source_address_type, wpan_address::source_ea, wpan_address::source_pan_id, wpan_address::source_sa, uns8, WPAN_ADDR_TYPE_EXTENDED, WPAN_ADDR_TYPE_NONE, WPAN_ADDR_TYPE_SHORT, wpan_data_received_callback(), wpan_rx_buffer, and wpan_rx_count.
Referenced by wpan_process().
void wpan_init | ( | ) |
Initialise underlying hardware (typically mrf24j40)
Definition at line 336 of file wpan.c.
References mrf24j40_init().
Referenced by its1_controller_init(), its1_device_init(), its2_device_init(), and its_init().
void wpan_print_address | ( | wpan_address * | addr | ) |
Print out the source and destination address
Definition at line 96 of file wpan.c.
References debug_str, wpan_address::dest_address_type, wpan_address::dest_ea, wpan_address::dest_pan_id, wpan_address::dest_sa, serial_print_int_hex(), serial_print_int_hex_16bit(), serial_print_str(), serial_putc(), wpan_address::source_address_type, wpan_address::source_ea, wpan_address::source_pan_id, wpan_address::source_sa, uns8, WPAN_ADDR_TYPE_EXTENDED, and WPAN_ADDR_TYPE_SHORT.
Referenced by wpan_data_received_callback().
void wpan_print_frame_type | ( | uns8 | frame_type | ) |
Definition at line 148 of file wpan.c.
References FRAME_TYPE_ACK, FRAME_TYPE_BEACON, FRAME_TYPE_DATA, FRAME_TYPE_MAC_COMMAND, and serial_print_str().
Referenced by wpan_data_received_callback().
void wpan_print_mac_command | ( | uns8 * | data | ) |
Print the MAC layer command details
Definition at line 166 of file wpan.c.
References MAC_CMD_ASSOC_REQ, MAC_CMD_ASSOC_RES, MAC_CMD_BEACON_REQ, MAC_CMD_COORD_REALIGN, MAC_CMD_DATA_REQ, MAC_CMD_DISASSOC, MAC_CMD_GTS_REQ, MAC_CMD_ORPHAN, MAC_CMD_PAN_ID_CONFLICT, serial_print_int_hex(), serial_print_str(), serial_putc(), and uns8.
void wpan_process | ( | ) |
Call wpan_process() regularly to handle events at the WPAN layer. Typically this includes handling any received packets, processing them, and handing up to a higher layer.
Definition at line 214 of file wpan.c.
References pkt_received, and wpan_handle_receive().
void wpan_setup_io | ( | ) |
Set up ports and pins for WPAN use
Definition at line 332 of file wpan.c.
References mrf24j40_setup_io().
Referenced by its1_setup_io(), and its2_setup_io().
uns8 pkt_received = 0 |
Definition at line 53 of file wpan.c.
Referenced by mrf24j40_receive_callback(), wpan_handle_receive(), and wpan_process().
uns8 receive_lost = 0 |
Definition at line 51 of file wpan.c.
Referenced by mrf24j40_receive_callback().
uns8 wpan_rx_buffer[50] |
Definition at line 49 of file wpan.c.
Referenced by mrf24j40_receive_callback(), and wpan_handle_receive().
uns8 wpan_rx_count |
Definition at line 50 of file wpan.c.
Referenced by mrf24j40_receive_callback(), and wpan_handle_receive().