/* sends the data the node identified by the string * this function copies the given buffer into an XBee_Message object */ uint8_t XBee::xbee_send_data(const string &destination, const uint8_t *data, uint16_t length) { XBee_Message *msg; uint8_t status; const XBee_Address *addr = xbee_get_address(destination); if (!addr) return GBEE_TIMEOUT_ERROR; /* node couldn't be found in network */ msg = new XBee_Message(*addr, data, length); status = xbee_send_data(*msg); delete msg; return status; }
int main(int argc, char **argv) { if (argc < 2) { printf("use : ./prg PORT\n"); } xbee_open((char *)argv[1]); uint8_t data[2]; uint8_t i; while(1){ sleep(3); printf("%x ", i); data[0] =i++; printf("%x\n", i); data[1] =i++; xbee_send_data(data, 2, 0, 0); } /* Closing file descriptor */ xbee_close(); return 0; }