fun_ofdm  1.0
802.11a Physical Layer for USRP
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
simple_transceiver.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include <fun_ofdm/transmitter.h>
4 #include <fun_ofdm/receiver.h>
5 
6 void callback(std::vector<std::vector<unsigned char> > payloads);
7 
8 using namespace std;
9 using namespace fun;
10 
11 int main()
12 {
13 
14  usrp_params params = usrp_params();
15  transmitter tx = transmitter(params);
16  receiver rx = receiver(&callback, params);
17 
18  std::string s = "Hello World";
19  std::vector<unsigned char> data = std::vector<unsigned char>(12);
20  memcpy(&data[0], &s[0], 12);
21  tx.send_packet(data);
22 
23  while(1)
24  {
25  sleep(4);
26  rx.pause();
27  tx.send_packet(data);
28  cout << "Sending \"Hello World\" " << std::endl;
29  rx.resume();
30  }
31 
32  return 0;
33 }
34 
35 void callback(std::vector<std::vector<unsigned char> > payloads)
36 {
37  for(int i = 0; i < payloads.size(); i++)
38  {
39  std::cout << "Received a packet" << std::endl;
40  }
41 
42 }