@Marten setting writeconfig to zero skips the reset as well. Would you consider adapting the second half of the script to read:
send("sys reset")
time.sleep(1)
if writeconfig is 1:
send("mac set nwkskey 2B7E151628AED2A6ABF7158809CF4F3C")
send("mac set appskey 2B7E151628AED2A6ABF7158809CF4F3C")
send("mac set devaddr "+devaddr)
send("mac set adr on")
send("mac save")
time.sleep(5)
send("mac join abp")
while True:
## maybe add cputmp here on a pi
msg="aa"
send("mac tx uncnf 1 "+msg)
time.sleep(60)
To provide a better example?