Two LoRa Socket

  • 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

  • @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.

  • @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...

  • @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

  • @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.

  • @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.

  • @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 :)

Pycom on Twitter