8 years, 9 months ago.

C Client for mbed

Hi Team,

Do you have a C Client for mbed that has the same API that the Paho C Version that we have for windows and Linux?

I found some sample, but all C++..

I have an application that uses Paho today and would be really nice to just have it compiled for MBed without needing to get any interface/adapter lawyer.

I'm using today, for example, these apis: MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer; MQTTClient_SSLOptions sslopts = MQTTClient_SSLOptions_initializer; int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions* options); (Using SSL for the options). int MQTTClient_create(MQTTClient* handle, const char* serverURI, const char* clientId, int persistence_type, void* persistence_context); int MQTTClient_setCallbacks(MQTTClient handle, void* context, MQTTClient_connectionLost* cl, MQTTClient_messageArrived* ma, MQTTClient_deliveryComplete* dc); void MQTTClient_freeMessage(MQTTClient_message msg); void MQTTClient_free(void* ptr); int MQTTClient_disconnect(MQTTClient handle, int timeout);

Have you done something on this line to have these API?

Thanks!

Angelo Ribeiro.

Question relating to:

Basic C library for MQTT packet serialization and deserialization

1 Answer

8 years, 8 months ago.

Hi Angelo,

the short answer is "no". In Paho we do have a C version of the embedded MQTTClient API, called MQTTClient-C (https://www.eclipse.org/paho/clients/c/embedded/) but that looks like the embedded API. Some reasons why the APIs are different:

  • C++ is the default language on mbed
  • mbed devices can be much more constrained, so we need to limit resource usage
  • dynamic memory allocation is avoided, for portability and resource usage limiting
  • network (including TLS) and OS specific functions are in replaceable classes, for portability
  • some other features are included based on user feedback, such as per subscription callbacks

I don't think the APIs are gratuitously different :-)

Ian

Thanks Ian,

I will try to build a wrapper so we can use the C++ Wrapper in a C code. I understand that C++ is the default language, however, on my case, my library is in C (based on C99 Standard) and we use the exactly same code to run on Windows/Linux/Mbed and other arquitectures...

I will share with you guys once I'm done.

Thanks!

Angelo Ribeiro.

posted by Angelo Ribeiro 30 Jul 2015

Hi Angelo: i'm doing the same work like you , i don't know how to build a wrapper to use the c++ wrapper in a c code. would you like to give me some suggestions?

posted by huaiyu wei 23 Oct 2015