Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The Host should ACK every frame from the Module that is not an ACK frame.
  • After the Host sends a frame to the Module, it should wait for an ACK or Response from the Module before proceeding with sending another frame.
    • If the Host does not receive an ACK or Response from the Module within expected timeout periods (i.e. up to 15 seconds for a ZCL command that goes out over the network), it should retry.

...

Code Samples

Code Block
languagec#
titleSerial Ack Sample
linenumberstrue
collapsetrue
//NOTE: not a working sample, code is for demonstration purposes only
 
class SampleSerialAckSampleMessageHandler
{
	//Setup Thread wait / Mutex
	EventWaitHandle ewh = new EventWaitHandler(false, EventResetMode.AutoReset);
	public delegate void IncomingMessageDelegate(Frame incomingFrame);

	Frame sentFrame;

	void SendAndWait( StartSending()
	{
		while(isMessageInQueue)
		{
	    	sentFrame = SendNextFrame();

	    	//Wait For Ack
	    	ewh.WaitOne();
		}
	}

	HandleIncomingFrame(Frame incomingFrame)
	{	
		if(incomingFrame.isAckOf(sentFrame))
		{
			ewh.set();//signal the wait	
		}
		else
		{
			doSomethingElse(incomingFrame);
		}

	}

	public class SerialListener
	{

		public static StartSerialListener()
		{
			IncomingMessageDelegate imd1 = new IncomingMessageDelegate(HandleIncomingFrame);
			openComPort();
			startReceiving();
		}

		//Listener methods
		//	.
		//	.
		//	.
		//	.

		public void onIncomingMessage(Frame f)
		{
			//
			//
			//
			imd1(f);
		}


	}

}

class Test()
{
	public static void Main()
	{
		SerialAckSmaple sas = new SerialAckSample();
		sas.StartSerialListener();
		sas.StartSending();
	}

}