New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for MQTT client #256
Conversation
Hm, the 32-bit test at Travis CI should display |
084ae10
to
9524f72
Compare
32-bit CMake cross compilation does not work at Travis CI, but I have no more ideas what and how to fix. https://travis-ci.org/modelica/Modelica_DeviceDrivers/jobs/422716533#L807 |
I believe it is same issue as http://cmake.3232098.n2.nabble.com/CMAKE-SIZEOF-VOID-P-question-td7595355.html. Cross-compilation will only work by use of artificial environment variable. See https://github.com/eclipse/paho.mqtt.c/blob/4b355d1fd48c13f47fc663af4001ff23aa9d3e5a/test/CMakeLists.txt#L21-L26 for an example. |
eb72928
to
0b74706
Compare
4d33f14 fixes the cross-compilation issue with CMake at Travis CI in master. |
aebc69c
to
359d6d4
Compare
Built at drone.io (https://drone.io/github.com/tbeu/paho.mqtt.c/files) with custom Makefile: ``` AR = ar -ru RM = rm -f CFLAGS = -O3 CPPFLAGS = -DNDEBUG INC = TARGETDIR = linux64 # The names of the four different libraries to be built MQTTLIB_C = paho-mqtt3c MQTTLIB_CS = paho-mqtt3cs MQTTLIB_A = paho-mqtt3a MQTTLIB_AS = paho-mqtt3as MQTT3A_OBJS = \ Clients.o \ Heap.o \ LinkedList.o \ Log.o \ Messages.o \ MQTTAsync.o \ MQTTPacket.o \ MQTTPacketOut.o \ MQTTPersistence.o \ MQTTPersistenceDefault.o \ MQTTProtocolClient.o \ MQTTProtocolOut.o \ Socket.o \ SocketBuffer.o \ StackTrace.o \ Thread.o \ Tree.o \ utf-8.o MQTT3C_OBJS = \ Clients.o \ Heap.o \ LinkedList.o \ Log.o \ Messages.o \ MQTTClient.o \ MQTTPacket.o \ MQTTPacketOut.o \ MQTTPersistence.o \ MQTTPersistenceDefault.o \ MQTTProtocolClient.o \ MQTTProtocolOut.o \ Socket.o \ SocketBuffer.o \ StackTrace.o \ Thread.o \ Tree.o \ utf-8.o ALL_OBJS = $(MQTT3A_OBJS) $(MQTT3C_OBJS) TS := $(shell /bin/date -u) all: clean versioninfo lib$(MQTTLIB_A).a lib$(MQTTLIB_C).a versioninfo: @echo "#ifndef VERSIONINFO_H" > src/VersionInfo.h @echo "#define VERSIONINFO_H" >> src/VersionInfo.h @echo "#define BUILD_TIMESTAMP \""$(TS)"\"" >> src/VersionInfo.h @echo "#define CLIENT_VERSION \"1.1.0\"" >> src/VersionInfo.h @echo "#endif /* VERSIONINFO_H */" >> src/VersionInfo.h lib$(MQTTLIB_A).a: $(MQTT3A_OBJS) $(AR) $@ $(MQTT3A_OBJS) cp $@ Library/$(TARGETDIR)/$@ lib$(MQTTLIB_C).a: $(MQTT3C_OBJS) $(AR) $@ $(MQTT3C_OBJS) cp $@ Library/$(TARGETDIR)/$@ %.o: src/%.c $(CC) $(CPPFLAGS) $(CFLAGS) $(INC) -c -o $@ $< clean: $(RM) $(ALL_OBJS) $(RM) *.a ```
…or Windows Built with Visual Studio 2010 (/MD flag)
[ci skip]
[ci skip]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took a bit of testing and some email exchange to get an understanding of this PR. It now works fine in Windows and Linux and will be cool new feature for the next release. I will squash it and merge it.
As discussed using email, the new library dependencies should be managed in a more transparent way so that it is not too difficult to reproduce the builds. However, this can be improved later. Particularly, building the OpenSSL libraries is a bit inconvenient and I like your idea of replacing that dependency by mbedTLS in the future (if possible).
I have experimented with adapting the cmake files, so that the library dependencies can be built as external projects. This is not complete, yet. I think I should do a more general revision of the cmake build system before. That's future work.
Below is what I understand about the library dependencies. We could document this at some place in the project, e.g., below the ../Resources/Libraries folder. Finally, I hope that we/I can adapt the cmake files, so that the libraries can be built by cmake (and thus a simple reproducible build becomes possible at some point in the future).
- paho.mqtt.c
- Windows:
paho-mqtt3cs.[lib,dll]
- Linux:
libpaho-mqtt3cs.a
- https://github.com/eclipse/paho.mqtt.c
- Version 1.3.0 (Paho 1.4)
- Windows:
- OpenSSL
- Windows:
libeay32.dll
(Windows name of libcrypto.a),ssleay32.dll
(Windows name of libssl.a) (Dummy libraries:crypto.dll
,ssl.dll
)- Build as described, e.g., in https://stackoverflow.com/a/40007671/8520615, but without debug and with no-asm
- Linux:
libcrypto.a
(general cryptographic support),libssl.a
(client and server-side implementations for SSLv3 and TLS, needs libcrypto.a) - https://www.openssl.org/
- OpenSSL_1_0_2p
- Windows:
Tested with MSVC and GCC on Linux.
TODO:
I did not spent time on setting up a local MQTT broker, thus the example works on some public test broker. This might be changed some day.
Close #130