Quantcast
Channel: Seeedstudio Forum
Viewing all articles
Browse latest Browse all 6612

RFBee stability

$
0
0
I call something like this after each reception of package (at the end of writeSerialData function)
Code:exec(&packet);


And in the exec function i handle relays according to the content of the packet.
Code:void exec(struct ccxPacket_t *packet)
{
   if (packet->len < 3)
      return;

   if (!(packet->frame[0] != 0 || packet->frame[0] != config_get(CONFIG_MY_ADDR)))
      return;

   LEDPORT = LEDPORT ^ LED;

   if (packet->frame[2] == '1') {
      if (packet->frame[3] & 1) {
         RELPORT |= REL1;
      }
      if (packet->frame[3] & 2) {
         RELPORT |= REL2;
      }
   } else if (packet->frame[2] == '0') {
      if (packet->frame[3] & 1) {
         RELPORT &= ~REL1;
      }
      if (packet->frame[3] & 2) {
         RELPORT &= ~REL2;
      }
   }
}


packet->frame[0] is the destination address, and your data starts from index 2

Statistics : Posted by cutlervufamily • on Mon Jul 15, 2013 5:46 pm • Replies 4 • Views 783

Viewing all articles
Browse latest Browse all 6612

Trending Articles