I am using a MultiTech gateway and an STM32WB5MMG controller. Initially, the device joins via OTAA, and after several packets are successfully transferred, the gateway gets disconnected due to a power issue and is turned on again. However, the device does not rejoin for several attempts. Only after resetting the end node does it rejoin from the beginning.
I want the device to reconnect automatically without needing a reset, even when the gateway is turned off and on again.
Not strictly relevant to your query - but that’s a BLE part …
What firmware / LW stack are you using?
Fundamentally what you are asking for is impossible - there is no connection between the device & gateway. The device can never know that the gateway is offline unless … see below. And a gateway that keeps going offline isn’t very useful - perhaps put it on a UPS - and if it’s on TTN, remove it immediately as it represents a denial of service to other community users.
And there is no reason for the gateway power cycling - even for a long duration - for the device to lose its session - so there is something really out of specification going on here.
What you can do is perform a link check at reasonable intervals (bearing in mind that that triggers a downlink) and after a couple of missing replies, do a rejoin. But a rejoin should not be necessary, the gateway holds no state