-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathtelem_forwarder_client.h
49 lines (38 loc) · 1.31 KB
/
telem_forwarder_client.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "INIReader.h"
#ifdef _WIN32
#include <Winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include "telem_client.h"
class Telem_Forwarder_Client : public Telem_Client {
public:
Telem_Forwarder_Client() :
Telem_Client()
{ }
uint32_t handle_recv();
void init() override;
void configure(INIReader *config) override;
void pack_select_fds(fd_set &fds_read, fd_set &fds_write, fd_set &fds_err, uint8_t &nfds) override;
void handle_select_fds(fd_set &fds_read, fd_set &fds_write, fd_set &fds_err, uint8_t &nfds) override;
void do_writer_sends() override;
bool send_message(const mavlink_message_t &msg) override;
bool any_data_to_send() override {
return _send_buf_start != _send_buf_stop;
}
void set_address(std::string ip, uint16_t port);
private:
int fd_telem_forwarder = -1;
struct sockaddr_in sa; // our send-from address
struct sockaddr_in sa_tf; /* telem_forwarder's address */
void create_and_bind();
void pack_telem_forwarder_sockaddr(INIReader *config);
bool sane_telem_forwarder_packet(uint8_t *pkt, uint16_t bpktlen);
/* send buffer stuff: */
mavlink_message_t _send_buf[256]; // way too bug?
uint32_t send_buf_size() const override {
return 256;
}
};