How does socket.recv(bufsize) work?
-
Hello,
I am trying to send data from the sigfox backend but I don't know how to receive them in the sipy.
Someone could help me?
-
@Paolo-Prado Sorry - you're right the downlink is confusingly called "BIDIR" - Have a look at this link for an example of how to get a payload from a server using the downlink
-
@bucknall I have just two options: "UPLINK" and "BIDIR"
I have worked with the "BIDIR" type, but I still can't send anything
-
@Paolo-Prado Brilliant! Yes you can! :) when you specify a callback, you can set it as a "DOWNLINK" type - the Sigfox Backend will make a GET Request at your specified address and you can use this request to send a payload from your server down to your Sigfox Device.
-
@bucknall Well it's working
Pymark section
Just one more question. I did with a "DIRECT" downlink data mode, can i do with "CALLBACK" mode?
-
@Paolo-Prado yes exactly! Can you show me the message when the Sigfox Backend returns the Status:OK message?
-
@bucknall Do you mean this?
-
@Paolo-Prado you need to go into the Sigfox Backend and specify what you want to be sent to your device via Downlink message. Go to:
- Device Type
- Information -> edit (the button is in the top right corner)
- You should see a section called 'Downlink' which specifies what Sigfox will send back to the device when you request a downlink message.
Let me know if this works!
- Device Type
-
Hi @bucknall,
I working whit the code that you showed.
from network import Sigfox
import socket
sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1)
s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
s.setblocking(True)
s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, True)
s.send("hello")
s.recv(32)But I have not yet been able to receive the data. In the backedn Sigfox the callback for the downlink is Status: OK
Regards.
-
Hi @Paolo-Prado if you want to receive a message from the Sigfox Backend, you'll need to use the following block of code -
from network import Sigfox import socket sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1) s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW) s.setblocking(True) s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, True) s.send("hello") s.recv(32)
The important thing to remember about Sigfox is that you must first send an uplink message to Sigfox which will trigger the downlink message.
This line of code sets the downlink request -
s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, True)
Hope this helps!