Closed ianmtaylor1 closed 1 year ago
Hello,
How much time do you leave between the commands?
Hi,
I'll see the crash if I send about 1 message every second.
Hello,
I hope I'm not bugging you or stepping on your toes. I did a little more investigating of this issue and found a potential fix, I'm wondering if this makes sense to you.
I think that it has to do with the placement of the call to disableActiveReceiver()
inside the function MQTTtoRF()
(currently line 271 in ZgatewayRF.ino) and that this function should be called before ELECHOUSE_cc1101.setPA()
.
The setPA
function causes an SPI signal to be sent to the CC1101 board. If that board is still receiving, this could interfere with a message that is currently being received. The crash didn't have to do with sending messages too quickly, but with sending a message while a message is being received. This is just more likely to happen when you are sending several messages quickly.
After changing that section of the code to the following:
# ifdef ZradioCC1101 // set Receive off and Transmitt on
disableActiveReceiver(); // <---- THIS MOVED
int txPower = RFdata["txpower"] | RF_CC1101_TXPOWER;
ELECHOUSE_cc1101.setPA((int)txPower);
Log.notice(F("CC1101 TX Power: %d" CR), txPower);
float trMhz = RFdata["mhz"] | CC1101_FREQUENCY;
if (validFrequency((int)trMhz)) {
ELECHOUSE_cc1101.SetTx(trMhz);
Log.notice(F("Transmit mhz: %F" CR), trMhz);
}
# endif
I can no longer reproduce the crash.
I'm not familiar with the internals of these functions, so I don't know if this is 100% correct or if there was any reason disableActiveReceiver()
was being called inside the if(validFrequency((int)trMhz))
conditional. Does this make sense to you? If so, I'm happy to make a pull request if you would like.
Hello,
No problem, this is a collaborative project. Quality comments are always welcome :-) @northernman54 may have a better answer than me on this
@ianmtaylor1 That change makes sense looking at the logic. Pls submit a PR
Thanks for your time!
Before submitting a problem please check the troubleshooting section https://docs.openmqttgateway.com/upload/troubleshoot.html
Describe the bug Occasionally when transmitting, especially when transmitting two signals in quick succession, the board will unexpectedly reboot and print the following error to the serial console:
To Reproduce
Send a series of these messages to the MQTT broker in quick succession:
rfbridge/OpenMQTTGateway/commands/MQTTto433
{"value":1135923,"protocol":1,"length":24,"delay":185,"mhz":433.92,"repeat":5,"cc1101_pa":7}
{"value":1135932,"protocol":1,"length":24,"delay":185,"mhz":433.92,"repeat":5,"cc1101_pa":7}
Expected behavior The Etekcity RF outlet these commands control turns on and off and the ESP32 board does not crash.
Screenshots Full serial output during crash:
Environment (please complete the following information):
my_env.ini
:[env:myenv-433] extends = env:esp32dev-multi_receiver build_flags = ${env:esp32dev-multi_receiver.build_flags} '-UZgatewayPilight' ; Replicate workaround in https://github.com/1technophile/OpenMQTTGateway/pull/1785 '-DESPWifiManualSetup=true' '-Dwifi_ssid=""'
'-Dwifi_password=""'
'-DBase_Topic="rfbridge/"'
'-Ddiscovery_Topic="OMGdiscovery"'
'-DMQTT_SERVER=""'
'-DMQTT_PORT="8883"'
'-DMQTT_SECURE_DEFAULT=true'
'-DMQTT_USER=""'
'-DMQTT_PASS=""'
'-DGateway_Name="OpenMQTTGateway"'