Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years 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:
![](/media/cache/profiles/mqtt.png.50x50_q85.png)
1 Answer
9 years 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 30 Jul 2015