WikiStart » Reference » Colony Robot Overview »
Wireless¶

Sample Code¶
#include <dragonfly_lib.h>
#include <wl_basic.h>
...
int main(void)
{
dragonfly_init(ALL_ON);
wl_basic_init_default(); // initialize the basic wireless capabilities
wl_set_channel(12); // set the robot to your assigned channel (12 to 26)
unsigned char *packet_data; // variables used to
int packet_length; // receive packets
char data[2]; // data buffer used to send packets
...
while(1)
{
packet_data = wl_basic_do_default(&packet_length);
// packet_data is a pointer to the data buffer
// packet_length is an int that specifies the length of the buffer
if (packet_data != 0) // WARNING: make sure you perform this check on the return value before accessing the data
{
// there is a new packet...now you need to do something with the data
// you can access the contents of the package as an array (i.e. packet_data[0], etc...)
}
if ( you want to send a packet )
{
data[0] = 'H';
data[1] = 'I';
wl_basic_send_global_packet( 42, data, 2 );
}
}
...
}
Schematic¶

