fix io callback scope issue

This commit is contained in:
Todd Treece 2016-07-29 15:06:54 -04:00
parent 0bfffa1571
commit 49eda71d17
2 changed files with 9 additions and 3 deletions

View File

@ -480,7 +480,7 @@ void Adafruit_MQTT::processPackets(int16_t timeout) {
else if (sub->callback_io != NULL) {
// huh lets do the callback in io mode
//serial.print("*** calling io instance callback with : "); serial.println(data);
sub->*callback_io((char *)sub->lastread, sub->datalen);
((sub->io_feed)->*(sub->callback_io))((char *)sub->lastread, sub->datalen);
}
}
@ -867,6 +867,7 @@ Adafruit_MQTT_Subscribe::Adafruit_MQTT_Subscribe(Adafruit_MQTT *mqttserver,
callback_buffer = 0;
callback_double = 0;
callback_io = 0;
io_feed = 0;
}
Adafruit_MQTT_Subscribe::Adafruit_MQTT_Subscribe(Adafruit_MQTT *mqttserver,
@ -878,6 +879,7 @@ Adafruit_MQTT_Subscribe::Adafruit_MQTT_Subscribe(Adafruit_MQTT *mqttserver,
callback_uint32t = 0;
callback_buffer = 0;
callback_io = 0;
io_feed = 0;
}
void Adafruit_MQTT_Subscribe::setCallback(SubscribeCallbackUInt32Type cb) {
@ -892,8 +894,9 @@ void Adafruit_MQTT_Subscribe::setCallback(SubscribeCallbackBufferType cb) {
callback_buffer = cb;
}
void Adafruit_MQTT_Subscribe::setCallback(SubscribeCallbackIOType cb) {
void Adafruit_MQTT_Subscribe::setCallback(AdafruitIO_Feed *f, SubscribeCallbackIOType cb) {
callback_io = cb;
io_feed = f;
}
void Adafruit_MQTT_Subscribe::removeCallback(void) {
@ -901,4 +904,5 @@ void Adafruit_MQTT_Subscribe::removeCallback(void) {
callback_buffer = 0;
callback_double = 0;
callback_io = 0;
io_feed = 0;
}

View File

@ -288,7 +288,7 @@ class Adafruit_MQTT_Subscribe {
void setCallback(SubscribeCallbackUInt32Type callb);
void setCallback(SubscribeCallbackDoubleType callb);
void setCallback(SubscribeCallbackBufferType callb);
void setCallback(SubscribeCallbackIOType callb);
void setCallback(AdafruitIO_Feed *io, SubscribeCallbackIOType callb);
void removeCallback(void);
const char *topic;
@ -304,6 +304,8 @@ class Adafruit_MQTT_Subscribe {
SubscribeCallbackBufferType callback_buffer;
SubscribeCallbackIOType callback_io;
AdafruitIO_Feed *io_feed;
private:
Adafruit_MQTT *mqtt;
};