|
1 |
| -/* Autogenerated on March 9, 2025 4:50:49 PM from eez-framework commit e660a47e84fed3db2020e839e6868a3f10103161 */ |
| 1 | +/* Autogenerated on March 9, 2025 7:38:29 PM from eez-framework commit b1188ad5be4a74d9efeee7dcf6892c9c1f6ed8a6 */ |
2 | 2 | /*
|
3 | 3 | * eez-framework
|
4 | 4 | *
|
@@ -4997,56 +4997,6 @@ static void removeEventHandler(MQTTEventActionComponenentExecutionState *compone
|
4997 | 4997 | }
|
4998 | 4998 | }
|
4999 | 4999 | }
|
5000 |
| -static void eez_mqtt_on_event_callback(void *handle, EEZ_MQTT_Event event, void *eventData) { |
5001 |
| - auto connection = findConnection(handle); |
5002 |
| - if (!connection) { |
5003 |
| - return; |
5004 |
| - } |
5005 |
| - for (auto eventHandler = connection->firstEventHandler; eventHandler; eventHandler = eventHandler->next) { |
5006 |
| - auto componentExecutionState = eventHandler->componentExecutionState; |
5007 |
| - auto flowState = componentExecutionState->flowState; |
5008 |
| - auto componentIndex = componentExecutionState->componentIndex; |
5009 |
| - auto component = (MQTTEventActionComponenent *)flowState->flow->components[componentIndex]; |
5010 |
| - if (event == EEZ_MQTT_EVENT_CONNECT) { |
5011 |
| - if (component->connectEventOutputIndex >= 0) { |
5012 |
| - componentExecutionState->addEvent(component->connectEventOutputIndex); |
5013 |
| - } |
5014 |
| - } else if (event == EEZ_MQTT_EVENT_RECONNECT) { |
5015 |
| - if (component->reconnectEventOutputIndex >= 0) { |
5016 |
| - componentExecutionState->addEvent(component->reconnectEventOutputIndex); |
5017 |
| - } |
5018 |
| - } else if (event == EEZ_MQTT_EVENT_CLOSE) { |
5019 |
| - if (component->closeEventOutputIndex >= 0) { |
5020 |
| - componentExecutionState->addEvent(component->closeEventOutputIndex); |
5021 |
| - } |
5022 |
| - } else if (event == EEZ_MQTT_EVENT_DISCONNECT) { |
5023 |
| - if (component->disconnectEventOutputIndex >= 0) { |
5024 |
| - componentExecutionState->addEvent(component->disconnectEventOutputIndex); |
5025 |
| - } |
5026 |
| - } else if (event == EEZ_MQTT_EVENT_OFFLINE) { |
5027 |
| - if (component->offlineEventOutputIndex >= 0) { |
5028 |
| - componentExecutionState->addEvent(component->offlineEventOutputIndex); |
5029 |
| - } |
5030 |
| - } else if (event == EEZ_MQTT_EVENT_END) { |
5031 |
| - if (component->endEventOutputIndex >= 0) { |
5032 |
| - componentExecutionState->addEvent(component->endEventOutputIndex); |
5033 |
| - } |
5034 |
| - } else if (event == EEZ_MQTT_EVENT_ERROR) { |
5035 |
| - if (component->errorEventOutputIndex >= 0) { |
5036 |
| - componentExecutionState->addEvent(component->errorEventOutputIndex, Value::makeStringRef((const char *)eventData, -1, 0x2b7ac31a)); |
5037 |
| - } |
5038 |
| - } else if (event == EEZ_MQTT_EVENT_MESSAGE) { |
5039 |
| - if (component->messageEventOutputIndex >= 0) { |
5040 |
| - auto messageEvent = (EEZ_MQTT_MessageEvent *)eventData; |
5041 |
| - Value messageValue = Value::makeArrayRef(defs_v3::SYSTEM_STRUCTURE_MQTT_MESSAGE_NUM_FIELDS, defs_v3::SYSTEM_STRUCTURE_MQTT_MESSAGE, 0xe256716a); |
5042 |
| - auto messageArray = messageValue.getArray(); |
5043 |
| - messageArray->values[defs_v3::SYSTEM_STRUCTURE_MQTT_MESSAGE_FIELD_TOPIC] = Value::makeStringRef(messageEvent->topic, -1, 0x5bdff567); |
5044 |
| - messageArray->values[defs_v3::SYSTEM_STRUCTURE_MQTT_MESSAGE_FIELD_PAYLOAD] = Value::makeStringRef(messageEvent->payload, -1, 0xcfa25e4f); |
5045 |
| - componentExecutionState->addEvent(component->messageEventOutputIndex, messageValue); |
5046 |
| - } |
5047 |
| - } |
5048 |
| - } |
5049 |
| -} |
5050 | 5000 | void onFreeMQTTConnection(ArrayValue *mqttConnectionValue) {
|
5051 | 5001 | void *handle = mqttConnectionValue->values[defs_v3::OBJECT_TYPE_MQTT_CONNECTION_FIELD_ID].getVoidPointer();
|
5052 | 5002 | deleteConnection(handle);
|
@@ -5338,17 +5288,69 @@ int eez_mqtt_publish(void *handle, const char *topic, const char *payload) {
|
5338 | 5288 | }, eez::flow::g_wasmModuleId, handle, topic, payload);
|
5339 | 5289 | }
|
5340 | 5290 | }
|
| 5291 | +void eez_mqtt_on_event_callback(void *handle, EEZ_MQTT_Event event, void *eventData) { |
| 5292 | + using namespace eez; |
| 5293 | + using namespace eez::flow; |
| 5294 | + auto connection = findConnection(handle); |
| 5295 | + if (!connection) { |
| 5296 | + return; |
| 5297 | + } |
| 5298 | + for (auto eventHandler = connection->firstEventHandler; eventHandler; eventHandler = eventHandler->next) { |
| 5299 | + auto componentExecutionState = eventHandler->componentExecutionState; |
| 5300 | + auto flowState = componentExecutionState->flowState; |
| 5301 | + auto componentIndex = componentExecutionState->componentIndex; |
| 5302 | + auto component = (MQTTEventActionComponenent *)flowState->flow->components[componentIndex]; |
| 5303 | + if (event == EEZ_MQTT_EVENT_CONNECT) { |
| 5304 | + if (component->connectEventOutputIndex >= 0) { |
| 5305 | + componentExecutionState->addEvent(component->connectEventOutputIndex); |
| 5306 | + } |
| 5307 | + } else if (event == EEZ_MQTT_EVENT_RECONNECT) { |
| 5308 | + if (component->reconnectEventOutputIndex >= 0) { |
| 5309 | + componentExecutionState->addEvent(component->reconnectEventOutputIndex); |
| 5310 | + } |
| 5311 | + } else if (event == EEZ_MQTT_EVENT_CLOSE) { |
| 5312 | + if (component->closeEventOutputIndex >= 0) { |
| 5313 | + componentExecutionState->addEvent(component->closeEventOutputIndex); |
| 5314 | + } |
| 5315 | + } else if (event == EEZ_MQTT_EVENT_DISCONNECT) { |
| 5316 | + if (component->disconnectEventOutputIndex >= 0) { |
| 5317 | + componentExecutionState->addEvent(component->disconnectEventOutputIndex); |
| 5318 | + } |
| 5319 | + } else if (event == EEZ_MQTT_EVENT_OFFLINE) { |
| 5320 | + if (component->offlineEventOutputIndex >= 0) { |
| 5321 | + componentExecutionState->addEvent(component->offlineEventOutputIndex); |
| 5322 | + } |
| 5323 | + } else if (event == EEZ_MQTT_EVENT_END) { |
| 5324 | + if (component->endEventOutputIndex >= 0) { |
| 5325 | + componentExecutionState->addEvent(component->endEventOutputIndex); |
| 5326 | + } |
| 5327 | + } else if (event == EEZ_MQTT_EVENT_ERROR) { |
| 5328 | + if (component->errorEventOutputIndex >= 0) { |
| 5329 | + componentExecutionState->addEvent(component->errorEventOutputIndex, Value::makeStringRef((const char *)eventData, -1, 0x2b7ac31a)); |
| 5330 | + } |
| 5331 | + } else if (event == EEZ_MQTT_EVENT_MESSAGE) { |
| 5332 | + if (component->messageEventOutputIndex >= 0) { |
| 5333 | + auto messageEvent = (EEZ_MQTT_MessageEvent *)eventData; |
| 5334 | + Value messageValue = Value::makeArrayRef(defs_v3::SYSTEM_STRUCTURE_MQTT_MESSAGE_NUM_FIELDS, defs_v3::SYSTEM_STRUCTURE_MQTT_MESSAGE, 0xe256716a); |
| 5335 | + auto messageArray = messageValue.getArray(); |
| 5336 | + messageArray->values[defs_v3::SYSTEM_STRUCTURE_MQTT_MESSAGE_FIELD_TOPIC] = Value::makeStringRef(messageEvent->topic, -1, 0x5bdff567); |
| 5337 | + messageArray->values[defs_v3::SYSTEM_STRUCTURE_MQTT_MESSAGE_FIELD_PAYLOAD] = Value::makeStringRef(messageEvent->payload, -1, 0xcfa25e4f); |
| 5338 | + componentExecutionState->addEvent(component->messageEventOutputIndex, messageValue); |
| 5339 | + } |
| 5340 | + } |
| 5341 | + } |
| 5342 | +} |
5341 | 5343 | EM_PORT_API(void) onMqttEvent(void *handle, EEZ_MQTT_Event event, void *eventDataPtr1, void *eventDataPtr2) {
|
5342 | 5344 | void *eventData;
|
5343 | 5345 | if (eventDataPtr1 && eventDataPtr2) {
|
5344 | 5346 | EEZ_MQTT_MessageEvent eventData;
|
5345 | 5347 | eventData.topic = (const char *)eventDataPtr1;
|
5346 | 5348 | eventData.payload = (const char *)eventDataPtr2;
|
5347 |
| - eez::flow::eez_mqtt_on_event_callback(handle, event, &eventData); |
| 5349 | + eez_mqtt_on_event_callback(handle, event, &eventData); |
5348 | 5350 | } else if (eventDataPtr1) {
|
5349 |
| - eez::flow::eez_mqtt_on_event_callback(handle, event, eventDataPtr1); |
| 5351 | + eez_mqtt_on_event_callback(handle, event, eventDataPtr1); |
5350 | 5352 | } else {
|
5351 |
| - eez::flow::eez_mqtt_on_event_callback(handle, event, nullptr); |
| 5353 | + eez_mqtt_on_event_callback(handle, event, nullptr); |
5352 | 5354 | }
|
5353 | 5355 | }
|
5354 | 5356 | #else
|
|
0 commit comments