Hello there, complete newby here to MySensors. I have been spending quite some time troubleshooting a particular issue that looks like a message protocol version mismatch but I have no idea why.
Setup:
- Miniwireless RFM69cw running the following sketch:
#define MY_DEBUG
#define MY_RADIO_RFM69
#define MY_RFM69_NEW_DRIVER
//#define MY_RFM69_ENABLE_ENCRYPTION
#define MY_DEBUG_VERBOSE_RFM69
#define MY_RADIO_RFM69
#define MY_RFM69_FREQUENCY RFM69_915MHZ
#define MY_RFM69_CS_PIN 10
#define MY_RFM69_IRQ_PIN 2
#define MY_BAUD_RATE 19200
#include <MySensors.h>
- Adafruit RFM69 Bonnet on Raspberry Pi 3 with the following configuration:
./configure \
--spi-driver=SPIDEV \
--spi-spidev-device=/dev/spidev0.0 \
--my-transport=rfm69 \
--my-rfm69-frequency=915 \
--my-rfm69-irq-pin=15 \
--my-rfm69-cs-pin=26 \
--my-is-rfm69hw \
--my-gateway=ethernet \
--my-port=5003 \
--my-debug=enable \
--extra-cxxflags="-DMY_RFM69_RST_PIN=22 -DMY_DEBUG_VERBOSE_TRANSPORT_HAL"
Because of the nature of my problem I added a simple printf statement in the RFM69_receive function in RFM69_new.cpp:
LOCAL uint8_t RFM69_receive(uint8_t *buf, const uint8_t maxBufSize)
{
const uint8_t payloadLen = min(RFM69.currentPacket.payloadLen, maxBufSize);
const uint8_t sender = RFM69.currentPacket.header.sender;
const rfm69_sequenceNumber_t sequenceNumber = RFM69.currentPacket.header.sequenceNumber;
const uint8_t controlFlags = RFM69.currentPacket.header.controlFlags;
const rfm69_RSSI_t RSSI = RFM69.currentPacket.RSSI;
printf("len=%d snd=%d seq=%d flg=%d rss=%d\n", payloadLen, sender, sequenceNumber, controlFlags, RSSI);
if (buf != NULL) {
(void)memcpy((void *)buf, (void *)&RFM69.currentPacket.payload, payloadLen);
}
// clear data flag
RFM69.dataReceived = false;
if (RFM69_getACKRequested(controlFlags) && !RFM69_getACKReceived(controlFlags)) {
#if defined(MY_GATEWAY_FEATURE) && (F_CPU>16*1000000ul)
// delay for fast GW and slow nodes
delay(50);
#endif
RFM69_sendACK(sender, sequenceNumber, RSSI);
}
return payloadLen;
}
The debug output of the mysgw process is as follows immediately after starting and then a bit later when the miniwireless module starts up:
pi@rfm69-1:~/MySensors $ sudo ./bin/mysgw
May 24 01:27:58 INFO Starting gateway...
May 24 01:27:58 INFO Protocol version - 2.3.2
May 24 01:27:58 DEBUG MCO:BGN:INIT GW,CP=RPNGL---,FQ=NA,REL=255,VER=2.3.2
May 24 01:27:58 DEBUG TSF:LRT:OK
May 24 01:27:58 DEBUG TSM:INIT
May 24 01:27:58 DEBUG TSF:WUR:MS=0
May 24 01:27:58 DEBUG THA:INIT
May 24 01:27:58 DEBUG TSM:INIT:TSP OK
May 24 01:27:58 DEBUG TSM:INIT:GW MODE
May 24 01:27:58 DEBUG THA:SAD:ADDR=0
May 24 01:27:58 DEBUG TSM:READY:ID=0,PAR=0,DIS=0
May 24 01:27:58 DEBUG MCO:REG:NOT NEEDED
May 24 01:27:58 DEBUG Listening for connections on :5003
May 24 01:27:58 DEBUG MCO:BGN:STP
May 24 01:27:58 DEBUG THA:SAN:RES=1
May 24 01:27:58 DEBUG MCO:BGN:INIT OK,TSP=1
May 24 01:27:58 DEBUG TSM:READY:NWD REQ
May 24 01:27:58 DEBUG THA:SND:MSG=0000FF020314FF
May 24 01:27:58 DEBUG THA:SND:MSG LEN=7,RES=1
May 24 01:27:58 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
May 24 01:28:21 DEBUG THA:DATA:AVAIL
len=7 snd=32 seq=100 flg=1 rss=62
May 24 01:28:21 DEBUG THA:RCV:MSG=64FF020307FF00
May 24 01:28:21 DEBUG !THA:RCV:PVER=3
May 24 01:28:22 DEBUG THA:DATA:AVAIL
len=7 snd=32 seq=100 flg=2 rss=71
May 24 01:28:22 DEBUG THA:RCV:MSG=64FF020307FF00
May 24 01:28:22 DEBUG !THA:RCV:PVER=3
May 24 01:28:23 DEBUG THA:DATA:AVAIL
len=7 snd=32 seq=100 flg=3 rss=66
May 24 01:28:23 DEBUG THA:RCV:MSG=64FF020307FF00
May 24 01:28:23 DEBUG !THA:RCV:PVER=3
May 24 01:28:25 DEBUG THA:DATA:AVAIL
len=7 snd=32 seq=100 flg=4 rss=66
May 24 01:28:25 DEBUG THA:RCV:MSG=64FF020307FF00
May 24 01:28:25 DEBUG !THA:RCV:PVER=3
while the miniwireless output on the Arduino serial monitor is:
__ __ ____
| \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___
| |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
| | | | |_| |___| | __/ | | \__ \ _ | | \__ \
|_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/
|___/ 2.3.2
104 MCO:BGN:INIT NODE,CP=RPNNA---,FQ=8,REL=255,VER=2.3.2
167 TSM:INIT
174 TSF:WUR:MS=0
184 RFM69:INIT
192 RFM69:INIT:PIN,CS=10,IQP=2,IQN=0
212 RFM69:PTX:LEVEL=5 dBm
225 TSM:INIT:TSP OK
235 TSF:SID:OK,ID=100
247 TSM:FPAR
256 RFM69:SWR:SEND,TO=255,SEQ=0,RETRY=0
276 RFM69:CSMA:RSSI=-84
...
776 RFM69:CSMA:RSSI=-83
794 ?TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2834 !TSM:FPAR:NO REPLY
2846 TSM:FPAR
2854 RFM69:SWR:SEND,TO=255,SEQ=1,RETRY=0
2877 RFM69:CSMA:RSSI=-84
...
3371 RFM69:CSMA:RSSI=-84
3391 ?TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
5431 !TSM:FPAR:NO REPLY
5443 TSM:FPAR
5451 RFM69:SWR:SEND,TO=255,SEQ=2,RETRY=0
5474 RFM69:CSMA:RSSI=-83
...
5967 RFM69:CSMA:RSSI=-82
5988 ?TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
8028 !TSM:FPAR:NO REPLY
8040 TSM:FPAR
8048 RFM69:SWR:SEND,TO=255,SEQ=3,RETRY=0
8071 RFM69:CSMA:RSSI=-83
...
8564 RFM69:CSMA:RSSI=-83
8585 ?TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
10625 !TSM:FPAR:FAIL
10635 TSM:FAIL:CNT=1
10647 TSM:FAIL:DIS
10657 TSF:TDI:TSL
10665 RFM69:RSL
As you can see the fields in my printf statement don't seem to be correct. The sequence number seems to be decoded as the flags field, and the sender as the sequence number. I'm running from the master branch on github and the current Arduino MySensors library.
For the life of me I cannot think of what else was changed. I believe the install is as clean as it can be starting from a clean Raspbian and latest pull from github. The only other change I made was in RFM69_new.cpp to enable the RFM69_CS_PIN as per instruction in a previous thread. Thank you for that, the support and documentation on this site is really very good.
It's probably something silly I did, so my apologies in advance.