2016-02-17 21:25:26 -04:00
|
|
|
#pragma once
|
2015-06-19 10:58:40 -03:00
|
|
|
|
|
|
|
#include "SerialDevice.h"
|
2015-08-15 19:50:47 -03:00
|
|
|
#include <AP_HAL/utility/Socket.h>
|
2015-06-19 10:58:40 -03:00
|
|
|
|
2015-07-08 14:27:21 -03:00
|
|
|
class TCPServerDevice: public SerialDevice {
|
2015-06-19 10:58:40 -03:00
|
|
|
public:
|
2015-07-28 20:37:57 -03:00
|
|
|
TCPServerDevice(const char *ip, uint16_t port, bool wait);
|
2015-07-08 14:27:21 -03:00
|
|
|
virtual ~TCPServerDevice();
|
2015-06-19 10:58:40 -03:00
|
|
|
|
|
|
|
virtual bool open() override;
|
|
|
|
virtual bool close() override;
|
|
|
|
virtual void set_blocking(bool blocking) override;
|
|
|
|
virtual void set_speed(uint32_t speed) override;
|
|
|
|
virtual ssize_t write(const uint8_t *buf, uint16_t n) override;
|
|
|
|
virtual ssize_t read(uint8_t *buf, uint16_t n) override;
|
2015-07-28 20:37:57 -03:00
|
|
|
|
2015-06-19 10:58:40 -03:00
|
|
|
private:
|
|
|
|
SocketAPM listener{false};
|
2016-10-30 02:24:21 -03:00
|
|
|
SocketAPM *sock = nullptr;
|
2015-06-19 10:58:40 -03:00
|
|
|
const char *_ip;
|
|
|
|
uint16_t _port;
|
2015-07-28 20:37:57 -03:00
|
|
|
bool _wait;
|
|
|
|
bool _blocking = false;
|
2015-07-28 20:55:47 -03:00
|
|
|
uint32_t _last_bind_warning = 0;
|
2015-06-19 10:58:40 -03:00
|
|
|
};
|