expand mqtt callbacks from 2^8 to 2^16
This commit is contained in:
parent
531f7e05a7
commit
06b69da78f
|
@ -377,7 +377,7 @@ void ESPMegaIoT::publish(const char *topic, const char *payload)
|
|||
* @param callback The callback function
|
||||
* @return The handler for the callback
|
||||
*/
|
||||
uint8_t ESPMegaIoT::registerMqttCallback(std::function<void(char *, char *)> callback)
|
||||
uint16_t ESPMegaIoT::registerMqttCallback(std::function<void(char *, char *)> callback)
|
||||
{
|
||||
mqtt_callbacks[mqtt_callbacks_handler_index] = callback;
|
||||
return mqtt_callbacks_handler_index++;
|
||||
|
@ -388,7 +388,7 @@ uint8_t ESPMegaIoT::registerMqttCallback(std::function<void(char *, char *)> cal
|
|||
*
|
||||
* @param handler The handler of the callback
|
||||
*/
|
||||
void ESPMegaIoT::unregisterMqttCallback(uint8_t handler)
|
||||
void ESPMegaIoT::unregisterMqttCallback(uint16_t handler)
|
||||
{
|
||||
mqtt_callbacks.erase(handler);
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ void ESPMegaIoT::sessionKeepAlive()
|
|||
* @param callback The callback function
|
||||
* @return The handler for the callback
|
||||
*/
|
||||
uint8_t ESPMegaIoT::registerRelativeMqttCallback(std::function<void(char *, char *)> callback)
|
||||
uint16_t ESPMegaIoT::registerRelativeMqttCallback(std::function<void(char *, char *)> callback)
|
||||
{
|
||||
mqtt_relative_callbacks[mqtt_relative_callbacks_handler_index] = callback;
|
||||
return mqtt_relative_callbacks_handler_index++;
|
||||
|
@ -490,7 +490,7 @@ uint8_t ESPMegaIoT::registerRelativeMqttCallback(std::function<void(char *, char
|
|||
*
|
||||
* @param handler The handler of the callback
|
||||
*/
|
||||
void ESPMegaIoT::unregisterRelativeMqttCallback(uint8_t handler)
|
||||
void ESPMegaIoT::unregisterRelativeMqttCallback(uint16_t handler)
|
||||
{
|
||||
mqtt_relative_callbacks.erase(handler);
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ void ESPMegaIoT::subscribeRelative(const char *topic)
|
|||
* @param callback The callback function
|
||||
* @return The handler for the callback
|
||||
*/
|
||||
uint8_t ESPMegaIoT::registerSubscribeCallback(std::function<void(void)> callback)
|
||||
uint16_t ESPMegaIoT::registerSubscribeCallback(std::function<void(void)> callback)
|
||||
{
|
||||
subscribe_callbacks[subscribe_callbacks_handler_index] = callback;
|
||||
return subscribe_callbacks_handler_index++;
|
||||
|
@ -539,7 +539,7 @@ uint8_t ESPMegaIoT::registerSubscribeCallback(std::function<void(void)> callback
|
|||
*
|
||||
* @param handler The handler of the callback
|
||||
*/
|
||||
void ESPMegaIoT::unregisterSubscribeCallback(uint8_t handler)
|
||||
void ESPMegaIoT::unregisterSubscribeCallback(uint16_t handler)
|
||||
{
|
||||
subscribe_callbacks.erase(handler);
|
||||
}
|
||||
|
|
|
@ -105,12 +105,12 @@ public:
|
|||
bool mqttConnected();
|
||||
void disconnectFromMqtt();
|
||||
void publish(const char *topic, const char *payload);
|
||||
uint8_t registerMqttCallback(std::function<void(char *, char *)> callback);
|
||||
void unregisterMqttCallback(uint8_t handler);
|
||||
uint8_t registerRelativeMqttCallback(std::function<void(char *, char *)> callback);
|
||||
void unregisterRelativeMqttCallback(uint8_t handler);
|
||||
uint8_t registerSubscribeCallback(std::function<void(void)> callback);
|
||||
void unregisterSubscribeCallback(uint8_t handler);
|
||||
uint16_t registerMqttCallback(std::function<void(char *, char *)> callback);
|
||||
void unregisterMqttCallback(uint16_t handler);
|
||||
uint16_t registerRelativeMqttCallback(std::function<void(char *, char *)> callback);
|
||||
void unregisterRelativeMqttCallback(uint16_t handler);
|
||||
uint16_t registerSubscribeCallback(std::function<void(void)> callback);
|
||||
void unregisterSubscribeCallback(uint16_t handler);
|
||||
void setBaseTopic(char *base_topic);
|
||||
void bindEthernetInterface(ETHClass *ethernetIface);
|
||||
bool networkConnected();
|
||||
|
@ -137,12 +137,12 @@ private:
|
|||
void wifiReconnect();
|
||||
void mqttSubscribe();
|
||||
void mqttCallback(char *topic, byte *payload, unsigned int length);
|
||||
uint8_t mqtt_callbacks_handler_index;
|
||||
uint8_t mqtt_relative_callbacks_handler_index;
|
||||
uint8_t subscribe_callbacks_handler_index;
|
||||
std::map<uint8_t, std::function<void(char*, char*)>> mqtt_callbacks;
|
||||
std::map<uint8_t, std::function<void(char*, char*)>> mqtt_relative_callbacks;
|
||||
std::map<uint8_t, std::function<void(void)>> subscribe_callbacks;
|
||||
uint16_t mqtt_callbacks_handler_index;
|
||||
uint16_t mqtt_relative_callbacks_handler_index;
|
||||
uint16_t subscribe_callbacks_handler_index;
|
||||
std::map<uint16_t, std::function<void(char*, char*)>> mqtt_callbacks;
|
||||
std::map<uint16_t, std::function<void(char*, char*)>> mqtt_relative_callbacks;
|
||||
std::map<uint16_t, std::function<void(void)>> subscribe_callbacks;
|
||||
void publishRelative(uint8_t card_id, char *topic, char *payload);
|
||||
bool active;
|
||||
PubSubClient mqtt;
|
||||
|
|
Loading…
Reference in New Issue