How program an Xbee S2B to read RF data from UART using Codewarrior libraries?

I have been trying to program my Xbee s2b to read data from an input (switch on-off) and then generate a message with a payload 01 10 or 01 20 depending on the switch state.

A second xbee S2B is supposed to receive the message and analyze the payload:

If the payload is 01 10 –> switch diode1 on
If the payload is 01 20 –> switch diode2 on

I tried to use the RF handler but I could only receive the message on the second xbee but not analyze it.

Could you please help me on knowing which is the xbee function to read the payload and if I should increment the operation each time I receive a packet?

Thank you in advance !

Have you looked at the Sample Zigbee Chat application?

Thank you for your answer mvut,

I have already tried that sample yet I still didn’t get it.

Here is my code in handler of the Xbee module which receives the message:

int xbee_transparent_rx(const wpan_envelope_t FAR *envelope, void FAR *context)
{
char addrbuf[ADDR64_STRING_LENGTH];

	addr64_format(addrbuf, &envelope->ieee_address);
	sys_watchdog_reset();
	if (addrbuf=="00-13-A2-00-40-70-D4-D2"){
							
				gpio_set(Diode1, FALSE);
				gpio_set(Diode2, TRUE);
	}	
								
	else{
				gpio_set(Diode1, TRUE);
				gpio_set(Diode2, FALSE);


return 0;
	}

}

I’m still new to Xbee so could you please

Thank you for your answer mvut,

I have already tried that sample yet I still didn’t get it.

Here is my code in handler of the Xbee module which receives the message:

int xbee_transparent_rx(const wpan_envelope_t FAR *envelope, void FAR *context)
{
char addrbuf[ADDR64_STRING_LENGTH];

addr64_format(addrbuf, &envelope->ieee_address);
sys_watchdog_reset();
if (addrbuf==“00-13-A2-00-40-70-D4-D2”){

gpio_set(Diode1, FALSE);
gpio_set(Diode2, TRUE);
}

else{
gpio_set(Diode1, TRUE);
gpio_set(Diode2, FALSE);

return 0;
}
}

I’m still new to Xbee so could you please