Skip to content

Fix null client when using MDNS.#981

Merged
1technophile merged 1 commit into1technophile:developmentfrom
h2zero:mdns-client-fix
Jun 10, 2021
Merged

Fix null client when using MDNS.#981
1technophile merged 1 commit into1technophile:developmentfrom
h2zero:mdns-client-fix

Conversation

@h2zero
Copy link
Collaborator

@h2zero h2zero commented Jun 10, 2021

When using MDNS the client was not initialized prior to the call to connect. This ensures initialization before the call.

@NorthernMan54
Copy link
Collaborator

Same, I will dig deeper into this after work today.

************* WELCOME TO OpenMQTTGateway **************
N: OpenMQTTGateway Version: ddd-bt-rtl-v0.9.6-34-g2737a4c[dev-june-8]
T: Connecting to 67 Bonacres
T: Connecting to The_Beach
N: WiFi ok with manual config credentials
T: OpenMQTTGateway mac: 24:0A:C4:EC:20:DC
T: OpenMQTTGateway ip: 192.168.1.181
T: Connecting to MQTT by mDNS without mqtt hostname
T: Browsing for MQTT service
T: 1 service(s) found
T: Service 0 jesse found
T: IP 192.168.1.11 Port 1883
T: One MQTT server found setting parameters
N: BLE scans interval: 0
N: BLE scans number before connect: 10
N: Publishing only BLE sensors: true
N: minrssi: 100
N: Low Power Mode: 0
T: ZgatewayBT multicore ESP32 setup done 
T: mqtt_max_packet_size: 1024
N: OpenMQTTGateway modules: ["BT"]
N: ************** Setup OpenMQTTGateway end **************
W: MQTT connection...
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400ddd55  PS      : 0x00060c30  A0      : 0x800ddffc  A1      : 0x3ffcd9d0  
A2      : 0x3ffc33b0  A3      : 0x3ffbdc44  A4      : 0x3ffbdd48  A5      : 0x3ffbdd0c  
A6      : 0x3ffcda54  A7      : 0x00000000  A8      : 0x800ddd4e  A9      : 0x3ffcd9b0  
A10     : 0x00000000  A11     : 0x00000001  A12     : 0x00000400  A13     : 0x00000008  
A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x0000001e  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000  

ELF file SHA256: 0000000000000000

Backtrace: 0x400ddd55:0x3ffcd9d0 0x400ddff9:0x3ffcda10 0x400d3108:0x3ffcda40 0x400dd814:0x3ffcdb40 0x400fd5c9:0x3ffcdb60 0x40090d3e:0x3ffcdb80
  #0  0x400ddd55:0x3ffcd9d0 in PubSubClient::connect(char const*, char const*, char const*, char const*, unsigned char, bool, char const*, bool) at .pio/libdeps/ddd-bt-rtl/PubSubClient/src/PubSubClient.cpp:761
  #1  0x400ddff9:0x3ffcda10 in PubSubClient::connect(char const*, char const*, char const*, char const*, unsigned char, bool, char const*) at .pio/libdeps/ddd-bt-rtl/PubSubClient/src/PubSubClient.cpp:761
  #2  0x400d3108:0x3ffcda40 in connectMQTT() at main/ZgatewayBT.ino:280
  #3  0x400dd814:0x3ffcdb40 in loop() at main/ZgatewayBT.ino:280
  #4  0x400fd5c9:0x3ffcdb60 in loopTask(void*) at /Users/xxxxxx/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:37
  #5  0x40090d3e:0x3ffcdb80 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

Rebooting...

@h2zero
Copy link
Collaborator Author

h2zero commented Jun 10, 2021

Thanks, I got quick on pushing this, I see the issue and I'll push the update shortly.

@h2zero h2zero force-pushed the mdns-client-fix branch from 85257c6 to f3f7e1a Compare June 10, 2021 14:25
@NorthernMan54
Copy link
Collaborator

This nailed it, tks

Am recommending that this get merged into the current development branch

************* WELCOME TO OpenMQTTGateway **************
N: OpenMQTTGateway Version: ddd-bt-rtl-v0.9.6-34-g2737a4c[dev-june-8]
T: Connecting to 67 Bonacres
T: Connecting to The_Beach
N: WiFi ok with manual config credentials
T: OpenMQTTGateway mac: 24:0A:C4:EC:20:DC
T: OpenMQTTGateway ip: 192.168.1.181
T: Connecting to MQTT by mDNS without mqtt hostname
T: Browsing for MQTT service
T: 1 service(s) found
T: Service 0 jesse found
T: IP 192.168.1.11 Port 1883
T: One MQTT server found setting parameters
N: BLE scans interval: 0
N: BLE scans number before connect: 10
N: Publishing only BLE sensors: true
N: minrssi: 100
N: Low Power Mode: 0
T: ZgatewayBT multicore ESP32 setup done 
T: mqtt_max_packet_size: 1024
N: OpenMQTTGateway modules: ["BT"]
N: ************** Setup OpenMQTTGateway end **************
W: MQTT connection...
N: Connected to broker
T: Subscription OK to the subjects home/cc1101-dddddd/commands/#
T: omgStatusDiscovery
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home//LWT","name":"SYS: Connectivity","uniq_id":"240AC4EC20DCconnectivity","dev_cla":"connectivity","pl_on":"online","pl_off":"offline","pl_avail":"online","pl_not_avail":"offline","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-34-g2737a4c[dev-june-8]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/binary_sensor/240AC4EC20DCconnectivity/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home//SYStoMQTT","name":"SYS: Uptime","uniq_id":"240AC4EC20DCuptime","val_tpl":"{{ value_json.uptime }}","unit_of_meas":"s","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-34-g2737a4c[dev-june-8]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/sensor/240AC4EC20DCuptime/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home//SYStoMQTT","name":"SYS: Free memory","uniq_id":"240AC4EC20DCfreemem","val_tpl":"{{ value_json.freemem }}","unit_of_meas":"B","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-34-g2737a4c[dev-june-8]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/sensor/240AC4EC20DCfreemem/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home//SYStoMQTT","name":"SYS: IP","uniq_id":"240AC4EC20DCip","val_tpl":"{{ value_json.ip }}","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-34-g2737a4c[dev-june-8]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/sensor/240AC4EC20DCip/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home//SYStoMQTT","name":"SYS: Rssi","uniq_id":"240AC4EC20DCrssi","val_tpl":"{{ value_json.rssi }}","unit_of_meas":"dB","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-34-g2737a4c[dev-june-8]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/sensor/240AC4EC20DCrssi/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home//SYStoMQTT","name":"SYS: Low Power Mode","uniq_id":"240AC4EC20DClowpowermode","val_tpl":"{{ value_json.lowpowermode }}","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-34-g2737a4c[dev-june-8]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/sensor/240AC4EC20DClowpowermode/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home//LWT","name":"SYS: Restart gateway","uniq_id":"240AC4EC20DCrestart","pl_on":"{\"cmd\":\"restart\"}","pl_avail":"online","pl_not_avail":"offline","cmd_t":"home//commands/MQTTtoSYS/config","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-34-g2737a4c[dev-june-8]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/switch/240AC4EC20DCrestart/config
N: Received json : ["BT"]

@1technophile 1technophile added this to the v0.9.7 milestone Jun 10, 2021
@1technophile 1technophile merged commit 2ece72d into 1technophile:development Jun 10, 2021
@NorthernMan54
Copy link
Collaborator

Tks

@h2zero h2zero deleted the mdns-client-fix branch June 11, 2021 00:49
@NorthernMan54
Copy link
Collaborator

@h2zero Finally got some time today to validate this further and look at the MQTT Discovery messages in the log fragment I shared and the various topics, they are missing the gateway name.

@h2zero
Copy link
Collaborator Author

h2zero commented Jun 11, 2021

At least the crash is solved 😄. The gateway name is an odd issue, changes were made to this area, I'm not sure why this would happen though. I'll do some work on it, thanks for the report.

@NorthernMan54
Copy link
Collaborator

Agreed on the crash

@h2zero
Copy link
Collaborator Author

h2zero commented Jun 11, 2021

@NorthernMan54 I believe I have resolved the missing gateway name, could you test this branch https://github.com/h2zero/OpenMQTTGateway/tree/bugfix/gateway-name ? If it works for you I will PR it asap.

@NorthernMan54
Copy link
Collaborator

Just updated my test device, and am getting this, which is great ;-)

************* WELCOME TO OpenMQTTGateway **************
N: OpenMQTTGateway Version: ddd-bt-rtl-v0.9.6-51-g3a24d9e[development-jun-10]
T: Connecting to 67 Bonacres
T: Connecting to The_Beach
N: WiFi ok with manual config credentials
T: OpenMQTTGateway mac: 24:0A:C4:EC:20:DC
T: OpenMQTTGateway ip: 192.168.1.181
T: Connecting to MQTT by mDNS without mqtt hostname
T: Browsing for MQTT service
T: 1 service(s) found
T: Service 0 jesse found
T: IP 192.168.1.11 Port 1883
T: One MQTT server found setting parameters
N: BLE scans interval: 0
N: BLE scans number before connect: 10
N: Publishing only BLE sensors: true
N: minrssi: 100
N: Low Power Mode: 0
T: ZgatewayBT multicore ESP32 setup done 
T: mqtt_max_packet_size: 1024
N: OpenMQTTGateway modules: ["BT"]
N: ************** Setup OpenMQTTGateway end **************
W: MQTT connection...
N: Connected to broker
T: Subscription OK to the subjects home/cc1101-dddddd/commands/#
T: omgStatusDiscovery
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home/cc1101-dddddd/LWT","name":"SYS: Connectivity","uniq_id":"240AC4EC20DCconnectivity","dev_cla":"connectivity","pl_on":"online","pl_off":"offline","pl_avail":"online","pl_not_avail":"offline","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-51-g3a24d9e[development-jun-10]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/binary_sensor/240AC4EC20DCconnectivity/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home/cc1101-dddddd/SYStoMQTT","name":"SYS: Uptime","uniq_id":"240AC4EC20DCuptime","val_tpl":"{{ value_json.uptime }}","unit_of_meas":"s","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-51-g3a24d9e[development-jun-10]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/sensor/240AC4EC20DCuptime/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home/cc1101-dddddd/SYStoMQTT","name":"SYS: Free memory","uniq_id":"240AC4EC20DCfreemem","val_tpl":"{{ value_json.freemem }}","unit_of_meas":"B","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-51-g3a24d9e[development-jun-10]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/sensor/240AC4EC20DCfreemem/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home/cc1101-dddddd/SYStoMQTT","name":"SYS: IP","uniq_id":"240AC4EC20DCip","val_tpl":"{{ value_json.ip }}","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-51-g3a24d9e[development-jun-10]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/sensor/240AC4EC20DCip/config
N: Received json : ["BT"]
T: Pub json :{"stat_t":"home/cc1101-dddddd/SYStoMQTT","name":"SYS: Rssi","uniq_id":"240AC4EC20DCrssi","val_tpl":"{{ value_json.rssi }}","unit_of_meas":"dB","device":{"name":"cc1101-dddddd","model":"[\"BT\"]","manufacturer":"OMG_community","sw_version":"ddd-bt-rtl-v0.9.6-51-g3a24d9e[development-jun-10]","identifiers":["240AC4EC20DC"]}} into custom topic: homeassistant/sensor/240AC4EC20DCrssi/config
N: Received json : ["BT"]

@h2zero
Copy link
Collaborator Author

h2zero commented Jun 11, 2021

Thanks, I will PR it now.

JeroenWiersma pushed a commit to JeroenWiersma/OpenMQTTGateway that referenced this pull request Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants