Given the following C interface:
IoT_Error_t aws_iot_mqtt_subscribe(AWS_IoT_Client *pClient,
const char *pTopicName,
uint16_t topicNameLen,
QoS qos,
pApplicationHandler_t pApplicationHandler,
oid *pApplicationHandlerData);
"aws_iot_mqtt_subscribe
stores its arguments for latter reference - to call, in response to some event at some later point in time"
Handler:
typedef void (*pApplicationHandler_t)(
AWS_IoT_Client *pClient,
char *pTopicName,
uint16_t topicNameLen,
IoT_Publish_Message_Params *pParams,
void *pClientData);
I am trying to wrap this into a C++ class that would have the following interface:
class AWS {
// ...
public:
void subscribe(const std::string &topic,
std::function<void(const std::string&)> callback);
// ...
};
My goal is to make it possible to pass a capturing lambda function to AWS::subscribe
. I have been trying with different approaches for a nearly a week now but none of them seemed to work.
Let me know if anything else needed to understand the problem, I'm happy to update the question.
aws_iot_mqtt_subscribe
is given by the AWS C SDK I can't modify it. I'd like to create a C++ class that wraps the C functionaws_iot_mqtt_subscribe
. – Algoid