user48730: I'll try to explain my need:

I have a generic library I created, called myIOT.h.
This class have a pre-configured  MQTT and wifi setup.
Inside this library there is a mqtt_callback function, for all generic commands, such as boot_time and connection_status.
BUT, this library serves in several of my iot device's code, that each one has a few more mqtt commands, that is tailored just for s specific device, and I looking for a way that iot.mqtt_callback(ext_mqtt_func) will get as parameter a local ( which belong to the sketch and not to the library ), that will have the additional code needed.

I'll try to explain more clearly:
void myIOT::mqtt_callback(ext_mqtt_func){
if (a == true ) {
do something

};

else {

ext_mqtt_func()); // calling another fucntion that belongs to sketch and not library

}


user52137: Yes, you can do it.
You pass function pointer as function parameter.
See this stackoverflow question:
https://stackoverflow.com/questions/2582161/c-function-pointer-as-parameter

48730: <p>I'll try to explain my need:</p>

<ol>
<li>I have a generic library I created, called <code>myIOT.h</code>.</li>
<li>This class have a pre-configured  MQTT and wifi setup.</li>
<li>Inside this library there is a <code>mqtt_callback</code> function, for all generic commands, such as <code>boot_time</code> and <code>connection_status</code>.</li>
<li>BUT, this library serves in several of my iot device's code, that each one has a few more mqtt commands, that is tailored just for s specific device, and I looking for a way that <code>iot.mqtt_callback(ext_mqtt_func)</code> will get as parameter a local ( which belong to the sketch and not to the library ), that will have the additional code needed.</li>
</ol>

<p>I'll try to explain more clearly:</p>

<pre><code>void myIOT::mqtt_callback(ext_mqtt_func){
if (a == true ) {
do something

};

else {

ext_mqtt_func()); // calling another fucntion that belongs to sketch and not library

}
</code></pre>
 52137: <p>Yes, you can do it.</p>

<p>You pass function pointer as function parameter.</p>

<p>See this stackoverflow question:</p>

<p><a href="https://stackoverflow.com/questions/2582161/c-function-pointer-as-parameter">https://stackoverflow.com/questions/2582161/c-function-pointer-as-parameter</a></p>
