pic_packet.c File Reference

#include "pic_packet.h"
Include dependency graph for pic_packet.c:

Go to the source code of this file.

Data Structures

union  rf_packet
struct  seen_packet
struct  sending_item

Defines

#define PKT_FLAG_DELETED   0xff

Functions

void pkt_calc_check_byte (rf_packet *packet)
uns8 pkt_check_check_byte (rf_packet *packet)
void pkt_init (uns16 my_addr, uns16 last_sent_id)
 Initialise packet delivery system.
uns8 pkt_print_packet (rf_packet *my_packet)
uns8 pkt_process_rf_data (uns8 *data_in)
 Process received RF data.
void pkt_process_tx_queue ()
 Handle queued items.
uns8 pkt_queue_packet (rf_packet *packet, uns8 resend)
uns8 pkt_seen (uns16 pkt_id, uns16 source_addr)
void pkt_send_packet (rf_packet *packet)
uns8 pkt_send_payload (uns16 dest_addr, uns8 *payload, uns8 resend)
 Send a payload via the packet delivery system.

Variables

uns16 pkt_my_addr = 0x66
uns16 pkt_my_next_pkt_id = 0
static seen_packet pkt_seen_list [PKT_SEEN_LIST_SIZE]
uns8 pkt_seen_list_last = 0
static sending_item pkt_tx_queue [PKT_TX_QUEUE_SIZE]

Define Documentation

#define PKT_FLAG_DELETED   0xff

Definition at line 78 of file pic_packet.c.

Referenced by pkt_init(), pkt_process_rf_data(), pkt_process_tx_queue(), and pkt_queue_packet().


Function Documentation

void pkt_calc_check_byte ( rf_packet packet  ) 

Definition at line 93 of file pic_packet.c.

References rf_packet::a, rf_packet_det::check_byte, rf_packet::d, PKT_PACKET_SIZE, and uns8.

Referenced by pkt_process_rf_data(), pkt_process_tx_queue(), and pkt_send_payload().

Here is the caller graph for this function:

uns8 pkt_check_check_byte ( rf_packet packet  ) 

Definition at line 104 of file pic_packet.c.

References rf_packet::a, rf_packet_det::check_byte, rf_packet::d, PKT_PACKET_SIZE, and uns8.

Referenced by pkt_process_rf_data().

Here is the caller graph for this function:

void pkt_init ( uns16  my_addr,
uns16  last_sent_pkt_id 
)

Initialise the packet delivery system ready for use. This routine clears the transmit queue and seen queue. If you don't store the last_sent_pkt_id (eg, in EEPROM) then set this to 0.

Parameters:
my_addr The address of this system
last_sent_pkt_id The last pkt_id used by this system.

Definition at line 423 of file pic_packet.c.

References sending_item::flag, PKT_FLAG_DELETED, pkt_my_addr, pkt_my_next_pkt_id, seen_packet::source_addr, uns16, and uns8.

uns8 pkt_print_packet ( rf_packet my_packet  ) 
uns8 pkt_process_rf_data ( uns8 *  data_in  ) 
void pkt_process_tx_queue (  ) 

Call this routine regularly (as often as possible) in your main loop in order for the packet delivery system to send any queued packets when it is appropriate to do so. It will also remove any packets from the tx queue that have been there too long.

Definition at line 354 of file pic_packet.c.

References rf_packet::d, rf_packet_det::dest_addr, sending_item::flag, sending_item::packet, rf_packet_det::payload, pkt_calc_check_byte(), PKT_FLAG_DELETED, PKT_FLAG_RESEND, rf_packet_det::pkt_id, pkt_print_packet(), pkt_send_callback(), pkt_send_failed_callback(), pkt_send_packet(), rf_packet_det::r1_addr, sending_item::sent_count, serial_print_int(), serial_print_spc(), serial_print_str(), tick_calc_diff(), tick_get_count(), sending_item::tick_sent, uns16, and uns8.

Here is the call graph for this function:

uns8 pkt_queue_packet ( rf_packet packet,
uns8  resend 
)

Definition at line 144 of file pic_packet.c.

References sending_item::flag, PKT_FLAG_DELETED, PKT_PACKET_SIZE, PKT_STATUS_QUEUED, PKT_STATUS_TX_QUEUE_FULL, sending_item::sent_count, serial_print_int(), serial_print_str(), and uns8.

Referenced by pkt_process_rf_data(), and pkt_send_payload().

Here is the call graph for this function:

Here is the caller graph for this function:

uns8 pkt_seen ( uns16  pkt_id,
uns16  source_addr 
)

Definition at line 80 of file pic_packet.c.

References uns8.

Referenced by pkt_process_rf_data().

Here is the caller graph for this function:

void pkt_send_packet ( rf_packet packet  )  [inline]

Definition at line 328 of file pic_packet.c.

References rf_packet::a, pic_rf_transmit(), PKT_PACKET_SIZE, pkt_print_packet(), serial_print_str(), tx_buffer, and uns8.

Referenced by pkt_process_tx_queue().

Here is the call graph for this function:

Here is the caller graph for this function:

uns8 pkt_send_payload ( uns16  dest_addr,
uns8 *  payload,
uns8  resend 
)

Use this routine to send a payload of data to the destination address. The payload must point to PKT_PAYLOAD_SIZE bytes of data (as defined in your config.h). The packet will be constructed, setting destination address, sender address (set previously in pkt_init) payload, initial routing directions and the check byte calculated. It will then be placed into the tx queue and will actually be sent next time pkt_process_tx_queue is called.

Parameters:
dest_addr Send payload to this address. Use address of PKT_BROADCAST_ADDR to broadcast to all listening local addresses
pay_load Pointer to PKT_PAYLOAD_SIZE array of bytes
resend Set to PKT_FLAG_RESEND or PKT_FLAG_NO_RESEND

Definition at line 440 of file pic_packet.c.

References rf_packet::d, rf_packet_det::dest_addr, rf_packet_det::payload, PKT_BROADCAST_ADDR, pkt_calc_check_byte(), PKT_DIRECT_SEND_ADDR, rf_packet_det::pkt_id, pkt_my_addr, pkt_my_next_pkt_id, pkt_print_packet(), pkt_queue_packet(), rf_packet_det::r1_addr, rf_packet_det::r2_addr, rf_packet_det::r3_addr, serial_print_int(), serial_print_str(), rf_packet_det::source_addr, and uns8.

Referenced by pkt_process_rf_data().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

uns16 pkt_my_addr = 0x66

Definition at line 74 of file pic_packet.c.

Referenced by pkt_init(), pkt_process_rf_data(), and pkt_send_payload().

uns16 pkt_my_next_pkt_id = 0

Definition at line 75 of file pic_packet.c.

Referenced by pkt_init(), and pkt_send_payload().

seen_packet pkt_seen_list[PKT_SEEN_LIST_SIZE] [static]

Definition at line 70 of file pic_packet.c.

Definition at line 73 of file pic_packet.c.

Referenced by pkt_process_rf_data().

sending_item pkt_tx_queue[PKT_TX_QUEUE_SIZE] [static]

Definition at line 71 of file pic_packet.c.


Generated on Wed Dec 8 13:47:34 2010 for Pic Pack by  doxygen 1.6.1