Ethernet_W5500/README.md
2024-10-28 17:55:14 +03:00

61 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Внесение изменений для совместимости
Для обеспечения совместимости с библиотекой `Ethernet3` потребуется внести изменения в файлы `EthernetClient.h` и `EthernetUdp3.h`. Следуйте инструкциям ниже.
### Изменение в `EthernetClient.h`
В файле `EthernetClient.h` замените доступ к переменным с `private` на `protected` для следующих элементов:
```cpp
class EthernetClient : public Client {
// ...
protected: // <--- замените 'private' на 'protected'
static uint16_t _srcport;
uint8_t _sock;
};
```
### Изменение в `EthernetUdp3.h`
В файле `EthernetUdp3.h` также замените доступ к переменным с `private` на `protected`:
```cpp
class EthernetUDP : public UDP {
protected: // <--- замените 'private' на 'protected'
uint8_t _sock; // socket ID for Wiz5100
// ...
};
```
### Изменение в `EthernetServer.h`
В файле `EthernetServer.h` также замените доступ к переменным с `private` на `protected`:
```cpp
class EthernetServer :
public Server {
protected: // <--- замените 'private' на 'protected'
uint16_t _port;
void accept();
//...
};
```
Эти изменения необходимы для обеспечения доступа к соответствующим членам класса при наследовании.
## Обратите внимание
При работе с библиотекой `Ethernet3` версии 3 требуется отдельно указывать CS пин для инициализации. Пример кода:
```cpp
void setup() {
// ...
Ethernet.setCsPin(W5500_CS_PIN);
Ethernet.init();
Ethernet.begin(mac, localIP, gateway, gateway, subnet);
// ...
}
```
Не забудьте правильно настроить `W5500_CS_PIN` и сетевые параметры (`mac`, `localIP`, `gateway`, `subnet`) в зависимости от вашей конфигурации.
```