RAK 3272 P2P Help 2

Hello,

I’ve been able to mostly get a consistent connection between two RAK 3272 modules, but every now and then I get an AT_MODE_NO_SUPPORT on one of the modules. Im using two scripts on raspberry Pi’s, one to send and one to receive and it was working great earlier but now I’m back to having issues.
Current issue is with my receive script after the AT+P2P command-

import serial
import time

UART = serial.Serial('/dev/serial0', 
                    baudrate=115200, 
                    timeout=9.0,
                    parity=serial.PARITY_NONE,
                    stopbits=serial.STOPBITS_ONE)


UART.reset_output_buffer()

print("\r\nChecking LoRa Module Status...")
UART.write(b"AT\r\n")
rcv = UART.read_until(b'\r\n')
status = rcv.decode()
print(" ", status)


# "AT+P2P=freq():SF(5-12):BW(125,250,500):CodeRate(0-3):Preamble(2-655636):TXPower(5-22dBm)>"

print("\r\nConfiguring LoRa Module...")
UART.write(b"AT+P2P=917000000:7:500:0:8:20\r\n")
rcv = UART.read_until(b'\r\n')
status = rcv.decode()
print(" ", status)

print("\r\nConfiguration Check:")
UART.write(b"AT+P2P=?\r\n")
rcv = UART.read_until(b'\r\n')
rcv = rcv.decode()
list = rcv.split(":")
print("\r\n", list)

counter = 1
while True:
    UART.write(b"AT+PRECV=0\r\n")
    rcv = UART.read_until(b'\r\n')


    print("\r\n", counter, " Waiting for data...\r\n")
    UART.write(b"AT+PRECV=65535\r\n")
    rcv = UART.read_until(b'\r\n')
    status = rcv.decode()
    print("Module Status- ", status)

    # Reads until Event flag
    rcv = UART.read_until(b"+EVT:")
    # Reads remainign data after event flag
    rcv = UART.read_until(b"\r\n")

    if rcv:
        rawdata = rcv.decode()
        print("\r\nRaw Data- ", rawdata)
    
        list = rawdata.split(':')
        mode = list[0]

        rsi = list[1]
        snr = list[2]
        hexdata = list[3]
        data = bytes.fromhex(hexdata).decode("utf-8")

        print("\r\nLora Mode:", mode, " Raw RSI:", rsi, " Connection Strength:", (1/(-1*int(rsi))*2000), " SNR:", snr)
        print("\r\nData- ", data)

    UART.reset_output_buffer()
    counter += 1

Console output is-

Send script for reference is-

import serial
import time

UART = serial.Serial('/dev/serial0', 
                    baudrate=115200, 
                    timeout=2.0, 
                    parity=serial.PARITY_NONE,
		    stopbits=serial.STOPBITS_ONE)

UART.reset_output_buffer()

print("\r\nChecking LoRa Module Status...")
UART.write(b"AT\r\n")
rcv = UART.read_until(b'\r\n')
status = str(rcv)
print(" ", status)

print("\r\nConfiguring Work Mode...")
UART.write(b"AT+NWM=0\r\n")
rcv = UART.read_until(b'\r\n')
rcv = UART.read_until(b'\r\n')
rcv = UART.read_until(b'\r\n')
rcv = UART.read_until(b'\r\n')
print(" ", rcv.decode())


# "AT+P2P=freq():SF(5-12):BW(125,250,500):CodeRate(0-3):Preamble(2-655636):TXPower(5-22dBm)>"
print("\r\nConfiguring LoRa Module...")
UART.write(b"AT+P2P=917000000:7:250:0:8:20\r\n")
rcv = UART.read_until(b'\r\n')
print(" ", rcv.decode())

print("\r\nConfiguration Check:")
UART.write(b"AT+P2P=?\r\n")
rcv = UART.read_until(b'\r\n')
rcv = rcv.decode()
list = rcv.split(':')
print("\r\n", list)

data = 0
counter = 0

#time.sleep(5)

while True:

    print("\r\n", counter, " Sending...\r\n")

    strdata = str(data)
    bytedata = strdata.encode("utf-8")
    hexdata = bytedata.hex()
    hexdata = hexdata.encode("utf-8")

    command = b"AT+PSEND=" + hexdata + b"\r\n"
    UART.write(command)
    #print("\r\nWrote-", command)
    #UART.write(b"AT+PSEND=48656C6C6F\r\n")
    rcv = UART.read_until(b'\r\n')
    print(" ", rcv.decode(), "Length-", len(hexdata))


    time.sleep(1)
    data += 1
    counter += 1

Any suggestions/optimizations/fixes are greatly appreciated! Happy with the progress I made today but not sure why I’m having issues again

Hi @Dizzy ,

I will suggest that you add in your receiver, device configuration of work mode as well. Like your implementation in the sender.

print("\r\nConfiguring Work Mode...")
UART.write(b"AT+NWM=0\r\n")
rcv = UART.read_until(b'\r\n')
rcv = UART.read_until(b'\r\n')
rcv = UART.read_until(b'\r\n')
rcv = UART.read_until(b'\r\n')
print(" ", rcv.decode())

I think that’s probably my issue! I thought I had it in both scripts but maybe I saved the wrong version when I was working yesterday. After I restarted the pi’s and the module lost power it probably just forgot what mode it was in and gave errors.

Update: that solved my issue. Sorry to bother with something simple, thought it would be something more involved

1 Like