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.
6 years, 2 months ago.
C Client for mbed
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?
Question relating to:
6 years, 1 month ago.
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 :-)