User manual
LPCXpresso Experiment Kit - User’s Guide
Page 115
Copyright 2013 © Embedded Artists AB
** Function name: xbeeTxStatus
**
** Descriptions: Received data callback. Called when data has been received
** by the Xbee node.
**
** parameters: addrHi - upper 32 bits of the 64-bit node address,
** addrLo - lower 32 bits of the 64-bit node address,
** rssi - signal strength,
** buf - buffer containing the data,
** len - number of received bytes,
** Returned value: None
**
*****************************************************************************/
static void xbeeData(uint32_t addrHi, uint32_t addrLo, uint8_t rssi,
uint8_t* buf, uint8_t len)
{
int i = 0;
printf("xbeeData %x:%x, rssi=%d, len=%d\r\n", addrHi, addrLo, rssi, len);
if (len < 1) {
return;
}
switch (buf[0]) {
// Set LED request. This is a two byte request where the data
// indicates if the LED should be turned on or off.
case RFPT_SET_LED:
if (len > 1) {
if (buf[1] == 1) {
GPIOSetValue(LED1_PORT, LED1_PIN, LED_ON);
} else {
GPIOSetValue(LED1_PORT, LED1_PIN, LED_OFF);
}
}
break;
default:
for (i = 0; i < len; i++) {
if (i > 0 && (i%8) == 0) {
printf("\r\n");
}
printf("%x ", buf[i]);
}
printf("\r\n");
break;
}
}
/*****************************************************************************
** Function name: sendSetLedRequest
**
** Descriptions: Broadcasts a request over Xbee to set the status of the LED
**
** parameters: ledOn - should the LED be lit or not
** Returned value: ERR_OK or an error code
**
*****************************************************************************/
static error_t sendSetLedRequest(uint8_t ledOn)
{
uint8_t data[2];
uint8_t id = 0;
data[0] = RFPT_SET_LED;
data[1] = ledOn;
return xbee_send(XBEE_ADDRHI_BROADCAST, XBEE_ADDRLO_BROADCAST, data, 2, &id);
}
int main (void)
{
error_t err;
uint8_t state = 0;
uint8_t oldState = !SW_PRESSED;