LoRaWAN - RAK WIRELESS

Place code snippets and demo code here
tcpipchip
Posts: 76
Joined: Fri Apr 02, 2021 12:48 am
Been thanked: 59 times

LoRaWAN - RAK WIRELESS

Post by tcpipchip »

The purpose of this BLOG is to demonstrate how it is possible to send packets to the LoRaWAN network through AT commands sent to the WISOL module LSM110A.
A sequence of bytes AAAAAAAA will be published every 10 seconds on the LoRaWAN CHIRPSTACK network (class a, OTAA).

https://lom204-cli-wisol.blogspot.com/2 ... annex.html

At moment the data are STATIC...new blogs coming using dynamic data, both to UPLINK and DOWNLINK

enjoy! The blog is always upgrading :)
User avatar
Electroguard
Posts: 860
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 276 times
Been thanked: 323 times

Re: LoRaWAN - RAK WIRELESS

Post by Electroguard »

Very thorough (much of sails over my head like the clouds, but that's not unusual).
tcpipchip
Posts: 76
Joined: Fri Apr 02, 2021 12:48 am
Been thanked: 59 times

Re: LoRaWAN - RAK WIRELESS

Post by tcpipchip »

Now Plus a video on BLOG
tcpipchip
Posts: 76
Joined: Fri Apr 02, 2021 12:48 am
Been thanked: 59 times

Re: LoRaWAN - RAK WIRELESS

Post by tcpipchip »

New blog, doing DOWNLINK to trigger RELAY
https://lom204-cli-wisol.blogspot.com/2 ... -como.html

Code: [Local Link Removed for Guests]

rem joined status
pin.mode 2, output 
rem relay 1
pin.mode 23, output
rem relay 1
pin.mode 19, output
rem relay 1
pin.mode 18, output
rem relay 1
pin.mode 5, output

rem relay off
pin(23) = 0
pin(19) = 0
pin(18) = 0
pin(5) = 0

serial2.mode 115200, 13, 15
onserial2 rec2
rem wait

BOOT:
ERRORS_LINKCHECK=0
JOINED$="NO"
FAIL$="NO"

pin(2) = 0
rem Pause enough to receive the JOIN
PAUSE 20000

if JOINED$="YES" then
   goto GOT_JOINED
end if

rem enable LoRaWAN
print2 "AT+NWM=1" + CHR$(13) + CHR$(10)
PAUSE 500

rem enable linkcheck message
print2 "AT+LINKCHECK=2" + CHR$(13) + CHR$(10)
PAUSE 500

rem DEV EUI
print2 "AT+DEVEUI=0080e115051fd80a" + CHR$(13) + CHR$(10)
PAUSE 500

rem APP KEY
print2 "AT+APPKEY=a614d59963a0861edf2702ae6f0e1ad6" + CHR$(13) + CHR$(10)
PAUSE 500

rem AU915
print2 "AT+BAND=6" + CHR$(13) + CHR$(10)
PAUSE 500

rem MASK (regional parameters)
print2 "AT+MASK=0002" + CHR$(13) + CHR$(10)
PAUSE 500

rem CLASS A
print2 "AT+CLASS=A" + CHR$(13) + CHR$(10)
PAUSE 500

rem no confirmation downlink
print2 "AT+CFM=0" + CHR$(13) + CHR$(10)
PAUSE 500

rem TX POWER 14
print2 "AT+TXP=14" + CHR$(13) + CHR$(10)
PAUSE 500

rem adaptative data rate
print2 "AT+ADR=1" + CHR$(13) + CHR$(10)
PAUSE 500

rem private network
print2 "AT+PNM=1" + CHR$(13) + CHR$(10)
PAUSE 500

rem auto join
print2 "AT+JOIN=1:0:10:8" + CHR$(13) + CHR$(10)
PAUSE 500

GOT_JOINED:

while 1=1
  print2 "AT+NJS=?" + CHR$(13) + CHR$(10)
  PAUSE 10000
  IF JOINED$="YES" THEN
    pin(2) = 1
    FAIL$="NO"
    print "Sending Package"
    print2 "AT+MASK=0002" + CHR$(13) + CHR$(10)
    PAUSE 500
    print2 "AT+SEND=2:AAAAAAAA" + CHR$(13) + CHR$(10)
    PAUSE 500
  END IF
  if FAIL$="YES" then
    GOTO BOOT
  end if
wend

rec2:
r$ = serial2.input$
print r$
if INSTR(1, r$, "JOINED")>0 then
  if INSTR(1, r$, "AT_NO_NETWORK_JOINED")>0 then
    FAIL$="YES"
    JOINED$="FALSE"
    GOTO sai_serial2
  else
    PRINT "CONGRATULATIONS, JOINED"
    JOINED$="YES"
    GOTO sai_serial2
  end if
end if
if INSTR(1, r$, "AT+NJS=0")>0 then
  FAIL$="YES"
  JOINED$="FALSE"
  GOTO sai_serial2    
end if
if INSTR(1, r$, "+EVT:SEND_CONFIRMED_FAILED")>0 then
  FAIL$="YES"
  JOINED$="FALSE"
  GOTO sai_serial2    
end if
if INSTR(1, r$, "+EVT:JOIN_FAILED_RX_TIMEOUT")>0 then
  FAIL$="YES"
  JOINED$="FALSE"
  GOTO sai_serial2    
end if
rem downlink
rem +EVT:RX_1:-67:8:UNICAST:4:30303030313131
rem +EVT:LINKCHECK:0:24:1:-67:8
if INSTR(1, r$, "+EVT:RX_1")>0 then
  s$= mid$(r$, INSTR(1, r$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= left$(s$, INSTR(1, s$, "+EVT")-1)
  if INSTR(1, s$, "31")>0 then
    pin(23) = 1  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "32")>0 then
    pin(19) = 1  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "33")>0 then
    pin(18) = 1  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "34")>0 then
    pin(5) = 1  
    GOTO sai_serial2
  end if  
  if INSTR(1, s$, "35")>0 then
    pin(23) = 0  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "36")>0 then
    pin(19) = 0  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "37")>0 then
    pin(18) = 0  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "38")>0 then
    pin(5) = 0 
    GOTO sai_serial2
  end if  
  GOTO sai_serial2    
end if
if INSTR(1, r$, "AT_PARAM_ERROR")>0 then
end if
if INSTR(1, r$, "+EVT:LINKCHECK")>0 then
  if INSTR(1, r$, "+EVT:LINKCHECK:1:0:0:0:0")>0 then
    ERRORS_LINKCHECK=ERRORS_LINKCHECK+1
    if ERRORS_LINKCHECK=3 THEN
      ERRORS_LINKCHECK=0
      FAIL$="YES"
      JOINED$="FALSE"
      GOTO sai_serial2    
    end if
  else
    print "Package Sent"
    ERRORS_LINKCHECK=0
    GOTO sai_serial2    
  end if
end if
sai_serial2:
return
tcpipchip
Posts: 76
Joined: Fri Apr 02, 2021 12:48 am
Been thanked: 59 times

Re: LoRaWAN - RAK WIRELESS

Post by tcpipchip »

Hi Francesco

after install the new ANNEX firmware...now i am getting this error...after some minutes of execution...
image.png
Here the code

Code: [Local Link Removed for Guests]

rem joined status
pin.mode 2, output 
rem relay 1
pin.mode 23, output
rem relay 1
pin.mode 19, output
rem relay 1
pin.mode 18, output
rem relay 1
pin.mode 5, output

rem relay off
pin(23) = 0
pin(19) = 0
pin(18) = 0
pin(5) = 0

serial2.mode 115200, 13, 15
onserial2 rec2
rem wait

BOOT:
ERRORS_LINKCHECK=0
JOINED$="NO"
FAIL$="NO"

pin(2) = 0
rem Pause enough to receive the JOIN
PAUSE 20000

if JOINED$="YES" then
   goto GOT_JOINED
end if

rem enable LoRaWAN
print2 "AT+NWM=1" + CHR$(13) + CHR$(10)
PAUSE 500

rem enable linkcheck message
print2 "AT+LINKCHECK=2" + CHR$(13) + CHR$(10)
PAUSE 500

rem DEV EUI
print2 "AT+DEVEUI=0080e115051fd80a" + CHR$(13) + CHR$(10)
PAUSE 500

rem APP KEY
print2 "AT+APPKEY=a614d59963a0861edf2702ae6f0e1ad6" + CHR$(13) + CHR$(10)
PAUSE 500

rem AU915
print2 "AT+BAND=6" + CHR$(13) + CHR$(10)
PAUSE 500

rem MASK (regional parameters)
print2 "AT+MASK=0002" + CHR$(13) + CHR$(10)
PAUSE 500

rem CLASS A
print2 "AT+CLASS=A" + CHR$(13) + CHR$(10)
PAUSE 500

rem no confirmation downlink
print2 "AT+CFM=0" + CHR$(13) + CHR$(10)
PAUSE 500

rem TX POWER 14
print2 "AT+TXP=14" + CHR$(13) + CHR$(10)
PAUSE 500

rem adaptative data rate
print2 "AT+ADR=1" + CHR$(13) + CHR$(10)
PAUSE 500

rem private network
print2 "AT+PNM=1" + CHR$(13) + CHR$(10)
PAUSE 500

rem auto join
print2 "AT+JOIN=1:0:10:8" + CHR$(13) + CHR$(10)
PAUSE 500

GOT_JOINED:

while 1=1
  print2 "AT+NJS=?" + CHR$(13) + CHR$(10)
  PAUSE 10000
  IF JOINED$="YES" THEN
    pin(2) = 1
    FAIL$="NO"
    print "Sending Package"
    print2 "AT+MASK=0002" + CHR$(13) + CHR$(10)
    PAUSE 500
    print2 "AT+SEND=2:AAAAAAAA" + CHR$(13) + CHR$(10)
    PAUSE 500
  END IF
  if FAIL$="YES" then
    GOTO BOOT
  end if
wend

rec2:
r$ = serial2.input$
print r$
if INSTR(1, r$, "JOINED")>0 then
  if INSTR(1, r$, "AT_NO_NETWORK_JOINED")>0 then
    FAIL$="YES"
    JOINED$="FALSE"
    GOTO sai_serial2
  else
    PRINT "CONGRATULATIONS, JOINED"
    JOINED$="YES"
    GOTO sai_serial2
  end if
end if
if INSTR(1, r$, "AT+NJS=0")>0 then
  FAIL$="YES"
  JOINED$="FALSE"
  GOTO sai_serial2    
end if
if INSTR(1, r$, "+EVT:SEND_CONFIRMED_FAILED")>0 then
  FAIL$="YES"
  JOINED$="FALSE"
  GOTO sai_serial2    
end if
if INSTR(1, r$, "+EVT:JOIN_FAILED_RX_TIMEOUT")>0 then
  FAIL$="YES"
  JOINED$="FALSE"
  GOTO sai_serial2    
end if
rem downlink
rem +EVT:RX_1:-67:8:UNICAST:4:30303030313131
rem +EVT:LINKCHECK:0:24:1:-67:8
if INSTR(1, r$, "+EVT:RX_1")>0 then
  s$= mid$(r$, INSTR(1, r$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= mid$(s$, INSTR(1, s$, ":")+1)
  s$= left$(s$, INSTR(1, s$, "+EVT")-1)
  if INSTR(1, s$, "31")>0 then
    pin(23) = 1  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "32")>0 then
    pin(19) = 1  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "33")>0 then
    pin(18) = 1  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "34")>0 then
    pin(5) = 1  
    GOTO sai_serial2
  end if  
  if INSTR(1, s$, "35")>0 then
    pin(23) = 0  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "36")>0 then
    pin(19) = 0  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "37")>0 then
    pin(18) = 0  
    GOTO sai_serial2
  end if
  if INSTR(1, s$, "38")>0 then
    pin(5) = 0 
    GOTO sai_serial2
  end if  
  GOTO sai_serial2    
end if
if INSTR(1, r$, "AT_PARAM_ERROR")>0 then
end if
if INSTR(1, r$, "+EVT:LINKCHECK")>0 then
  if INSTR(1, r$, "+EVT:LINKCHECK:1:0:0:0:0")>0 then
    ERRORS_LINKCHECK=ERRORS_LINKCHECK+1
    if ERRORS_LINKCHECK=3 THEN
      ERRORS_LINKCHECK=0
      FAIL$="YES"
      JOINED$="FALSE"
      GOTO sai_serial2    
    end if
  else
    print "Package Sent"
    ERRORS_LINKCHECK=0
    GOTO sai_serial2    
  end if
end if
sai_serial2:
return
This is not happenning in older annex versions
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 2059
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1358 times
Contact:

Re: LoRaWAN - RAK WIRELESS

Post by cicciocb »

I'll try to understand why, another user reported the same problem. Probably is caused by the gotos
BeanieBots
Posts: 345
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 183 times
Been thanked: 112 times

Re: LoRaWAN - RAK WIRELESS

Post by BeanieBots »

There was a version which gave this error when exiting a while/wend loop. Can't recall the version but it did get fixed. Maybe it's back?
Edit: Was fixed in 1.48.2 (assuming it's the same issue)
Last edited by BeanieBots on Thu Nov 23, 2023 8:27 pm, edited 1 time in total.
User avatar
cicciocb
Site Admin
Posts: 2059
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1358 times
Contact:

Re: LoRaWAN - RAK WIRELESS

Post by cicciocb »

I think I found a way to reproduce the problem.
The cause is since I introduced the ELSEIF :oops:

The code below reproduce the problem

Code: [Local Link Removed for Guests]

a = 10
b = 20
for z = 1 to 70000
  if a = 10 then
    if (z and 1) = 0 then
      goto popo
    end if
  end if
popo:
next z
User avatar
Electroguard
Posts: 860
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 276 times
Been thanked: 323 times

Re: LoRaWAN - RAK WIRELESS

Post by Electroguard »

fails.jpg

Might be worth reducing 97 to a single line, cos IF 97 does GOTO BOOT then the corresponding ENDIF on line 99 never completes, leaving an unmatched IF ENDIF next time through.

97 if FAIL$="YES" then GOTO BOOT
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 2059
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1358 times
Contact:

Re: LoRaWAN - RAK WIRELESS

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Thu Nov 23, 2023 8:44 pm fails.jpg


Might be worth reducing 97 to a single line, cos IF 97 does GOTO BOOT then the corresponding ENDIF on line 99 never completes, leaving an unmatched IF ENDIF next time through.

97 if FAIL$="YES" then GOTO BOOT
I know the GOTO are a bad habit and should be avoided BUT that code, in any cases, should work.
Post Reply