Cleaned up Doxygen warnings in library drivers
This commit is contained in:
@@ -39,34 +39,35 @@
|
|||||||
#define ALTSS_BASE_FREQ F_CPU
|
#define ALTSS_BASE_FREQ F_CPU
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** AltSoftSerial class */
|
||||||
class AltSoftSerial : public Stream
|
class AltSoftSerial : public Stream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AltSoftSerial() { }
|
AltSoftSerial() { } //!< Constructor
|
||||||
~AltSoftSerial() { end(); }
|
~AltSoftSerial() { end(); } //!< Destructor
|
||||||
static void begin(uint32_t baud) { init((ALTSS_BASE_FREQ + baud / 2) / baud); }
|
static void begin(uint32_t baud) { init((ALTSS_BASE_FREQ + baud / 2) / baud); } //!< begin
|
||||||
static void end();
|
static void end(); //!< end
|
||||||
int peek();
|
int peek(); //!< peek
|
||||||
int read();
|
int read(); //!< read
|
||||||
int available();
|
int available(); //!< available
|
||||||
#if ARDUINO >= 100
|
#if ARDUINO >= 100
|
||||||
size_t write(uint8_t byte) { writeByte(byte); return 1; }
|
size_t write(uint8_t byte) { writeByte(byte); return 1; } //!< write
|
||||||
void flush() { flushOutput(); }
|
void flush() { flushOutput(); } //!< flush
|
||||||
#else
|
#else
|
||||||
void write(uint8_t byte) { writeByte(byte); }
|
void write(uint8_t byte) { writeByte(byte); } //!< write
|
||||||
void flush() { flushInput(); }
|
void flush() { flushInput(); } //!< flush
|
||||||
#endif
|
#endif
|
||||||
using Print::write;
|
using Print::write;
|
||||||
static void flushInput();
|
static void flushInput(); //!< flushInput
|
||||||
static void flushOutput();
|
static void flushOutput(); //!< flushOutput
|
||||||
// for drop-in compatibility with NewSoftSerial, rxPin & txPin ignored
|
// for drop-in compatibility with NewSoftSerial, rxPin & txPin ignored
|
||||||
//AltSoftSerial(uint8_t rxPin, uint8_t txPin, bool inverse = false) { }
|
//AltSoftSerial(uint8_t rxPin, uint8_t txPin, bool inverse = false) { }
|
||||||
bool listen() { return false; }
|
bool listen() { return false; } //!< listen
|
||||||
bool isListening() { return true; }
|
bool isListening() { return true; } //!< isListening
|
||||||
bool overflow() { bool r = timing_error; timing_error = false; return r; }
|
bool overflow() { bool r = timing_error; timing_error = false; return r; } //!< overflow
|
||||||
static int library_version() { return 1; }
|
static int library_version() { return 1; } //!< library_version
|
||||||
static void enable_timer0(bool) { }
|
static void enable_timer0(bool) { } //!< enable_timer0
|
||||||
static bool timing_error;
|
static bool timing_error; //!< timing_error
|
||||||
private:
|
private:
|
||||||
static void init(uint32_t cycles_per_bit);
|
static void init(uint32_t cycles_per_bit);
|
||||||
static void writeByte(uint8_t byte);
|
static void writeByte(uint8_t byte);
|
||||||
|
|||||||
@@ -72,19 +72,20 @@
|
|||||||
#define RF69_BROADCAST_ADDR 255
|
#define RF69_BROADCAST_ADDR 255
|
||||||
#define RF69_CSMA_LIMIT_MS 1000
|
#define RF69_CSMA_LIMIT_MS 1000
|
||||||
|
|
||||||
|
/** RFM69 class */
|
||||||
class RFM69 {
|
class RFM69 {
|
||||||
public:
|
public:
|
||||||
static volatile byte DATA[RF69_MAX_DATA_LEN]; // recv/xmit buf, including hdr & crc bytes
|
static volatile byte DATA[RF69_MAX_DATA_LEN]; //!< recv/xmit buf, including hdr & crc bytes
|
||||||
static volatile byte DATALEN;
|
static volatile byte DATALEN; //!< DATALEN
|
||||||
static volatile byte SENDERID;
|
static volatile byte SENDERID; //!< SENDERID
|
||||||
static volatile byte TARGETID; //should match _address
|
static volatile byte TARGETID; //!< should match _address
|
||||||
static volatile byte PAYLOADLEN;
|
static volatile byte PAYLOADLEN; //!< PAYLOADLEN
|
||||||
static volatile byte ACK_REQUESTED;
|
static volatile byte ACK_REQUESTED; //!< ACK_REQUESTED
|
||||||
static volatile byte ACK_RECEIVED; /// Should be polled immediately after sending a packet with ACK request
|
static volatile byte ACK_RECEIVED; //!< Should be polled immediately after sending a packet with ACK request
|
||||||
static volatile int RSSI; //most accurate RSSI during reception (closest to the reception)
|
static volatile int RSSI; //!< most accurate RSSI during reception (closest to the reception)
|
||||||
static volatile byte _mode; //should be protected?
|
static volatile byte _mode; //!< should be protected?
|
||||||
|
|
||||||
RFM69(byte slaveSelectPin=RF69_SPI_CS, byte interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, byte interruptNum=RF69_IRQ_NUM) {
|
RFM69(byte slaveSelectPin=RF69_SPI_CS, byte interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, byte interruptNum=RF69_IRQ_NUM) { //!< Constructor
|
||||||
_slaveSelectPin = slaveSelectPin;
|
_slaveSelectPin = slaveSelectPin;
|
||||||
_interruptPin = interruptPin;
|
_interruptPin = interruptPin;
|
||||||
_interruptNum = interruptNum;
|
_interruptNum = interruptNum;
|
||||||
@@ -94,52 +95,52 @@ class RFM69 {
|
|||||||
_isRFM69HW = isRFM69HW;
|
_isRFM69HW = isRFM69HW;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool initialize(byte freqBand, byte ID, byte networkID=1);
|
bool initialize(byte freqBand, byte ID, byte networkID=1); //!< initialize
|
||||||
void setAddress(byte addr);
|
void setAddress(byte addr); //!< setAddress
|
||||||
bool canSend();
|
bool canSend(); //!< canSend
|
||||||
void send(byte toAddress, const void* buffer, byte bufferSize, bool requestACK=false);
|
void send(byte toAddress, const void* buffer, byte bufferSize, bool requestACK=false); //!< send
|
||||||
bool sendWithRetry(byte toAddress, const void* buffer, byte bufferSize, byte retries=2, byte retryWaitTime=40); //40ms roundtrip req for 61byte packets
|
bool sendWithRetry(byte toAddress, const void* buffer, byte bufferSize, byte retries=2, byte retryWaitTime=40); //!< sendWithRetry (40ms roundtrip req for 61byte packets)
|
||||||
bool receiveDone();
|
bool receiveDone(); //!< receiveDone
|
||||||
bool ACKReceived(byte fromNodeID);
|
bool ACKReceived(byte fromNodeID); //!< ACKReceived
|
||||||
bool ACKRequested();
|
bool ACKRequested(); //!< ACKRequested
|
||||||
void sendACK(const void* buffer = "", uint8_t bufferSize=0);
|
void sendACK(const void* buffer = "", uint8_t bufferSize=0); //!< sendACK
|
||||||
void setFrequency(uint32_t FRF);
|
void setFrequency(uint32_t FRF); //!< setFrequency
|
||||||
void encrypt(const char* key);
|
void encrypt(const char* key); //!< encrypt
|
||||||
void setCS(byte newSPISlaveSelect);
|
void setCS(byte newSPISlaveSelect); //!< setCS
|
||||||
int readRSSI(bool forceTrigger=false);
|
int readRSSI(bool forceTrigger=false); //!< readRSSI
|
||||||
void promiscuous(bool onOff=true);
|
void promiscuous(bool onOff=true); //!< promiscuous
|
||||||
void setHighPower(bool onOFF=true); //have to call it after initialize for RFM69HW
|
void setHighPower(bool onOFF=true); //!< setHighPower (have to call it after initialize for RFM69HW)
|
||||||
void setPowerLevel(byte level); //reduce/increase transmit power level
|
void setPowerLevel(byte level); //!< setPowerLevel (reduce/increase transmit power level)
|
||||||
void sleep();
|
void sleep(); //!< sleep
|
||||||
byte readTemperature(byte calFactor=0); //get CMOS temperature (8bit)
|
byte readTemperature(byte calFactor=0); //!< readTemperature (get CMOS temperature (8bit))
|
||||||
void rcCalibration(); //calibrate the internal RC oscillator for use in wide temperature variations - see datasheet section [4.3.5. RC Timer Accuracy]
|
void rcCalibration(); //!< rcCalibration (calibrate the internal RC oscillator for use in wide temperature variations - see datasheet section [4.3.5. RC Timer Accuracy])
|
||||||
|
|
||||||
// allow hacking registers by making these public
|
// allow hacking registers by making these public
|
||||||
byte readReg(byte addr);
|
byte readReg(byte addr); //!< readReg
|
||||||
void writeReg(byte addr, byte val);
|
void writeReg(byte addr, byte val); //!< writeReg
|
||||||
void readAllRegs();
|
void readAllRegs(); //!< readAllRegs
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void isr0();
|
static void isr0(); //!< isr0
|
||||||
void virtual interruptHandler();
|
void virtual interruptHandler(); //!< interruptHandler
|
||||||
void sendFrame(byte toAddress, const void* buffer, byte size, bool requestACK=false, bool sendACK=false);
|
void sendFrame(byte toAddress, const void* buffer, byte size, bool requestACK=false, bool sendACK=false); //!< sendFrame
|
||||||
|
|
||||||
static RFM69* selfPointer;
|
static RFM69* selfPointer; //!< selfPointer
|
||||||
byte _slaveSelectPin;
|
byte _slaveSelectPin; //!< _slaveSelectPin
|
||||||
byte _interruptPin;
|
byte _interruptPin; //!< _interruptPin
|
||||||
byte _interruptNum;
|
byte _interruptNum; //!< _interruptNum
|
||||||
byte _address;
|
byte _address; //!< _address
|
||||||
bool _promiscuousMode;
|
bool _promiscuousMode; //!< _promiscuousMode
|
||||||
byte _powerLevel;
|
byte _powerLevel; //!< _powerLevel
|
||||||
bool _isRFM69HW;
|
bool _isRFM69HW; //!< _isRFM69HW
|
||||||
byte _SPCR;
|
byte _SPCR; //!< _SPCR
|
||||||
byte _SPSR;
|
byte _SPSR; //!< _SPSR
|
||||||
|
|
||||||
void receiveBegin();
|
void receiveBegin(); //!< receiveBegin
|
||||||
void setMode(byte mode);
|
void setMode(byte mode); //!< setMode
|
||||||
void setHighPowerRegs(bool onOff);
|
void setHighPowerRegs(bool onOff); //!< setHighPowerRegs
|
||||||
void select();
|
void select(); //!< select
|
||||||
void unselect();
|
void unselect(); //!< unselect
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -87,34 +87,35 @@
|
|||||||
// Example for Winbond 4Mbit W25X40CL: 0xEF30 (page 14: http://www.winbond.com/NR/rdonlyres/6E25084C-0BFE-4B25-903D-AE10221A0929/0/W25X40CL.pdf)
|
// Example for Winbond 4Mbit W25X40CL: 0xEF30 (page 14: http://www.winbond.com/NR/rdonlyres/6E25084C-0BFE-4B25-903D-AE10221A0929/0/W25X40CL.pdf)
|
||||||
#define SPIFLASH_MACREAD 0x4B // read unique ID number (MAC)
|
#define SPIFLASH_MACREAD 0x4B // read unique ID number (MAC)
|
||||||
|
|
||||||
|
/** SPIFlash class */
|
||||||
class SPIFlash {
|
class SPIFlash {
|
||||||
public:
|
public:
|
||||||
static uint8_t UNIQUEID[8];
|
static uint8_t UNIQUEID[8]; //!< Storage for unique identifier
|
||||||
SPIFlash(uint8_t slaveSelectPin, uint16_t jedecID=0);
|
SPIFlash(uint8_t slaveSelectPin, uint16_t jedecID=0); //!< Constructor
|
||||||
boolean initialize();
|
boolean initialize(); //!< setup SPI, read device ID etc...
|
||||||
void command(uint8_t cmd, boolean isWrite=false);
|
void command(uint8_t cmd, boolean isWrite=false); //!< Send a command to the flash chip, pass TRUE for isWrite when its a write command
|
||||||
uint8_t readStatus();
|
uint8_t readStatus(); //!< return the STATUS register
|
||||||
uint8_t readByte(uint32_t addr);
|
uint8_t readByte(uint32_t addr); //!< read 1 byte from flash memory
|
||||||
void readBytes(uint32_t addr, void* buf, uint16_t len);
|
void readBytes(uint32_t addr, void* buf, uint16_t len); //!< read unlimited # of bytes
|
||||||
void writeByte(uint32_t addr, uint8_t byt);
|
void writeByte(uint32_t addr, uint8_t byt); //!< Write 1 byte to flash memory
|
||||||
void writeBytes(uint32_t addr, const void* buf, uint16_t len);
|
void writeBytes(uint32_t addr, const void* buf, uint16_t len); //!< write multiple bytes to flash memory (up to 64K)
|
||||||
boolean busy();
|
boolean busy(); //!< check if the chip is busy erasing/writing
|
||||||
void chipErase();
|
void chipErase(); //!< erase entire flash memory array
|
||||||
void blockErase4K(uint32_t address);
|
void blockErase4K(uint32_t address); //!< erase a 4Kbyte block
|
||||||
void blockErase32K(uint32_t address);
|
void blockErase32K(uint32_t address); //!< erase a 32Kbyte block
|
||||||
uint16_t readDeviceId();
|
uint16_t readDeviceId(); //!< Get the manufacturer and device ID bytes (as a short word)
|
||||||
uint8_t* readUniqueId();
|
uint8_t* readUniqueId(); //!< Get the 64 bit unique identifier, stores it in @ref UNIQUEID[8]
|
||||||
|
|
||||||
void sleep();
|
void sleep(); //!< Put device to sleep
|
||||||
void wakeup();
|
void wakeup(); //!< Wake device
|
||||||
void end();
|
void end(); //!< end
|
||||||
protected:
|
protected:
|
||||||
void select();
|
void select(); //!< select
|
||||||
void unselect();
|
void unselect(); //!< unselect
|
||||||
uint8_t _slaveSelectPin;
|
uint8_t _slaveSelectPin; //!< Slave select pin
|
||||||
uint16_t _jedecID;
|
uint16_t _jedecID; //!< JEDEC ID
|
||||||
uint8_t _SPCR;
|
uint8_t _SPCR; //!< SPCR
|
||||||
uint8_t _SPSR;
|
uint8_t _SPSR; //!< SPSR
|
||||||
#ifdef SPI_HAS_TRANSACTION
|
#ifdef SPI_HAS_TRANSACTION
|
||||||
SPISettings _settings;
|
SPISettings _settings;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
|
|
||||||
#define MQTT_CALLBACK_SIGNATURE void (*callback)(char*,uint8_t*,unsigned int)
|
#define MQTT_CALLBACK_SIGNATURE void (*callback)(char*,uint8_t*,unsigned int)
|
||||||
|
|
||||||
|
/** PubSubClient class */
|
||||||
class PubSubClient {
|
class PubSubClient {
|
||||||
private:
|
private:
|
||||||
Client* _client;
|
Client* _client;
|
||||||
@@ -83,44 +84,44 @@ private:
|
|||||||
Stream* stream;
|
Stream* stream;
|
||||||
int _state;
|
int _state;
|
||||||
public:
|
public:
|
||||||
PubSubClient();
|
PubSubClient(); //!< PubSubClient
|
||||||
PubSubClient(Client& client);
|
PubSubClient(Client& client); //!< PubSubClient
|
||||||
PubSubClient(IPAddress, uint16_t, Client& client);
|
PubSubClient(IPAddress, uint16_t, Client& client); //!< PubSubClient
|
||||||
PubSubClient(IPAddress, uint16_t, Client& client, Stream&);
|
PubSubClient(IPAddress, uint16_t, Client& client, Stream&); //!< PubSubClient
|
||||||
PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
|
PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client); //!< PubSubClient
|
||||||
PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
|
PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&); //!< PubSubClient
|
||||||
PubSubClient(uint8_t *, uint16_t, Client& client);
|
PubSubClient(uint8_t *, uint16_t, Client& client); //!< PubSubClient
|
||||||
PubSubClient(uint8_t *, uint16_t, Client& client, Stream&);
|
PubSubClient(uint8_t *, uint16_t, Client& client, Stream&); //!< PubSubClient
|
||||||
PubSubClient(uint8_t *, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
|
PubSubClient(uint8_t *, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client); //!< PubSubClient
|
||||||
PubSubClient(uint8_t *, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
|
PubSubClient(uint8_t *, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&); //!< PubSubClient
|
||||||
PubSubClient(const char*, uint16_t, Client& client);
|
PubSubClient(const char*, uint16_t, Client& client); //!< PubSubClient
|
||||||
PubSubClient(const char*, uint16_t, Client& client, Stream&);
|
PubSubClient(const char*, uint16_t, Client& client, Stream&); //!< PubSubClient
|
||||||
PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
|
PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client); //!< PubSubClient
|
||||||
PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
|
PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&); //!< PubSubClient
|
||||||
|
|
||||||
PubSubClient& setServer(IPAddress ip, uint16_t port);
|
PubSubClient& setServer(IPAddress ip, uint16_t port); //!< setServer
|
||||||
PubSubClient& setServer(uint8_t * ip, uint16_t port);
|
PubSubClient& setServer(uint8_t * ip, uint16_t port); //!< setServer
|
||||||
PubSubClient& setServer(const char * domain, uint16_t port);
|
PubSubClient& setServer(const char * domain, uint16_t port); //!< setServer
|
||||||
PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE);
|
PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE); //!< setCallback
|
||||||
PubSubClient& setClient(Client& client);
|
PubSubClient& setClient(Client& client); //!< setClient
|
||||||
PubSubClient& setStream(Stream& stream);
|
PubSubClient& setStream(Stream& stream); //!< setStream
|
||||||
|
|
||||||
boolean connect(const char* id);
|
boolean connect(const char* id); //!< connect
|
||||||
boolean connect(const char* id, const char* user, const char* pass);
|
boolean connect(const char* id, const char* user, const char* pass); //!< connect
|
||||||
boolean connect(const char* id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage);
|
boolean connect(const char* id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage); //!< connect
|
||||||
boolean connect(const char* id, const char* user, const char* pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage);
|
boolean connect(const char* id, const char* user, const char* pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage); //!< connect
|
||||||
void disconnect();
|
void disconnect(); //!< disconnect
|
||||||
boolean publish(const char* topic, const char* payload);
|
boolean publish(const char* topic, const char* payload); //!< publish
|
||||||
boolean publish(const char* topic, const char* payload, boolean retained);
|
boolean publish(const char* topic, const char* payload, boolean retained); //!< publish
|
||||||
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
|
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength); //!< publish
|
||||||
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
|
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained); //!< publish
|
||||||
boolean publish_P(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
|
boolean publish_P(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained); //!< publish_P
|
||||||
boolean subscribe(const char* topic);
|
boolean subscribe(const char* topic); //!< subscribe
|
||||||
boolean subscribe(const char* topic, uint8_t qos);
|
boolean subscribe(const char* topic, uint8_t qos); //!< subscribe
|
||||||
boolean unsubscribe(const char* topic);
|
boolean unsubscribe(const char* topic); //!< unsubscribe
|
||||||
boolean loop();
|
boolean loop(); //!< loop
|
||||||
boolean connected();
|
boolean connected(); //!< connected
|
||||||
int state();
|
int state(); //!< state
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
/** Buffer class */
|
||||||
class Buffer {
|
class Buffer {
|
||||||
private:
|
private:
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
@@ -10,14 +11,14 @@ private:
|
|||||||
uint16_t length;
|
uint16_t length;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Buffer();
|
Buffer(); //!< Buffer
|
||||||
Buffer(uint8_t* buf, size_t size);
|
Buffer(uint8_t* buf, size_t size); //!< Buffer
|
||||||
|
|
||||||
virtual bool available();
|
virtual bool available(); //!< available
|
||||||
virtual uint8_t next();
|
virtual uint8_t next(); //!< next
|
||||||
virtual void reset();
|
virtual void reset(); //!< reset
|
||||||
|
|
||||||
virtual void add(uint8_t* buf, size_t size);
|
virtual void add(uint8_t* buf, size_t size); //!< add
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,20 +2,21 @@
|
|||||||
#define client_h
|
#define client_h
|
||||||
#include "IPAddress.h"
|
#include "IPAddress.h"
|
||||||
|
|
||||||
|
/** Client class */
|
||||||
class Client {
|
class Client {
|
||||||
public:
|
public:
|
||||||
virtual int connect(IPAddress ip, uint16_t port) =0;
|
virtual int connect(IPAddress ip, uint16_t port) =0; //!< connect
|
||||||
virtual int connect(const char *host, uint16_t port) =0;
|
virtual int connect(const char *host, uint16_t port) =0; //!< connect
|
||||||
virtual size_t write(uint8_t) =0;
|
virtual size_t write(uint8_t) =0; //!< write
|
||||||
virtual size_t write(const uint8_t *buf, size_t size) =0;
|
virtual size_t write(const uint8_t *buf, size_t size) =0; //!< write
|
||||||
virtual int available() = 0;
|
virtual int available() = 0; //!< available
|
||||||
virtual int read() = 0;
|
virtual int read() = 0; //!< read
|
||||||
virtual int read(uint8_t *buf, size_t size) = 0;
|
virtual int read(uint8_t *buf, size_t size) = 0; //!< read
|
||||||
virtual int peek() = 0;
|
virtual int peek() = 0; //!< peek
|
||||||
virtual void flush() = 0;
|
virtual void flush() = 0; //!< flush
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0; //!< stop
|
||||||
virtual uint8_t connected() = 0;
|
virtual uint8_t connected() = 0; //!< connected
|
||||||
virtual operator bool() = 0;
|
virtual operator bool() = 0; //!< bool operator
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
// A class to make it easier to handle and pass around IP addresses
|
// A class to make it easier to handle and pass around IP addresses
|
||||||
|
|
||||||
|
/** IPAddress class */
|
||||||
class IPAddress {
|
class IPAddress {
|
||||||
private:
|
private:
|
||||||
uint8_t _address[4]; // IPv4 address
|
uint8_t _address[4]; // IPv4 address
|
||||||
@@ -40,23 +41,30 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructors
|
// Constructors
|
||||||
IPAddress();
|
IPAddress(); //!< IPAddress
|
||||||
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
|
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); //!< IPAddress
|
||||||
IPAddress(uint32_t address);
|
IPAddress(uint32_t address); //!< IPAddress
|
||||||
IPAddress(const uint8_t *address);
|
IPAddress(const uint8_t *address); //!< IPAddress
|
||||||
|
|
||||||
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
|
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
|
||||||
// to a four-byte uint8_t array is expected
|
// to a four-byte uint8_t array is expected
|
||||||
|
/** @brief operator overload */
|
||||||
operator uint32_t() { return *((uint32_t*)_address); };
|
operator uint32_t() { return *((uint32_t*)_address); };
|
||||||
|
/** @brief operator overload */
|
||||||
bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
|
bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
|
||||||
|
/** @brief operator overload */
|
||||||
bool operator==(const uint8_t* addr);
|
bool operator==(const uint8_t* addr);
|
||||||
|
|
||||||
// Overloaded index operator to allow getting and setting individual octets of the address
|
// Overloaded index operator to allow getting and setting individual octets of the address
|
||||||
|
/** @brief operator overload */
|
||||||
uint8_t operator[](int index) const { return _address[index]; };
|
uint8_t operator[](int index) const { return _address[index]; };
|
||||||
|
/** @brief operator overload */
|
||||||
uint8_t& operator[](int index) { return _address[index]; };
|
uint8_t& operator[](int index) { return _address[index]; };
|
||||||
|
|
||||||
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
|
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
|
||||||
|
/** @brief operator overload */
|
||||||
IPAddress& operator=(const uint8_t *address);
|
IPAddress& operator=(const uint8_t *address);
|
||||||
|
/** @brief operator overload */
|
||||||
IPAddress& operator=(uint32_t address);
|
IPAddress& operator=(uint32_t address);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
/** ShimClient class */
|
||||||
class ShimClient : public Client {
|
class ShimClient : public Client {
|
||||||
private:
|
private:
|
||||||
Buffer* responseBuffer;
|
Buffer* responseBuffer;
|
||||||
@@ -22,30 +23,30 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ShimClient();
|
ShimClient();
|
||||||
virtual int connect(IPAddress ip, uint16_t port);
|
virtual int connect(IPAddress ip, uint16_t port); //!< connect
|
||||||
virtual int connect(const char *host, uint16_t port);
|
virtual int connect(const char *host, uint16_t port); //!< connect
|
||||||
virtual size_t write(uint8_t);
|
virtual size_t write(uint8_t); //!< write
|
||||||
virtual size_t write(const uint8_t *buf, size_t size);
|
virtual size_t write(const uint8_t *buf, size_t size); //!< write
|
||||||
virtual int available();
|
virtual int available(); //!< available
|
||||||
virtual int read();
|
virtual int read(); //!< read
|
||||||
virtual int read(uint8_t *buf, size_t size);
|
virtual int read(uint8_t *buf, size_t size); //!< read
|
||||||
virtual int peek();
|
virtual int peek(); //!< peek
|
||||||
virtual void flush();
|
virtual void flush(); //!< flush
|
||||||
virtual void stop();
|
virtual void stop(); //!< stop
|
||||||
virtual uint8_t connected();
|
virtual uint8_t connected(); //!< connected
|
||||||
virtual operator bool();
|
virtual operator bool(); //!< bool operator
|
||||||
|
|
||||||
virtual ShimClient* respond(uint8_t *buf, size_t size);
|
virtual ShimClient* respond(uint8_t *buf, size_t size); //!< respond
|
||||||
virtual ShimClient* expect(uint8_t *buf, size_t size);
|
virtual ShimClient* expect(uint8_t *buf, size_t size); //!< expect
|
||||||
|
|
||||||
virtual void expectConnect(IPAddress ip, uint16_t port);
|
virtual void expectConnect(IPAddress ip, uint16_t port); //!< expectConnect
|
||||||
virtual void expectConnect(const char *host, uint16_t port);
|
virtual void expectConnect(const char *host, uint16_t port); //!< expectConnect
|
||||||
|
|
||||||
virtual uint16_t received();
|
virtual uint16_t received(); //!< received
|
||||||
virtual bool error();
|
virtual bool error(); //!< error
|
||||||
|
|
||||||
virtual void setAllowConnect(bool b);
|
virtual void setAllowConnect(bool b); //!< setAllowConnect
|
||||||
virtual void setConnected(bool b);
|
virtual void setConnected(bool b); //!< setConnected
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
|
||||||
|
/** Stream class */
|
||||||
class Stream {
|
class Stream {
|
||||||
private:
|
private:
|
||||||
Buffer* expectBuffer;
|
Buffer* expectBuffer;
|
||||||
@@ -12,11 +13,11 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Stream();
|
Stream();
|
||||||
virtual size_t write(uint8_t);
|
virtual size_t write(uint8_t); //!< write
|
||||||
|
|
||||||
virtual bool error();
|
virtual bool error(); //!< error
|
||||||
virtual void expect(uint8_t *buf, size_t size);
|
virtual void expect(uint8_t *buf, size_t size); //!< expect
|
||||||
virtual uint16_t length();
|
virtual uint16_t length(); //!< length
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user