RAKWireless / RAK811_LoRaWAN_Arduino

MCCI_LoRaWAN_LMIC_library
4 stars 0 forks source link

Not Joining #2

Open MilovdZee opened 4 years ago

MilovdZee commented 4 years ago

Hello,

I think there is an issue with the antenna switching... But I'm not sure. Were you able to get this working as-is?

I assume the LMIC has to be extended with PA switching.

MAG, Milo

kallemooo commented 4 years ago

Antenna switching is enabled in the example.

The problem is that the default timekeeping in the STM32 (almost all examples, including the Aurdino plattform) is using interrupts to count milliseconds. The LMIC radio core is executing with interrupts disabled and that causes timekeeping instability.

The result is that the receive window is missed and join is delayed.

To mitigate this problem this following can be done:

MilovdZee commented 4 years ago

Thank you very much. I'll experiment with your suggestions.

mtbspace commented 4 years ago

@MilovdZee, did you manage to solve this?

I have the same problem. I can see the Join Request is accepted on the gateway, but it is not received on the RAK811. I have tried experimenting with different clock errors and different Spread factors when joining, but it is not helping.

@kallemooo, when you say 'Antenna switching is enabled in the example', are you referring to this line of code? .rxtx = 32,

There is more information about switching on the radios here, but this is also not helping:

https://github.com/stm32duino/Arduino_Core_STM32/issues/859

Receive state:

pinMode(RADIO_RF_CRX_RX, OUTPUT);
digitalWrite(RADIO_RF_CRX_RX, 1); //control LoRa work to receive pinMode(RADIO_RF_CTX_PA, OUTPUT);
digitalWrite(RADIO_RF_CTX_PA, 0); //

Transmit state:

pinMode(RADIO_RF_CRX_RX, OUTPUT);
digitalWrite(RADIO_RF_CRX_RX, 0);
pinMode(RADIO_RF_CTX_PA,OUTPUT);
digitalWrite(RADIO_RF_CTX_PA, 1); //control LoRa send by PA_BOOST

MilovdZee commented 4 years ago

Hello, I did not proceed with this. I'm actually trying it in a different way and that is by fully trying to understand the protocol and do it myself. But not much luck yet. The library seems a bit overkill for just registering...

mtbspace commented 4 years ago

I've got this working... I should have read the mcci-catena / arduino-lmic documents sooner! They tell the user to ensure they call 'os_runloop_once()' often enough, because it is polling. I had a delay in my main loop, so it wasn't getting called nearly often enough to catch the join accept.

OTAA is working with no changes to the code (other than keys/EUIs), including no extra allowance for clock error.

I've not tried class b or class c

EDIT: Seems I shouted too soon... Although it now joins easily, receiving downlinks is not reliable

jezdd commented 3 years ago

Having same issues here, I tried going back to older mcci-catena / arduino-lmic versions 3.0, 3.1 etc as were working at one point.

Its all related to the RAK811 tracker being unable to receive downlinks/joins etc - I will try in ABP mode and test normal downlinks.

In my testing on the latest versions of STM core/libraries I am getting OTAA to join maybe once in 50 attempts.

Anyone made progress?

jezdd commented 3 years ago

Been playing with this and got OTAA working but its limited, from my point of view this seems to be a RX1/2 window timing issue.

Using the following I can get SF10 to connect via OTAA every time, also SF11 and SF12 too with less aggressive setclockerror settings. Of course you could switch to ABP but there will still be issues with downlinks.

    case EV_JOINING:
        LMIC_setClockError(MAX_CLOCK_ERROR * 50 / 100);  //Relax RX timing window
        LMIC_setDrTxpow(DR_SF10, 14);  // DR TxPower
        Serial.println(F("EV_JOINING"));
        break;

I am using latest platform and libraries under PlatformIO for testing.

jezdd commented 3 years ago

If anyone is out there I have found a working and stable setup, EU freq from SF7 to SF12 - more a stumble while testing all combo, I stripped back all adjustments for starters. So basic default code:

setup...... os_init();
LMIC_reset(); LMIC_setClockError(MAX_CLOCK_ERROR * 5 / 100); //Relax RX timing window // LMIC_setAdrMode(true); // ADR do_send(&sendjob);

case EV_JOINING: // LMIC_setAdrMode(true); // ADR LMIC_setDrTxpow(DR_SF7, 14); // DR TxPower Serial.println(F("EV_JOINING")); break;

platformio.ini build_flags = -D ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS -D CFG_eu868=1 -D CFG_sx1276_radio=1 -D DISABLE_PING -D DISABLE_BEACONS ; remove this -D LMIC_ENABLE_arbitrary_clock_error=1