diff --git a/assets/webconfig/i18n/cs.json b/assets/webconfig/i18n/cs.json index 988e14d8..8cc269fb 100644 --- a/assets/webconfig/i18n/cs.json +++ b/assets/webconfig/i18n/cs.json @@ -512,7 +512,7 @@ "edt_conf_fw_json_expl": "Jeden z cílů na jeden řádek. Obsahuje IP:PORT (Příklad: 127.0.0.1:19446)", "edt_conf_fw_json_itemtitle": "Json cíl", "edt_conf_fw_proto_title": "Seznam proto klientů", - "edt_conf_fw_proto_expl": "Jeden cíl na každý řádek. Obsahuje IP:PORT (Příklad: 127.0.0.1:19447)", + "edt_conf_fw_proto_expl": "Jeden cíl na každý řádek. Obsahuje IP:PORT (Příklad: 127.0.0.1:19401)", "edt_conf_fw_proto_itemtitle": "Proto cíl", "edt_conf_js_heading_title": "JSON Server", "edt_conf_ps_heading_title": "PROTO Server", @@ -753,4 +753,4 @@ "edt_conf_enum_SECAM": "SECAM", "general_speech_it": "Italština", "general_speech_cs": "Czech" -} \ No newline at end of file +} diff --git a/assets/webconfig/i18n/de.json b/assets/webconfig/i18n/de.json index 440746ad..135d67a8 100644 --- a/assets/webconfig/i18n/de.json +++ b/assets/webconfig/i18n/de.json @@ -561,7 +561,7 @@ "edt_conf_fw_json_expl" : "Ein Json Ziel pro Zeile. Bestehend aus IP:PORT (Beispiel: 127.0.0.1:19446)", "edt_conf_fw_json_itemtitle" : "Json Ziel", "edt_conf_fw_proto_title" : "Liste von Proto zielen", - "edt_conf_fw_proto_expl" : "Ein Proto Ziel pro Zeile. Bestehend aus IP:PORT (Beispiel: 127.0.0.1:19447)", + "edt_conf_fw_proto_expl" : "Ein Proto Ziel pro Zeile. Bestehend aus IP:PORT (Beispiel: 127.0.0.1:19401)", "edt_conf_fw_proto_itemtitle" : "Proto Ziel", "edt_conf_js_heading_title" : "JSON Server", "edt_conf_fbs_heading_title" : "Flatbuffers Server", diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json index 15f5296e..5bd4b134 100644 --- a/assets/webconfig/i18n/en.json +++ b/assets/webconfig/i18n/en.json @@ -562,7 +562,7 @@ "edt_conf_fw_json_expl" : "One json target per line. Contains IP:PORT (Example: 127.0.0.1:19446)", "edt_conf_fw_json_itemtitle" : "Json target", "edt_conf_fw_proto_title" : "List of proto clients", - "edt_conf_fw_proto_expl" : "One proto target per line. Contains IP:PORT (Example: 127.0.0.1:19447)", + "edt_conf_fw_proto_expl" : "One proto target per line. Contains IP:PORT (Example: 127.0.0.1:19401)", "edt_conf_fw_proto_itemtitle" : "Proto target", "edt_conf_js_heading_title" : "JSON Server", "edt_conf_fbs_heading_title" : "Flatbuffers Server", diff --git a/assets/webconfig/i18n/it.json b/assets/webconfig/i18n/it.json index f44f8b88..1a85d8cf 100644 --- a/assets/webconfig/i18n/it.json +++ b/assets/webconfig/i18n/it.json @@ -512,7 +512,7 @@ "edt_conf_fw_json_expl": "Una destinazione json per riga. Contiene IP:PORTA:(Esempio: 127.0.0.1:19446)", "edt_conf_fw_json_itemtitle": "Destinatario json", "edt_conf_fw_proto_title": "Lista dei client proto", - "edt_conf_fw_proto_expl": "Una destinazione proto per riga. Contiene IP:PORTA:(Esempio: 127.0.0.1:19447)", + "edt_conf_fw_proto_expl": "Una destinazione proto per riga. Contiene IP:PORTA:(Esempio: 127.0.0.1:19401)", "edt_conf_fw_proto_itemtitle": "Destinatario proto", "edt_conf_js_heading_title": "Server JSON", "edt_conf_ps_heading_title": "Server PROTO", @@ -753,4 +753,4 @@ "edt_conf_enum_SECAM": "SECAM", "general_speech_it": "Italiano", "general_speech_cs": "Czech" -} \ No newline at end of file +} diff --git a/config/hyperion.config.json.commented b/config/hyperion.config.json.commented index 13e87737..65db7807 100644 --- a/config/hyperion.config.json.commented +++ b/config/hyperion.config.json.commented @@ -216,14 +216,14 @@ /// The configuration of the Json/Proto forwarder. Forward messages to multiple instances of Hyperion on same and/or other hosts /// 'proto' is mostly used for video streams and 'json' for effects /// * enable : Enable or disable the forwarder (true/false) - /// * proto : Proto server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19447"] or more instances to forward ["127.0.0.1:19447","192.168.0.24:19449"] + /// * proto : Proto server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19401"] or more instances to forward ["127.0.0.1:19401","192.168.0.24:19403"] /// * json : Json server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19446"] or more instances to forward ["127.0.0.1:19446","192.168.0.24:19448"] /// HINT:If you redirect to "127.0.0.1" (localhost) you could start a second hyperion with another device/led config! - /// Be sure your client(s) is/are listening on the configured ports. The second Hyperion (if used) also needs to be configured! (HyperCon -> External -> Json Server/Proto Server) + /// Be sure your client(s) is/are listening on the configured ports. The second Hyperion (if used) also needs to be configured! (WebUI -> Settings Level (Expert) -> Configuration -> Network Services -> Forwarder) "forwarder" : { "enable" : false, - "proto" : ["127.0.0.1:19447"], + "proto" : ["127.0.0.1:19401"], "json" : ["127.0.0.1:19446"] }, diff --git a/config/hyperion.config.json.default b/config/hyperion.config.json.default index c950d01f..ae60dec6 100644 --- a/config/hyperion.config.json.default +++ b/config/hyperion.config.json.default @@ -123,7 +123,7 @@ { "enable" : false, "json" : ["127.0.0.1:19446"], - "proto" : ["127.0.0.1:19447"] + "proto" : ["127.0.0.1:19401"] }, "jsonServer" : diff --git a/libsrc/flatbufserver/FlatBufferClient.cpp b/libsrc/flatbufserver/FlatBufferClient.cpp index f740abf2..419eb937 100644 --- a/libsrc/flatbufserver/FlatBufferClient.cpp +++ b/libsrc/flatbufserver/FlatBufferClient.cpp @@ -111,6 +111,12 @@ void FlatBufferClient::handleRegisterCommand(const hyperionnet::Register *regReq { _priority = regReq->priority(); _hyperion->registerInput(_priority, hyperion::COMP_FLATBUFSERVER, regReq->origin()->c_str()+_clientAddress); + + auto reply = hyperionnet::CreateReplyDirect(_builder, nullptr, -1, (_priority ? _priority : -1)); + _builder.Finish(reply); + + // send reply + sendMessage(); } void FlatBufferClient::handleImageCommand(const hyperionnet::Image *image) diff --git a/libsrc/flatbufserver/FlatBufferConnection.cpp b/libsrc/flatbufserver/FlatBufferConnection.cpp index c9cc5834..cfcafc46 100644 --- a/libsrc/flatbufserver/FlatBufferConnection.cpp +++ b/libsrc/flatbufserver/FlatBufferConnection.cpp @@ -95,7 +95,19 @@ void FlatBufferConnection::setRegister(const QString& origin, int priority) auto req = hyperionnet::CreateRequest(_builder, hyperionnet::Command_Register, registerReq.Union()); _builder.Finish(req); - sendMessage(_builder.GetBufferPointer(), _builder.GetSize()); + uint32_t size = _builder.GetSize(); + const uint8_t header[] = { + uint8_t((size >> 24) & 0xFF), + uint8_t((size >> 16) & 0xFF), + uint8_t((size >> 8) & 0xFF), + uint8_t((size ) & 0xFF)}; + + // write message + int count = 0; + count += _socket.write(reinterpret_cast(header), 4); + count += _socket.write(reinterpret_cast(_builder.GetBufferPointer()), size); + _socket.flush(); + _builder.Clear(); } void FlatBufferConnection::setColor(const ColorRgb & color, int priority, int duration) @@ -136,10 +148,7 @@ void FlatBufferConnection::connectToHost() { // try connection only when if (_socket.state() == QAbstractSocket::UnconnectedState) - { _socket.connectToHost(_host, _port); - //_socket.waitForConnected(1000); - } } void FlatBufferConnection::sendMessage(const uint8_t* buffer, uint32_t size) @@ -147,19 +156,17 @@ void FlatBufferConnection::sendMessage(const uint8_t* buffer, uint32_t size) // print out connection message only when state is changed if (_socket.state() != _prevSocketState ) { + _registered = false; switch (_socket.state() ) { case QAbstractSocket::UnconnectedState: Info(_log, "No connection to Hyperion: %s:%d", _host.toStdString().c_str(), _port); - _registered = false; break; case QAbstractSocket::ConnectedState: Info(_log, "Connected to Hyperion: %s:%d", _host.toStdString().c_str(), _port); - _registered = false; break; default: Debug(_log, "Connecting to Hyperion: %s:%d", _host.toStdString().c_str(), _port); - _registered = false; break; } _prevSocketState = _socket.state(); @@ -171,7 +178,6 @@ void FlatBufferConnection::sendMessage(const uint8_t* buffer, uint32_t size) if(!_registered) { - _registered = true; setRegister(_origin, _priority); return; } @@ -194,14 +200,22 @@ bool FlatBufferConnection::parseReply(const hyperionnet::Reply *reply) { if (!reply->error()) { - // no error set must be a success or video + // no error set must be a success or registered or video const auto videoMode = reply->video(); + const auto registered = reply->registered(); if (videoMode != -1) { // We got a video reply. emit setVideoMode(static_cast(videoMode)); - } return true; - } + } + // We got a registered reply. + if (registered != -1 && registered != _priority) + _registered = false; + else + _registered = true; + + return true; + } return false; } diff --git a/libsrc/flatbufserver/hyperion_reply.fbs b/libsrc/flatbufserver/hyperion_reply.fbs index 5d9c3f69..c80d1b61 100644 --- a/libsrc/flatbufserver/hyperion_reply.fbs +++ b/libsrc/flatbufserver/hyperion_reply.fbs @@ -3,6 +3,7 @@ namespace hyperionnet; table Reply { error:string; video:int = -1; + registered:int = -1; } root_type Reply; diff --git a/libsrc/hyperion/MessageForwarder.cpp b/libsrc/hyperion/MessageForwarder.cpp index 61e937a5..a8fc4594 100644 --- a/libsrc/hyperion/MessageForwarder.cpp +++ b/libsrc/hyperion/MessageForwarder.cpp @@ -98,7 +98,7 @@ void MessageForwarder::componentStateChanged(const hyperion::Components componen { _forwarder_enabled = enable; handleSettingsUpdate(settings::NETFORWARD, _hyperion->getSetting(settings::NETFORWARD)); - Info(_log, "Message Forwarder change state to %s", (_forwarder_enabled ? "enabled" : "disabled")); + Info(_log, "Forwarder change state to %s", (_forwarder_enabled ? "enabled" : "disabled")); _hyperion->getComponentRegister().componentStateChanged(component, _forwarder_enabled); } } @@ -187,7 +187,7 @@ void MessageForwarder::addProtoSlave(QString slave) if (_forwarder_enabled) { _protoSlaves << slave; - FlatBufferConnection* flatbuf = new FlatBufferConnection("Message Forwarder", slave.toLocal8Bit().constData(), _priority, true); + FlatBufferConnection* flatbuf = new FlatBufferConnection("Forwarder", slave.toLocal8Bit().constData(), _priority, false); _forwardClients << flatbuf; } } @@ -215,10 +215,7 @@ void MessageForwarder::forwardProtoMessage(const Image &image) if (_forwarder_enabled) { for (int i=0; i < _forwardClients.size(); i++) - { - _forwardClients.at(i)->setRegister("Message Forwarder", _priority); _forwardClients.at(i)->setImage(image); - } } } diff --git a/src/hyperion-aml/hyperion-aml.cpp b/src/hyperion-aml/hyperion-aml.cpp index 02a7aca1..83f717bb 100644 --- a/src/hyperion-aml/hyperion-aml.cpp +++ b/src/hyperion-aml/hyperion-aml.cpp @@ -41,7 +41,7 @@ int main(int argc, char ** argv) IntOption & argWidth = parser.add (0x0, "width", "Width of the captured image [default: %1]", "160", 160, 4096); IntOption & argHeight = parser.add (0x0, "height", "Height of the captured image [default: %1]", "160", 160, 4096); BooleanOption & argScreenshot = parser.add(0x0, "screenshot", "Take a single screenshot, save it to file and quit"); - Option & argAddress = parser.add