Hi,
I’ve needed to restart my Rpi a few times recently and noticed a repeating problem, that after a reboot, lwrfd doesn’t work. The following appears in daemon.log and syslog:
May 25 07:19:35 emonpi lwrfd[441]: Starting LightwaveRF MQTT daemon: lwrfd.
May 25 07:19:35 emonpi lwrfd[489]: Failed to connect, return code -1
If I attempt to send any commands by publishing to the lwrf topic, nothing happens, nothing appears in daemon or syslog. If I restart lwrfd, then it works just fine:
sudo service lwrfd restart
May 25 18:50:55 emonpi lwrfd[27091]: Stopping LightwaveRF MQTT daemon: lwrfd.
May 25 18:50:55 emonpi lwrfd[27100]: Starting LightwaveRF MQTT daemon: lwrfd.
May 25 18:50:55 emonpi lwrfd[27107]: Subscribing to topic lwrf for client lwrf using QoS 1
May 25 18:51:04 emonpi lwrfd[27107]: Sending command 0 on channel 1, level 0
May 25 18:51:05 emonpi lwrfd[27107]: Sending command 1 on channel 1, level 0
I think I have found the connect failure message and -1 return code comes from this section in https://github.com/openenergymonitor/lightwaverf-pi/blob/master/lwrfmqtt.c
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
log_msg(“Failed to connect, return code %d\n”, rc);
exit(-1);
I guess that it is a timing issue, and that when lwrf starts something else hasn’t finished yet, hence restarting the service sometime later works, but I can’t see what the conflict is, and I haven’t manged to understand what the code is trying to do. Any ideas?
I am using emoncms v9.6 on a Rpi with RFM69Pi and the OOK transmitter from the OEM store
Thanks. Ian
Edited title (expanded acronym) - Moderator, BT