Skip to main content
deleted 3 characters in body
Source Link
Michel Keijzers
  • 13k
  • 7
  • 43
  • 59

I'll try to explain my need:

  1. I have a generic library I created, called myIOT.h.
  2. This class have a pre-configured MQTT and wifi setup.
  3. Inside this library there is a mqtt_callback function, for all generic commands, such as boot_time and connection_status.
  4. 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.

2)This class have a pre-configured MQTT and wifi setup.

  1. Inside this library there is a mqtt_callback function, for all generic commands, such as boot_time and connection_status.

4)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

}

I'll try to explain my need:

  1. I have a generic library I created, called myIOT.h.

2)This class have a pre-configured MQTT and wifi setup.

  1. Inside this library there is a mqtt_callback function, for all generic commands, such as boot_time and connection_status.

4)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

}

I'll try to explain my need:

  1. I have a generic library I created, called myIOT.h.
  2. This class have a pre-configured MQTT and wifi setup.
  3. Inside this library there is a mqtt_callback function, for all generic commands, such as boot_time and connection_status.
  4. 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

}
Source Link
guyd
  • 1k
  • 2
  • 26
  • 62

Calling external function from a class function

I'll try to explain my need:

  1. I have a generic library I created, called myIOT.h.

2)This class have a pre-configured MQTT and wifi setup.

  1. Inside this library there is a mqtt_callback function, for all generic commands, such as boot_time and connection_status.

4)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

}