Publish --> MQTT Gateway very slow
-
Hi,
I wrote an issue on github: https://github.com/mysensors/Arduino/issues/309
Do you have an idea please ?thanks in advance
-
@mickaelh51 can you check speed of
_ethernetServer.write(_ethernetMsg);
call using the same debug code as for esp8266 gateway code here: http://forum.mysensors.org/topic/1870/esp8266-wifi-gateway-port-for-mysensors/225 ?Something like this:
// Send message to connected clients #if defined(MY_GATEWAY_ESP8266) for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) { if (clients[i] && clients[i].connected()) { clients[i].write((uint8_t*)_ethernetMsg, strlen(_ethernetMsg)); } } #else unsigned long start_time = hwMillis(); _ethernetServer.write(_ethernetMsg); debug(PSTR("Ethernet transaction time: %u ms\n"), hwMillis() - start_time); #endif
File to patch is
libraries\MySensors\Core\MyGatewayTransportEthernet.cpp
-
Hi,
thanks for your answer @robosensor .
But, I'm sorry, I don't know where add the patch in fileI patched MyGatewayTransportEthernet.cpp with your code, but I don't use ESP8266. I use W5100 + NRF24L01.
I patched in MY_CONTROLLER_IP_ADDRESS too => no result (not debug in serial monitor)
For me, when W5100 receive MQTT messages there is a reception problem (because MQTT server send several times the same MQTT message.
Can you help me to write patch please ?thanks in advance
FYI
STATUS 0x0E RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0 RX_ADDR_P0-1 0x00003B3F00 00003B3F0E RX_ADDR_P2-5 0xFF C4 C5 C6 TX_ADDR 0x00003B3F00 RX_PW_P0-6 0x20 20 20 00 00 00 EN_AA 0x3B EN_RXADDR 0x06 RF_CH 0x4C RF_SETUP 0x07 CONFIG 0x0E DYNPD/FEATURE 0x3F 06 Data Rate 1MBPS Model nRF24L01+ CRC Length 16 bits PA Power PA_MAX
-
@mickaelh51 I'm sorry, MQTT gateway is slightly different.
Please replace function in file
MyGatewayTransportMQTTClient.cpp
bool gatewayTransportSend(MyMessage &message) { if (!_client.connected()) return false; snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR(MY_MQTT_PUBLISH_TOPIC_PREFIX "/%d/%d/%d/%d/%d"), message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type); debug(PSTR("Sending message on topic: %s\n"), _fmtBuffer); return _client.publish(_fmtBuffer, message.getString(_convBuffer)); }
With something like this:
bool gatewayTransportSend(MyMessage &message) { if (!_client.connected()) return false; snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR(MY_MQTT_PUBLISH_TOPIC_PREFIX "/%d/%d/%d/%d/%d"), message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type); debug(PSTR("Sending message on topic: %s\n"), _fmtBuffer); unsigned long start_time = hwMillis(); bool bReturnValue = _client.publish(_fmtBuffer, message.getString(_convBuffer)); debug(PSTR("Ethernet transaction time: %u ms\n"), hwMillis() - start_time); return bReturnValue; }
I just want to know speed of _client.publish() call, but I don't have W5100.
-
the results @robosensor :
0;0;3;0;9;read: 9-9-0 s=3,c=0,t=3,pt=0,l=0,sg=0: 0;0;3;0;9;Sending message on topic: mygateway1-out/9/3/0/0/3 0;0;3;0;9;Ethernet transaction time: 1 ms
1 ms for all received messages. indeed when sensor send temp + humidity from DHT11, the messages the messages arrive quickly to OpenHAB.
But when I send MQTT message from OpenHAB to Gateway, it's very long (https://youtu.be/zQxLzGmCKlY).
-
@mickaelh51 thank you very much for test results! Where is openhab located? Raspberry Pi? Or PC?
-
@robosensor openhab is located on a proxmox server (it's a container).
Openhab server: 172.16.13.237/24 --> MQTTGateway: 172.16.13.145/24
I have many others sensors on arduino that are using MQTT directly (Not mysensors Framework) and they're ok and fast
I think, the MQTT gateway is very slow at some moments and it don't process MQTT messages received (as you can see in my youtube video).
but at some others moments it can process this messagesFor your information, MQTT message is slow before incomingMQTT
void incomingMQTT(char* topic, byte* payload, unsigned int length) { debug(PSTR("Message arrived on topic: %s\n"), topic);
Because when I send MQTT message with OpenHAB or MQTT.fx to mosquitto, it's send immediatly this message.
After X seconds I can see in serial monitor log: "Message arrived...."Have you an idea ?
thanks a lot !
-
HAAAAAAAAAAAAAAAAAA !!!!!! pffffffffffff !!!!
so noob I amit's work now !
I have a lot of arduino in my network, and there are diffrent MAc address => normal !
But in arduino with my sensor there wasn't MY_MAC_ADDRESS defined.
and... two arduino with the same MAC (default MAC) ... pffff ==> doesn't work fine!!!!now it's work perfectly ! I'm sorry for you waste time !
thanks !