/**************************************************************************** Module Farmer_RX.c Pseudo Code ****************************************************************************/ /*----------------------------- Module Defines ----------------------------*/ define definitions /*---------------------------- Module Functions ---------------------------*/ define module functions /*---------------------------- Module Variables ---------------------------*/ define module variables /*------------------------------ Module Code ------------------------------*/ /**************************************************************************** ****************************************************************************/ bool InitFarmerRX ( uint8_t Priority ) { set priority /******************************************** Initialization Code *******************************************/ Initialize local variables to 0 (data packet and xbee packet length) enable RX interrupt print out initializing completion post the initial transition event } /**************************************************************************** ****************************************************************************/ bool PostFarmerRX( ES_Event ThisEvent ) { return ES_PostToService( MyPriority, ThisEvent); } /**************************************************************************** ****************************************************************************/ ES_Event RunFarmerRX( ES_Event ThisEvent ) { set return event to no event if this event is received valid packet, analyse the received data get data packet length from the event parameter copy elements from the buffer in FarmerTX module to local one call analysing function to process the data packet return return event } /*************************************************************************** private functions ***************************************************************************/ /* * This function clear data packet ocntent */ static void ClearDataPacket(){ set all elements of data packet to 0 } /* * This function analyze the recieved data packet */ static void AnalyzeRXPacket(){ set API_id to data packet index 0 if API id is 0x89, this is transmit status message get frame id from index 1 get transmit status from index 2 if transmit status is 0, this is ack post ACK_RECEIVED event to FarmerTopSM with frame id as parameter if transmit status is 1, this is nack post NACK_RECEIVED event to FarmerTopSM with frame id as parameter if API id is 0x81, this is receive data message save source address from index 1 and 2 set dog address if data packet type (index 5 is 0x02) is pairing acknowledge message post get req2pair ack response message to farmer top SM with dog address as parameter if data packet type is encryption reset request post reset encryption received to farmer top SM with dog address as a parameter if data packet type is pairing acknowledge message save status to local array combine every two imu status (MSB and LSB) to one imu value post dog report received to farmer top SM with the index 5 IMU value as parameter (gyro z value) } /*------------------------------- Footnotes -------------------------------*/ /*------------------------------ End of file ------------------------------*/