Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/EtherCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,23 @@ uint16_t EtherCard::delaycnt = 0; //request gateway ARP lookup
uint8_t EtherCard::begin (const uint16_t size,
const uint8_t* macaddr,
uint8_t csPin) {
copyMac(mymac, macaddr);
return begin(size, csPin);
}

uint8_t EtherCard::begin (const uint16_t size,
const __FlashStringHelper *macaddr,
uint8_t csPin) {
copyMac(mymac, macaddr);
return begin(size, csPin);
}

/// helper for EtherCard::begin(3)
inline uint8_t EtherCard::begin (const uint16_t size, uint8_t csPin) {
using_dhcp = false;
#if ETHERCARD_STASH
Stash::initMap();
#endif
copyMac(mymac, macaddr);
return initialize(size, mymac, csPin);
}

Expand Down
23 changes: 23 additions & 0 deletions src/EtherCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ class EtherCard : public Ethernet {
*/
static uint8_t begin (const uint16_t size, const uint8_t* macaddr,
uint8_t csPin = SS);
/** @brief Initialise the network interface using a MAC in PROGMEM
* @param size Size of data buffer
* @param macaddr Hardware address to assign to the network interface (6 bytes), read from program space
* @param csPin Arduino pin number connected to chip select. Default = 8
* @return <i>uint8_t</i> Firmware version or zero on failure.
*/
static uint8_t begin (const uint16_t size, const __FlashStringHelper * macaddr,
uint8_t csPin = SS);

/** @brief Configure network interface with static IP
* @param my_ip IP address (4 bytes). 0 for no change.
Expand Down Expand Up @@ -394,6 +402,13 @@ class EtherCard : public Ethernet {
*/
static void copyMac (uint8_t *dst, const uint8_t *src);

/** @brief Copies a hardware address from PROGMEM
* @param dst Pointer to the 6 byte destination
* @param src Pointer to the 6 byte destination in program space
* @note There is no check of source or destination size. Ensure both are 6 bytes
*/
static void copyMac (uint8_t *dst, const __FlashStringHelper *src);

/** @brief Output to serial port in dotted decimal IP format
* @param buf Pointer to 4 byte IP address
* @note There is no check of source or destination size. Ensure both are 4 bytes
Expand Down Expand Up @@ -469,6 +484,14 @@ class EtherCard : public Ethernet {
/** @brief Return the payload length of the current Tcp package
*/
static uint16_t getTcpPayloadLength();
private:
/** @brief Initialise the network interface
* @param size Size of data buffer
* @param csPin Arduino pin number connected to chip select. Default = 8
* @return <i>uint8_t</i> Firmware version or zero on failure.
* @note assumes the MAC address has already been set
*/
inline static uint8_t begin (const uint16_t size, uint8_t csPin = SS);
};

extern EtherCard ether; //!< Global presentation of EtherCard class
Expand Down
4 changes: 4 additions & 0 deletions src/webutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ void EtherCard::copyMac (uint8_t *dst, const uint8_t *src) {
memcpy(dst, src, ETH_LEN);
}

void EtherCard::copyMac (uint8_t *dst, const __FlashStringHelper *src) {
memcpy_P(dst, src, ETH_LEN);
}

void EtherCard::printIp (const char* msg, const uint8_t *buf) {
Serial.print(msg);
EtherCard::printIp(buf);
Expand Down