See below for working example code of using the wireless transceiver.
The transceiver has several modes, each needed for different tasks.
Following is a list of functions to use the wireless feature of the Axon Mote:
wireless_TX_MODE(); - Go into transmit mode. You must go into this mode to prepare to transmit data.
wireless_BUFFER_byte(uint8_t data); - You must be in transmit mode to use this. It will load one byte into
the buffer. The byte must either be a char or an uint8_t (unsigned 8 bit integer, ie 0 to 255).
wireless_BUFFER_string("hello world!"); - You must be in transmit mode to use this. It will load an
entire string into the buffer. Your receive code must differentiate between int's and char's to read data properly.
The buffer cannot exceed 125 bytes, or an error will be generated by the transceiver.
wireless_TX_TRANSMIT(); - Command Mote to wirelessly transmit the data in the buffer.
wireless_BUFFER_CLEAN(); - The buffer is persistant. Use this function to clean out the data buffer.
If you do not clean out the buffer after a transmit or receive, previous data can potentially interfere with future data.
There are some cases where you'd like to keep the data, hence this is optional.
wireless_RX_MODE(); - Go into recieve mode. You must be in this mode to recieve data.
wireless_RX_PROTECT(boolean protect); - Prevents over-writing of buffer when new data is recieved.
It's possible your buffer can get over written before your code has finished processing it. Use a 1 to
turn protection on, and a 0 to turn it off.
wireless_OFF(); - Turn transceiver partially off to reduce power. Some power is still required in off mode so that it can quickly
go back into RX or TX modes.
wireless_SLEEP(); - Puts transceiver into sleep mode for near zero power consumption.
wireless_WAKE(); - Wakes up transciever from sleep mode to go into off mode.
wireless_SetChannel(17); - Sets channel to 17. Channel can be from 11 to 26. Specific frequency data can be found
in the ATmega128RFA1 datasheet. The ATmega128RFA1 defaults to channel 11 if not set. Using multiple channels is very helpful
in mesh networks where data collision is possible.
wireless_ReadChannel() - This function *returns* the channel number as a uint8_t.
wireless_reset(); - Restarts the transceiver hardware to default settings.
boolean wireless_crc_valid - This variable is false whenever the last returned wireless data packet had an error. You must check
for this error before reading data, as shown in the example code. Your code can then request a retransmission.
This is an example program to transmit data: