2021-03-29 21:08:29 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "pico/stdlib.h"
|
2021-04-07 23:25:08 +01:00
|
|
|
#include <string>
|
2021-04-12 18:03:56 +01:00
|
|
|
#include "spi_drv.hpp"
|
2021-03-29 21:08:29 +01:00
|
|
|
|
|
|
|
namespace pimoroni {
|
|
|
|
|
|
|
|
class IPAddress {
|
|
|
|
//--------------------------------------------------
|
|
|
|
// Variables
|
|
|
|
//--------------------------------------------------
|
|
|
|
private:
|
|
|
|
union {
|
2021-04-12 18:03:56 +01:00
|
|
|
uint8_t bytes[WL_IPV4_LENGTH];
|
2021-03-29 21:08:29 +01:00
|
|
|
uint32_t dword;
|
|
|
|
} addr;
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
// Constructors/Destructor
|
|
|
|
//--------------------------------------------------
|
|
|
|
public:
|
|
|
|
IPAddress();
|
|
|
|
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
|
|
|
|
IPAddress(uint32_t address);
|
|
|
|
IPAddress(const uint8_t *address);
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
// Operators
|
|
|
|
//--------------------------------------------------
|
|
|
|
public:
|
|
|
|
bool operator==(const IPAddress &address) const;
|
|
|
|
bool operator==(const uint32_t &address) const;
|
|
|
|
uint8_t operator[](int index) const;
|
|
|
|
uint8_t& operator[](int index);
|
|
|
|
IPAddress& operator=(uint32_t address);
|
|
|
|
operator uint32_t() const;
|
2021-04-12 18:03:56 +01:00
|
|
|
std::string to_string() const;
|
|
|
|
const uint8_t* to_bytes() const;
|
2021-03-29 21:08:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|