29 #include <boost/asio.hpp>
46 typedef unsigned char byte;
69 void startup(
const std::string& port_name,
const int baud_rate,
const NodeId& my_node_id,
70 const uint16_t network_id,
const std::string& xbee_info_location,
71 const bool& use_encryption,
const std::string& encryption_password);
96 std::shared_ptr<boost::asio::io_context> io;
97 boost::asio::serial_port* port;
101 std::string glog_group;
104 std::map<NodeId, SerialNumber> node_id_to_serial_number_map;
105 std::map<SerialNumber, NodeId> serial_number_to_node_id_map;
107 std::vector<std::string> received_packets;
110 void get_my_serial_number();
111 void get_maximum_payload_size();
112 void broadcast_node_id();
118 void write(
const std::string& raw);
119 std::string read_until(
const std::string& delimiter);
120 size_t bytes_available();
121 void read(
void* ptr,
const size_t n_bytes);
122 void async_read_with_timeout(std::string& buffer,
const std::string& delimiter,
124 std::function<
void(
const std::string&)> handler);
127 std::string convertToHex(
const std::string& str);
130 void enter_command_mode();
132 void exit_command_mode();
135 std::string read_frame();
140 std::string api_transmit_request(
const SerialNumber& dest,
const byte frame_id,
const byte* ptr,
141 const size_t length);
142 std::string api_explicit_transmit_request(
const SerialNumber& dest,
145 void process_frame();
146 void process_frame_if_available();
147 void process_frame_extended_transmit_status(
const std::string& response_string);
148 void process_frame_at_command_response(
const std::string& response_string);
149 void process_frame_receive_packet(
const std::string& response_string);
150 void process_frame_node_identification_indicator(
const std::string& response_string);
151 void process_frame_explicit_rx_indicator(
const std::string& response_string);
165 bool received_rssi_{
false};
166 bool received_er_{
false};
167 bool received_gd_{
false};
168 bool received_bc_{
false};
169 bool received_tr_{
false};
172 uint16_t current_rssi_{0};
173 uint16_t history_rssi_{0};
174 int rssi_query_count_{1};
175 uint16_t max_rssi_{0};
176 uint16_t min_rssi_{150};
177 uint16_t average_rssi_{0};
180 uint32_t bytes_transmitted_{0};
183 uint16_t received_error_count_{0};
186 uint16_t received_good_count_{0};
189 uint16_t transmission_failure_count_{0};
191 std::string my_xbee_info_location_{
""};
std::vector< NodeId > get_peers()
void add_peer(const NodeId node_id, const SerialNumber serial_number)
static const NodeId broadcast
uint16_t max_payload_size
void send_packet(const NodeId &dest, const std::string &s)
std::vector< std::string > get_packets()
void startup(const std::string &port_name, const int baud_rate, const NodeId &my_node_id, const uint16_t network_id, const std::string &xbee_info_location, const bool &use_encryption, const std::string &encryption_password)
void send_test_links(const NodeId &dest, const NodeId &com_dest)
void send_diagnostic_commands()
Packet(const NodeId &dest, const std::string &data)