User manual
IDUINO for maker’s life
www.openplatform.cc
// Get a packet
static bool getPacket(void* _packet)
{
// Void pointer to packet_s pointer hack
// Arduino puts all the function defs at the top of the file
before packet_s being declared :/
packet_s* packet = (packet_s*)_packet;
byte buffer[NRF905_MAX_PAYLOAD];
// See if any data available
if(!nRF905_getData(buffer, sizeof(buffer)))
return false;
// Convert byte array to packet
packet->type = buffer[0];
packet->len = buffer[1];
// Sanity check
if(packet->len > MAX_PACKET_SIZE)
packet->len = MAX_PACKET_SIZE;
memcpy(packet->data, &buffer[2], packet->len);
return true;
}
********Code End*******