Wireless Personal Area Network routines. More...
#include "pic_utils.h"
#include "config.h"
#include "mrf24j40.h"
#include "spi_hw.h"
Go to the source code of this file.
Data Structures | |
struct | wpan_address |
Defines | |
#define | FRAME_TYPE_ACK 0b010 |
#define | FRAME_TYPE_BEACON 0b000 |
#define | FRAME_TYPE_DATA 0b001 |
#define | FRAME_TYPE_MAC_COMMAND 0b011 |
#define | MAC_CMD_ASSOC_REQ 0x01 |
#define | MAC_CMD_ASSOC_RES 0x02 |
#define | MAC_CMD_BEACON_REQ 0x07 |
#define | MAC_CMD_COORD_REALIGN 0x08 |
#define | MAC_CMD_DATA_REQ 0x04 |
#define | MAC_CMD_DISASSOC 0x03 |
#define | MAC_CMD_GTS_REQ 0x09 |
#define | MAC_CMD_ORPHAN 0x06 |
#define | MAC_CMD_PAN_ID_CONFLICT 0x05 |
#define | WPAN_ADDR_TYPE_EXTENDED 0b00000011 |
#define | WPAN_ADDR_TYPE_NONE 0b00000000 |
#define | WPAN_ADDR_TYPE_SHORT 0b00000010 |
Functions | |
void | wpan_data_received_callback (wpan_address *addr, uns8 *data, uns8 data_size, uns8 lqi, uns8 rssi) |
Callback for data received. | |
void | wpan_data_transmitted_callback (uns8 status, uns8 retries, uns8 channel_busy) |
Callback for data transmitted. | |
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 |
Put this in your config.h
// ------------------------ // WPAN (802.15.4) wireless // ------------------------ #define WPAN_USE_MRF24J50 // ------------------------
Definition in file wpan.h.
#define FRAME_TYPE_ACK 0b010 |
Definition at line 79 of file wpan.h.
Referenced by wpan_print_frame_type().
#define FRAME_TYPE_BEACON 0b000 |
Definition at line 77 of file wpan.h.
Referenced by wpan_handle_receive(), and wpan_print_frame_type().
#define FRAME_TYPE_DATA 0b001 |
Definition at line 78 of file wpan.h.
Referenced by its2_transmit(), its_transmit_to_ea(), its_transmit_to_sa(), wpan_handle_receive(), and wpan_print_frame_type().
#define FRAME_TYPE_MAC_COMMAND 0b011 |
Definition at line 80 of file wpan.h.
Referenced by wpan_handle_receive(), and wpan_print_frame_type().
#define MAC_CMD_ASSOC_REQ 0x01 |
Definition at line 67 of file wpan.h.
Referenced by wpan_print_mac_command().
#define MAC_CMD_ASSOC_RES 0x02 |
Definition at line 68 of file wpan.h.
Referenced by wpan_print_mac_command().
#define MAC_CMD_BEACON_REQ 0x07 |
Definition at line 73 of file wpan.h.
Referenced by wpan_print_mac_command().
#define MAC_CMD_COORD_REALIGN 0x08 |
Definition at line 74 of file wpan.h.
Referenced by wpan_print_mac_command().
#define MAC_CMD_DATA_REQ 0x04 |
Definition at line 70 of file wpan.h.
Referenced by wpan_print_mac_command().
#define MAC_CMD_DISASSOC 0x03 |
Definition at line 69 of file wpan.h.
Referenced by wpan_print_mac_command().
#define MAC_CMD_GTS_REQ 0x09 |
Definition at line 75 of file wpan.h.
Referenced by wpan_print_mac_command().
#define MAC_CMD_ORPHAN 0x06 |
Definition at line 72 of file wpan.h.
Referenced by wpan_print_mac_command().
#define MAC_CMD_PAN_ID_CONFLICT 0x05 |
Definition at line 71 of file wpan.h.
Referenced by wpan_print_mac_command().
#define WPAN_ADDR_TYPE_EXTENDED 0b00000011 |
Definition at line 63 of file wpan.h.
Referenced by wpan_handle_receive(), and wpan_print_address().
#define WPAN_ADDR_TYPE_NONE 0b00000000 |
Definition at line 65 of file wpan.h.
Referenced by wpan_handle_receive().
#define WPAN_ADDR_TYPE_SHORT 0b00000010 |
Definition at line 64 of file wpan.h.
Referenced by wpan_handle_receive(), and wpan_print_address().
void wpan_data_received_callback | ( | wpan_address * | addr, | |
uns8 * | data, | |||
uns8 | data_size, | |||
uns8 | lqi, | |||
uns8 | rssi | |||
) |
After the packet has been processed and the address extracted, it is delivered to the callback function.
void wpan_data_transmitted_callback | ( | uns8 | status, | |
uns8 | retries, | |||
uns8 | channel_busy | |||
) |
Once the lower layers have attempted to transmit the packet, the results will be presented to the callback.
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 804 of file its_mode2.c.
References its2_transmitting.
Referenced by mrf24j40_transmit_callback().
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 |
Definition at line 53 of file wpan.c.
Referenced by mrf24j40_receive_callback(), wpan_handle_receive(), and wpan_process().