← Back to team overview

mosquitto-users team mailing list archive

Re: v1.30 breaks embedded usage

 

Some of the networking had to be altered to work with lwIP and FreeRTOS on a STM32 microcontroller target.  For example in mosquito.c



#ifndef WIN32

#include <sys/select.h>

#include <sys/time.h>

#include <unistd.h>

#else

#include <winsock2.h>

#include <windows.h>

typedef int ssize_t;

#endif



fails for my build environment with FreeRTOS / lwIP because no sys/select.h and no unistd.h support.



#ifndef WIN32

                signal(SIGPIPE, SIG_IGN);

#endif



fails since no signal support.



Another example is in _mosquitto_socket_connect() with WITH_TLS defined, to load the CA you call the OpenSSL function SSL_CTX_load_verify_locations() which relies on a file system to load the file.  Since I have no file system I had to tweak this to call something different where that file was already in a buffer and built into the code.    No big deal, that did not work for me and my project, so another tweak.  General stuff like that.  Probably more places but you get the idea.



Since my build environment is not the typical one, I have become used to these kinds of manual tweaks.  I do not expect every combination of target and library option to be already done and configured via defines, so I budget extra time to walk through the code and change as needed for my target.   Just makes the upgrades take a little longer when I cannot just copy over the files as is, but rather have to do diffs on those files I modified and push over the required changes.



Keep up the good work on Mosquitto.  Very useful, much appreciated.  Thanks.



Regards,





David Reid

Silicon Engines

 <mailto:david.reid@xxxxxxxxxxxxxxxxxx> david.reid@xxxxxxxxxxxxxxxxxx

847.637.1180 x234

847.637.1185 (f)



From: rogerlight@xxxxxxxxx [mailto:rogerlight@xxxxxxxxx] On Behalf Of Roger Light
Sent: Friday, March 21, 2014 6:06 PM
To: david.reid@xxxxxxxxxxxxxxxxxx
Cc: mosquitto-users@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Mosquitto-users] v1.30 breaks embedded usage



Hi David,

Out of interest - what massaging was required?

Cheers,


Roger



On Fri, Mar 21, 2014 at 11:01 PM, Roger Light <roger@xxxxxxxxxx> wrote:

Hi David,

It's a simple mistake, nothing more. Rest assured you aren't expected to have threading! I'll fix it up for you.

Cheers,

Roger



On Fri, Mar 21, 2014 at 9:03 PM, David Reid <david.reid@xxxxxxxxxxxxxxxxxx> wrote:

Roger,



I think v1.30 has some issues, please advise.



With v1.2.3 I was able to get a Mosquitto C client running on a STM32 microcontroller with lwIP and FreeRTOS with relative ease, just a little massaging of the code here and there.



With v1.30 it seems to have gotten broken, namely because of #ifdef WITH_THREADING requirements to add the in_message_mutex and out_message_mutex members to the mosquito struct.  Since threading does not apply to my usage case, if I do not define WITH_THREADING then these members are not included in the struct and the code fails to compile for places where these members are accessed but not protected by that ifdef.  For example, all of these functions require in_message_mutex and/or out_message_mutex member to exist, but if WITH_THREADING is not defined then the code will fail to compile because those members do not exist.

_mosquitto_messages_reconnect_reset()

_mosquitto_message_remove()

_mosquitto_message_retry_check()

mosquitto_loop_read()

mosquitto_loop_write()

_mosquitto_handle_publish()



Am I wrong?  Should I be defining WITH_THREADING for a FreeRTOS build?  I am not sure that I should, there is no pthread.h header file for me to include if I do so, so I end up including the dummypthread.h header instead.



Also, I had to add a definition for pthread_mutex_t to your dummypthread.h file since it is not defined anywhere else that I could find.  Without it, the code will not compile.



I realize that my usage case is not the norm, so perhaps you just assumed that the target would support threading?   If I am wrong and need to change something, please advise.



Thanks.



Regards,





David Reid

Silicon Engines

david.reid@xxxxxxxxxxxxxxxxxx

847.637.1180 x234 <tel:847.637.1180%20x234>

847.637.1185 (f)





  _____


 <http://www.avast.com/>

This email is free from viruses and malware because avast! Antivirus <http://www.avast.com/>  protection is active.





--
Mailing list: https://launchpad.net/~mosquitto-users
Post to     : mosquitto-users@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~mosquitto-users
More help   : https://help.launchpad.net/ListHelp







---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

References