Trying to get OTAA functioning

Hardware TTGO LORA OLED VS 2.1
CODE https://github.com/rwanrooy/TTGO-PAXCOUNTER-LoRa32-V2.1-TTN

After successfully connecting and posting data via ABP I have been unable to switch this codebase over to use OTAA even though the process is to simply change a #define

Its puzzling because I can switch back and get ABP working perfectly but OTAA simply times out at “Joining TTN”. I have switched verbose debugging on in the LMIC library and get the message below.

The gateway is a few kilometres away so I tried a Things Node to make sure it was in range and the Things Node works flawlessly, even though it has only a tiny internal aerial.

Any ideas?

Joining TTN…

343150: engineUpdate, opmode=0xc
833881: engineUpdate, opmode=0xc
833973: TXMODE, freq=868100000, len=23, SF=7, BW=125, CR=4/5, IH=0
1148601: setupRx1 txrxFlags 00 --> 01
start single rx: now-rxtime: 3
1149224: RXMODE_SINGLE, freq=868100000, SF=7, BW=125, CR=4/5, IH=0
rxtimeout: entry: 1152519 rxtime: 1149217 entry-rxtime: 3302 now-entry: 5 rxtime-txend: 311126
1210991: setupRx2 txrxFlags 0x1 --> 02
start single rx: now-rxtime: 3
1211474: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
rxtimeout: entry: 1228145 rxtime: 1211467 entry-rxtime: 16678 now-entry: 5 rxtime-txend: 373376
1228446: processRx2Jacc txrxFlags 0x2 --> 00
1228741: engineUpdate, opmode=0xc
5215401: engineUpdate, opmode=0xc
5215486: TXMODE, freq=868300000, len=23, SF=7, BW=125, CR=4/5, IH=0
5530371: setupRx1 txrxFlags 00 --> 01
start single rx: now-rxtime: 3
5530733: RXMODE_SINGLE, freq=868300000, SF=7, BW=125, CR=4/5, IH=0
rxtimeout: entry: 5534027 rxtime: 5530726 entry-rxtime: 3301 now-entry: 4 rxtime-txend: 311126
5592496: setupRx2 txrxFlags 0x1 --> 02
start single rx: now-rxtime: 4
5592983: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
rxtimeout: entry: 5609655 rxtime: 5592976 entry-rxtime: 16679 now-entry: 4 rxtime-txend: 373376
5609956: processRx2Jacc txrxFlags 0x2 --> 00
5610249: engineUpdate, opmode=0xc
9598820: engineUpdate, opmode=0xc
9598905: TXMODE, freq=868500000, len=23, SF=7, BW=125, CR=4/5, IH=0
9913523: setupRx1 txrxFlags 00 --> 01
start single rx: now-rxtime: 4
9914153: RXMODE_SINGLE, freq=868500000, SF=7, BW=125, CR=4/5, IH=0
rxtimeout: entry: 9917447 rxtime: 9914146 entry-rxtime: 3301 now-entry: 5 rxtime-txend: 311126
9975915: setupRx2 txrxFlags 0x1 --> 02
start single rx: now-rxtime: 4
9976403: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
rxtimeout: entry: 9993075 rxtime: 9976396 entry-rxtime: 16679 now-entry: 5 rxtime-txend: 373376
9993377: processRx2Jacc txrxFlags 0x2 --> 00
9993670: engineUpdate, opmode=0xc
13660568: engineUpdate, opmode=0xc
13660653: TXMODE, freq=868100000, len=23, SF=8, BW=125, CR=4/5, IH=0
13978278: setupRx1 txrxFlags 00 --> 01
start single rx: now-rxtime: 3
13978905: RXMODE_SINGLE, freq=868100000, SF=8, BW=125, CR=4/5, IH=0
rxtimeout: entry: 13982472 rxtime: 13978898 entry-rxtime: 3574 now-entry: 5 rxtime-txend: 311126
14040668: setupRx2 txrxFlags 0x1 --> 02
start single rx: now-rxtime: 4
14041155: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
rxtimeout: entry: 14057827 rxtime: 14041148 entry-rxtime: 16679 now-entry: 4 rxtime-txend: 373376
14058129: processRx2Jacc txrxFlags 0x2 --> 00
14058421: engineUpdate, opmode=0xc

Most likely you don’t have downlinks working with ABP either, but simply haven’t noticed their failure as you can get application level uplink packets through even when downlink (for network level housekeeping, etc) is broken.

Often broken downlinks are a timing problem…

Hi all
I have the same problem (Joining TTN…) with OTAA and this code https://github.com/rwanrooy/TTGO-PAXCOUNTER-LoRa32-V2.1-TTN over TTGO LORA OLED VS 2.1.
The gateway is 4 km aprox away; may be this the problem?
Regards