2016-02-17 21:25:26 -04:00
|
|
|
#pragma once
|
2015-06-15 18:01:14 -03:00
|
|
|
|
2023-12-25 22:21:11 -04:00
|
|
|
#include <AP_HAL/utility/Socket_native.h>
|
2015-06-15 18:01:14 -03:00
|
|
|
#include "SerialDevice.h"
|
|
|
|
|
|
|
|
class UDPDevice: public SerialDevice {
|
|
|
|
public:
|
2016-06-28 07:58:31 -03:00
|
|
|
UDPDevice(const char *ip, uint16_t port, bool bcast, bool input);
|
2015-06-15 18:01:14 -03:00
|
|
|
virtual ~UDPDevice();
|
|
|
|
|
|
|
|
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;
|
|
|
|
private:
|
2023-12-25 22:41:12 -04:00
|
|
|
SocketAPM_native socket{true};
|
2015-06-15 18:01:14 -03:00
|
|
|
const char *_ip;
|
|
|
|
uint16_t _port;
|
2015-07-29 03:46:53 -03:00
|
|
|
bool _bcast;
|
2016-06-28 07:58:31 -03:00
|
|
|
bool _input;
|
2015-07-29 03:46:53 -03:00
|
|
|
bool _connected = false;
|
2015-06-15 18:01:14 -03:00
|
|
|
};
|