Sigfox RC4 Freezing after 1 msg



  • Hi Forum !

    I encounter a problem when I try to send multiple Sigfox messages from my FiPy card on Sigfox network. After the first msg sent (and received) I must disconnect the kit to get it working again.

    The code is :

    from network import Sigfox
    import socket
    import binascii
    
    # init Sigfox for RCZ4
    sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ4)
    
    # create a Sigfox socket
    s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
    
    # make the socket blocking
    s.setblocking(True)
    s.settimeout(5.0)
    
    # configure it as uplink only
    s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, False)
    
    #Print sigfox ID
    print(binascii.hexlify(sigfox.id()))
    
    for i in range(1,20):
        # send some bytes
        s.send(bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]))
        print("Message {} sent".format(i))
    

    When I change Sigfox.RCZ4 to Sigfox.RCZ1 it works perfectly...



  • @jmarcelino said in Sigfox RC4 Freezing after 1 msg:

    time.sleep(20)

    Works like a charm. Thanks a lot.

    The documentation is a bit misguiding here, it says :

    "there must a minimum of a 20s delay after resetting to the default macro-channel. Our API takes care of this [...]

    for i in range(1, 100):
      # send something
      s.send('Hello ' + str(i))
    

    There will be a 20 second delay after every 2 packets"

    In fact, there should be a delay added between 2 packets. Maybe a suggestion for modification of the doc.

    Anyway, thanks a lot for correcting me !
    All the best.



  • Hi @gsimenel

    I found the problem in our code, it's related to how the socket layer reacts to the enforced wait time for Sigfox resets (necessary for RCZ2 and RCZ4).

    As the docs page explains for compliance reasons we must wait 20 seconds between consecutive sends. This wait should be handled automatically but that is causing some problems.

    For now the easiest solution is to add more time between your sends in your code - at least 20 seconds - for example simply adding a time.sleep(20) like this:

    from network import Sigfox
    import socket
    import binascii
    import time
    
    # init Sigfox for RCZ4
    sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ4)
    
    # create a Sigfox socket
    s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
    
    # make the socket blocking
    s.setblocking(True)
    s.settimeout(30)
    
    # configure it as uplink only
    s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, False)
    
    #Print sigfox ID
    print(binascii.hexlify(sigfox.id()))
    
    for i in range(1,20):
        # send some bytes
        s.send(bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]))
        print("Message {} sent".format(i))
        time.sleep(20)
    

    Please remember that Sigfox has a 140 message/day limit so spacing out your sends is always a good policy.



  • @jmarcelino Thanks a lot. Let me know if I can do anything to assist.



  • Thanks for reporting this @gsimenel, I'll look into it today.



Pycom on Twitter