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

    Two LoRa Socket

    Scheduled Pinned Locked Moved LoPy
    lorasocketthreadpymakrpython
    7 Posts 4 Posters 1.4k Views 4 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.
    • A Offline
      AHellLycan
      last edited by

      Hi, I'm making a project where I need to use two LoRa threads, the first one to send a message, and the second one will be always listening, the problem is that when I use this code:

         s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
      

      On the second thread it gives me an error saying that the socket is busy.
      Is there a way to create two LoRa Sockets and use them at the same time?
      Thanks in advance

      C J 2 Replies Last reply Reply Quote 0
      • C Offline
        combaindeft @AHellLycan
        last edited by

        @ahelllycan

        From what I've read about the LoRa specification, you can only either Receive or Transmit ... but never do the same at the same time.

        Maybe, try something like:
        s_rx = socket.socket(socket.AF_LORA)
        s_tr = socket.socket(socket.SOCK_RAW)

        and use s_rx when you want to Listen/Receive, ... and when you want to transmit/sends messages use s_tr ...

        Since LoRa is for low-power ... it's not part of the Specification to use use a lot of power ...

        But, I'll stand corrected :)

        T 1 Reply Last reply Reply Quote 0
        • J Offline
          jcaron @AHellLycan
          last edited by

          @ahelllycan Is there a specific reason you need two sockets? Just use the same socket for both. You can even set up a trigger to call a function when a frame is received.

          A 1 Reply Last reply Reply Quote 1
          • T Offline
            timh @combaindeft
            last edited by

            @combaindeft I think your confusing functionality of the radios with sockets. Whilst the radio can't transmit at receive at the same time. That doesn't mean the socket can't.

            1 Reply Last reply Reply Quote 0
            • A Offline
              AHellLycan @jcaron
              last edited by

              @jcaron How can I set up a trigger to send a message?, my lopy is always listening a lot of messages so is always busy.

              Thank you

              J T 2 Replies Last reply Reply Quote 0
              • J Offline
                jcaron @AHellLycan
                last edited by

                @ahelllycan not sure what you mean by a trigger to send? You can receive a callback when a message has been received, but it’s up to you to decide when you want to send.

                If your issue is that the channel is constantly busy, then you have a design issue...

                1 Reply Last reply Reply Quote 0
                • T Offline
                  timh @AHellLycan
                  last edited by

                  @ahelllycan I think we would need to see code, or general overview of your process. At the moment we are guessing. But @jcaron is right. You should have a call back on message receive and you choose when to send messages based on other criteria. The rest of the time you will be sleeping or waiting.

                  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