Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    How does LoRa socket chose which channel to use when you add several using lora.add_channel ?

    Scheduled Pinned Locked Moved MicroPython
    5 Posts 2 Posters 37 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      storm 1050
      last edited by

      Hello,

      I'm trying to understand on which channel my Lopy4 is sending data, for example if I'm allocating these channel :
      3c13e183-f0c8-45de-a0b3-7b7b5e932b45-image.png

      Then sending data using :

      s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
      s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
      s.send(packet)
      

      How do I know which channel is used ? I know it's not the last because it's for downlink but for the uplink I've no idea, is there something to configure ? Or is it automatic ?

      Thanks

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @storm 1050
        last edited by

        @storm-1050 Long time since I went into these kind of details, but IIRC all channels you add using add_channel can be used for uplinks. Downlinks are handled separately, according to the region rules and/or configuration sent by the network. You should not add the downlink channel.

        The channel listed at index 8 is not a downlink channel, but actually an additional DR on an existing uplink channel.

        The device will use any of those links. Don't quite remember if it's round-robin, random, LRU or duty-cycle based, though, but you can check the sources if you want the details. Channel use is also controlled by the network, which can send a mask of which channels to use or not and/or reconfigure channels.

        You can know the channel which was used by the last uplink by using lora.stats() (tx_frequency and sftx).

        1 Reply Last reply Reply Quote 2
        • S Offline
          storm 1050
          last edited by

          Hey thanks for the answer, the lora.stats() is a good tip, as for the source, do you know where is it ? Where am I supposed to search ? Is it the network library ? The socket when you send the packet?
          I'm a bit lost on where the algorithm which choose the channel is located.

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            jcaron @storm 1050
            last edited by

            @storm-1050 a quick glance makes me think this could be in https://github.com/pycom/pycom-micropython-sigfox/blob/Dev/lib/lora/mac/region/RegionEU868.c starting at line 913, but I really haven’t looked into it in detail.

            S 1 Reply Last reply Reply Quote 1
            • S Offline
              storm 1050 @jcaron
              last edited by

              @jcaron It's perfect I found what I want thanks a lot !

              So if people want to know, in RegionEU868.c the function RegionEU868NextChannel, call the function CountNbOfEnabledChannels which check all the channel that are enabled ( channel enabled, joined and available for transmission) which get you a list of available channel and then it select one randomly from this list.

              In LoRaMac.c in the function ScheduleTx, there is a while loop calling RegionEU868NextChannel till one channel is available

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better đź’—

              Register Login
              • 1 / 1
              • First post
                Last post

              Pycom on Twitter

              Pycom