|
/**************************************************************************
Function Description: Parsing and decoding the received packets and performing different operations according to different types of packets, the packet information is stored in the structure variable rxData by the packet callback function.
Input parameters: None
Output parameters: None
***************************************************************************/
void Processrxpacket (void)
{
......
// Check to determine the packet frame type, only the ft_data type is used in the code
Switch (rxdata.packet[1]&0x7) {
Case Ft_data:
Rx_details (printf ("ft_data\r\n");)
Packettype = (ft_data<<4);
Break
Case Ft_mac_command:
Rx_details (printf ("ft_mac_command\r\n");)
Packettype = (ft_mac_command<<4);
Break
Default
Rx_details (printf ("Unknown frame type\r\n");)
Goto stopprocessing;
};
// determine if the data packet has PAN ID Information
if ((rxdata.packet[1]&0x40)!=0x40) {
Pkthassrcpanid=true;
Srcaddroffset = 2;
}
// four different address types
Switch (rxdata.packet[2]) {
......
}
Rx_details (
if (Pkthassrcpanid) {
printf ("src pan = 0x%04x\r\n", Srcpanid);
}
)
// determine if the packet length satisfies sufficient length to hold the payload type
if (Rxdata.packet[0]<payloadstart) {
Rx_details (printf ("Length byte Too short\r\n");)
Goto stopprocessing;
}
// calculate packet type by frame type and load type
Packettype |= (rxdata.packet[payloadstart]<<0);
Rx_details (printf ("Packet type = 0x%02x\r\n", packettype);)
// different packet types perform different operations
Switch (packettype) {
Case (Generic_data_packet):// normal type packet,Sun node and Planet node will receive
Rx_details (printf ("generic_data_packet\r\n");)
printf ("%d\n", Rxdata.rssi);//rssi output
Break
......
Default
Rx_details (printf ("Unknown payload type\r\n");)
Goto stopprocessing;
}
Stopprocessing:
rxdata.packetbeingprocessed = FALSE;
}
|