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?


  • administrators

    @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

    https://github.com/nicolsc/sigfox-downlink



  • @bucknall I have just two options: "UPLINK" and "BIDIR"

    0_1487866635838_upload-3eca82b9-88ee-45ef-8065-77125f76e36e

    I have worked with the "BIDIR" type, but I still can't send anything


  • administrators

    @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

    0_1487864489636_upload-b35a7580-7574-416f-9bc2-39487bafbbe4

    Pymark section

    0_1487864543639_upload-19e04217-8bc5-4fcf-8905-0e08b68019e6

    Just one more question. I did with a "DIRECT" downlink data mode, can i do with "CALLBACK" mode?


  • administrators

    @Paolo-Prado yes exactly! Can you show me the message when the Sigfox Backend returns the Status:OK message?



  • @bucknall Do you mean this?

    0_1487864167922_Sin título.png


  • administrators

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



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


  • administrators

    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!


Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.