TrippyLighting / EthernetBonjour

Bonjour Library for Arduino & Teensyduino
53 stars 46 forks source link

Compile issues #14

Open Hemonster opened 5 years ago

Hemonster commented 5 years ago

Hi there,

I'm trying to use EthernetBonjour using a W5500 Wiznet ethernet controller, hence using Ethernet2.h library. I've been trying to get the DiscoverServices.ino example project to run, but I'm facing a few issues.

Firstly I corrected wiring.h to wiring_private.h after reading similar issue with that on other forums. In EthernetBonjour.cpp: extern "C" {

include "wiring_private.h"

include <utility/EthernetUtil.h>

}

In EhternetCompat.cpp I replaced all instances of W5100 in the file to W5500.

In DiscoveringServices.ino I changed

include

to

include

All is working hardware wise when using Ethernet2 with UDP as well as MQTT, so I know there is no issues with hardware talking to server running on Win7. What I would like is to use Bonjour discovery services to find an "mqtt" service on the network (which will be hosted eventually by a RasPi), so I don't have to hard code the IP address into each of the client nodes - instead they automagically find the broker to connect to if present.

However I'm getting compile errors compiling the DiscoveringServices.ino as shown in file attached: DiscoveringServices.ino.error.txt

Can somebody help me with this?

Hemonster

DeltaCore commented 5 years ago

Oh my,

i will try to look at it in my lunch break. Haven't seen that much conflicts in a while.

Deltacore

Hemonster commented 5 years ago

Thanks Marcel, you're a champ! I hope you can help. BTW, I'm using a Nano 3.0 board with a 328p controller - I think the code will fit, but it is pretty tight in there.

In the worst case I will probably go back to UDP broadcast instead, but I thought it would be nice to use this wonderful code that somebody wrote ;)

DeltaCore commented 5 years ago

Ok.

I tried the example code. It compiles fine with 2 changes to the eth lib: EthernetBonjour.cpp: change

#include <Ethernet.h>
#include <EthernetUdp.h>

to

#include <Ethernet2.h>
#include <EthernetUdp2.h>

EthernetBonjour.h: change

extern "C" {
    #include <inttypes.h>
}

to

extern "C" {
    #include <Ethernet2.h>
    #include <inttypes.h>
}

After that it worked fine. What i would suggest is that you may try to reinstall the library. The fix with the wiring_private.h was not needed and it maybe that the error came from there.

I must admit i tried it using platformio just because i don't have the arduino ide not installed on my pc at work.

If you want to try it out yourself with platformio, clone this repo (https://git.ccmob.net/marcel/eth2-eth-bonjour-test) and run it with vscode or something (See http://docs.platformio.org/en/latest/ide/vscode.html#installation):

In that repo is the main file i used and the modified ethernetbonjour library i used.

Had problems with the arduino ide in the past aswell. Platformio was more reliable and vscode faster that the arduino ide. Maybe a bit of work the get used to but was worth it for me atleast ^^

Deltacore

DeltaCore commented 5 years ago

What i forgot:

i was using the leonardo ethernet, had nothing else here, but your problems where with the compiling it's self so that should not matter in my opinion.

DeltaCore

Hemonster commented 5 years ago

Thanks so much Marcel for your quick work on this, I appreciate it.

I was using the code base from this website: http://gkaindl.com/software/arduino-ethernet/bonjour

... which I think is older than the one on this repo as well (that was not helping). I will try your suggestions and report back.

TrippyLighting commented 5 years ago

I initially used the code on the Gkaindl website but then completely re-wrote parts of that code to make it mostly hardware independent and to work with Ethernet library that is delivered with the Teensy boards. I've not had a chance to look at this in a long time.

Hemonster commented 5 years ago

Thanks so much Marcel!

Actually it turns out the code I was running was from this website: http://gkaindl.com/software/arduino-ethernet/bonjour

... and not from this repo. When I downloaded this repo and put it in the libraries folder, I note that EthernetCompat.cpp/h are not there. So I'm getting this error message now:

C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:21:36: fatal error: utility/EthernetCompat.h: No such file or directory

include <utility/EthernetCompat.h>

                                ^

compilation terminated.

Hemonster commented 5 years ago

Hi Marcel,

I had to reinstall Arduino IDE because Win7 was caching the previous EthernetBonjour source files and I was getting issues when compiling with updated files, even after your proposed changes. I've have since reinstalled the IDE to a different location on C drive and retried. I've managed to again compile Ethernet2 library sample code successfully.

I've implemented your changes for Ethernet Bonjour, and tried to recompile the DiscoveryServices sample code, but I'm getting this issue: C:\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:148:22: error: 'class EthernetBonjourClass' has no member named 'beginMulticast'

statusCode = this->beginMulticast(mdnsMulticastIPAddr, MDNS_SERVER_PORT);

Any ideas?

DeltaCore commented 5 years ago

Hi @Hemonster,

sadly i have no idea from ontop of my head. I'll be out on the weekend so i can't do much about that right now. Monday i will have time again. Untill then you have to patient or someone else has a look into it ^^

Marcel

Hemonster commented 5 years ago

No worries Marcel, thanks again. I'll poke around it myself and see if I can find out what is wrong.

On Fri, 7 Sep 2018 at 19:14, Marcel notifications@github.com wrote:

Hi @Hemonster https://github.com/Hemonster,

sadly i have no idea from ontop of my head. I'll be out on the weekend so i can't do much about that right now. Monday i will have time again. Untill then you have to patient or someone else has a look into it ^^

Marcel

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TrippyLighting/EthernetBonjour/issues/14#issuecomment-419345897, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY8SG5Sg2wMM6a5uMcVOmmWO2wUtdI4ks5uYhzIgaJpZM4Wakzf .

Hemonster commented 5 years ago

FYI ... I have attached the error file. DiscoveringServices.ino.error.txt

Hemonster commented 5 years ago

I think this is the similar issue here: "https://github.com/TrippyLighting/EthernetBonjour/issues/2"

Requires mods to EthernetUDP2 in my case, and of course changing EthernetBonjour.cpp line 148 to this:

    if (statusCode)
//      statusCode = this->beginMulticast(mdnsMulticastIPAddr, MDNS_SERVER_PORT);
      statusCode = EthernetUDP.beginMulti(mdnsMulticastIPAddr, MDNS_SERVER_PORT); 

Having made changes, I'm getting this error now:

In file included from C:\Arduino\libraries\Ethernet2\src/Dhcp.h:7:0,

                 from C:\Arduino\libraries\Ethernet2\src/Ethernet2.h:18,

                 from C:\Users\Hemon\Desktop\DiscoveringServices\DiscoveringServices\DiscoveringServices.ino:24:

C:\Arduino\libraries\Ethernet2\src/EthernetUdp2.h:51:1: error: 'friend' used outside of class

 friend class EthernetBonjourClass;

 ^

Full error file: DiscoveringServices.ino.error.txt

Source files attached.

EthernetUDP2 modified.zip EthernetBonjour modified.zip

Is there something obvious?

DeltaCore commented 5 years ago

Hello @Hemonster,

i am having trouble to understand why there is the line friend class EthernetBonjourClass; at line 51 in the EthernetUdp2.h

There is no need for that. You don't have to modify the Ethernet2 lib. Just use it as is. The only thing you need todo is to modify the imports of the bonjour lib.

You should be fine if you remove that line.

Marcel

DeltaCore commented 5 years ago

I just tried to compile it using the fix with Arduino 1.8.2 at home. I changed the said lines i showed in my prev. post and updated the example sketch to use Ethernet2.h instead of Ethernet.h.

Set the Board to Arduino Ethernet and compiled it successfully.

Marcel

Hemonster commented 5 years ago

Hi Marcel,

I managed to get it to compile, by removing the "friend class" line, and

changing in EthernetBonjour.CPP: EthernetUPD.beginMulti (...) to this->beginMulti(...)

I'll give it more of a test once I've figured how to get Bonjour working on the python side to adversite the "mqtt" service to see if I can discover it.

Thanks for your help!