Skip to content

Commit 3603a5a

Browse files
rzrhobinjk
authored andcommitted
ethernet: Add STM32duimo Support
It was tested on nucleo-f767zi, with a couple of hack for SDK (see URL) maybe other boards could be supported in future too. Change-Id: Ie51c889151dbfb31595c222f170379181a10d086 Relate-to: https://github.com/rzr/webthing-iotjs/wiki/MCU Signed-off-by: Philippe Coval <[email protected]>
1 parent 4dc9d72 commit 3603a5a

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

EthernetWebThingAdapter.h

+23-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,26 @@
1515
#if !defined(ESP32) && !defined(ESP8266)
1616

1717
#include <Arduino.h>
18+
19+
#if defined(STM32F7xx)
20+
#include <LwIP.h>
21+
#include <STM32Ethernet.h>
22+
#else
1823
#include <Ethernet.h>
1924
#include <EthernetClient.h>
2025
#include <EthernetServer.h>
2126
#include <EthernetUdp.h>
2227
#include <Dhcp.h>
2328
#include <Dns.h>
29+
#define CONFIG_MDNS 1
30+
#endif
2431

32+
#ifdef CONFIG_MDNS
2533
#include <ArduinoMDNS.h>
34+
EthernetUDP udp;
35+
MDNS mdns(udp);
36+
#endif
37+
2638
#include <ArduinoJson.h>
2739

2840
#include "Thing.h"
@@ -48,7 +60,11 @@ enum ReadState {
4860

4961
class WebThingAdapter {
5062
public:
51-
WebThingAdapter(String _name, uint32_t _ip): name(_name), server(80), mdns(udp) {
63+
WebThingAdapter(String _name, uint32_t _ip): name(_name), server(80)
64+
#ifdef CONFIG_MDNS
65+
, mdns(udp)
66+
#endif
67+
{
5268
ip = "";
5369
for (int i = 0; i < 4; i++) {
5470
ip += _ip & 0xff;
@@ -60,19 +76,21 @@ class WebThingAdapter {
6076
}
6177

6278
void begin() {
79+
#ifdef CONFIG_MDNS
6380
mdns.begin(Ethernet.localIP(), name.c_str());
6481

6582
mdns.addServiceRecord("_webthing",
6683
80,
6784
MDNSServiceTCP,
6885
"\x06path=/");
69-
86+
#endif
7087
server.begin();
7188
}
7289

7390
void update() {
91+
#ifdef CONFIG_MDNS
7492
mdns.run();
75-
93+
#endif
7694
if (!client) {
7795
EthernetClient client = server.available();
7896
if (!client) {
@@ -203,8 +221,10 @@ class WebThingAdapter {
203221
String name, ip;
204222
EthernetServer server;
205223
EthernetClient client;
224+
#ifdef CONFIG_MDNS
206225
EthernetUDP udp;
207226
MDNS mdns;
227+
#endif
208228

209229
ReadState state = STATE_READ_METHOD;
210230
String uri = "";

0 commit comments

Comments
 (0)