// --------------------------------------------------------------------------------------------
// Receiver template (example of a simple base station receiver)
// designed for the Smart-Its Core
// --------------------------------------------------------------------------------------------
// last modified: 11.03.2003
// --------------------------------------------------------------------------------------------
// COPYRIGHT (c) 2002, 2003 by Albrecht Schmidt - http://www.comp.lancs.ac.uk/~albrecht/
// Lancaster University, http://www.comp.lancs.ac.uk/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// --------------------------------------------------------------------------------------------
// developed/improved for various prototypes
// in the Smart-Its Project (http://www.smart-its.org) and
// in the Equator IRC (http://www.equator.ac.uk)
// --------------------------------------------------------------------------------------------
// compiled with
// CCS PCM C Compiler, Version 3.080
// CCS PCH C Compiler
#include "core16.c"
#use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7)
main() {
int ret; // return value for rfReceiveOnCD
char msg[MAXBUF];
// iitialize core, show boot sign
init_core();
// loop forever
while(1) {
// restart the watchdog timer - at least every 2 seconds
restart_wdt();
// check 900ms whether or not RF data is available
// if data is available and correct then ret = 0
ret = rfReceiveOnCD(msg, MAXBUF, 900);
if (ret==0) {
// print the received data
printf("%s", msg);
// if the string starts with l1 switch LED on
if ((rf_buffer[0]=='l') && (rf_buffer[1]=='1')) {
led_on();
}
// if the string starts with l0 switch LED off
if ((rf_buffer[0]=='l') && (rf_buffer[1]=='0')) {
led_off();
}
}
}
}