Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Lorawan and ADR problem. #104

Open
Open
@atoy40

Description

@atoy40

Hello

I'm using :
(sysname='LoPy', nodename='LoPy', release='1.10.2.b1', version='v1.8.6-849-g0af003a4 on 2017-11-24', machine='LoPy with ESP32', lorawan='1.0.0')

I'm trying to use Lorawan with ADR. here is a piece of code :

lora = LoRa(mode=LoRa.LORAWAN, adr=True, public=True, tx_retries=1)
lora.power_mode(LoRa.ALWAYS_ON)
lora.callback(trigger=(LoRa.RX_PACKET_EVENT | LoRa.TX_PACKET_EVENT), handler=lora_cb)

# OTAA code not shown here

s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
s.bind(3)
# default rate to SF12
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 0)
s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, True)

i = 0
while True:
    count = s.send(data)
    print('Sent %s bytes' % count)
    pycom.rgbled(green)
    time.sleep(0.1)
    pycom.rgbled(off)
    time.sleep(9.9 + os.urandom(1)[0]%5)
    i += 1

It seems to work "on the wire" because TX packet has ADR bit set, and RX packet (ack in my case) contains a mac command (LinkADRReq) telling the device to set DR4/SF8 (by default I've setup the socket to DR0/SF12)

The problem seems to be in the lora socket code (modlora.c), because it always ask the Semtech stack to send using the datarate defined in the socket, and it never check the current ChannelsDataRate value stored in the Semtech stack MIB after an ADR LinkADRReq is received.

Thanks for help.
Anthony.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LoRaIssues related to LoRa

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions