LoPy4 s.send() getting stuck on second message.



  • I am unable to send more than 1 Sigfox messages in any one instance. I am utilizing deep sleep functionality and when my device wakes it is sometimes required to upload multiple messages.
    I am in the RC4 region and am aware that the API should wait 20s between every 2 uploads, however in my case i don't get to the second upload and the device gets stuck and doesn't continue.
    When sending my messages i run the following code every time i send a message, essentially setting up the Sigfox connection sending the message and then closing the socket every time.

    def sigfox(RCzone, msg , time):
        if messagesInTheLastHour(time) > 0:
            print("Trying to Send Sigfox Message")
            # init Sigfox for RCZ4 (Australia)
            sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=RCzone)
            print("1")
            # create a Sigfox socket
            s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
            print("2")
            # make the socket blocking
            s.setblocking(True)
            print("3")
            # configure it as uplink only
            s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, False)
            print("4")
            # Send Message if specified
            print('Message: {}'.format(msg))
            result = s.send(bytes([msg[0],msg[1],msg[2],msg[3],msg[4],msg[5],msg[6],msg[7],msg[8],msg[9],msg[10],msg[11]]))
            print('Message: {}'.format(msg))
            s.close()
            if result == 12:
                result = True
                messagesThisHour = pycom.nvs_get('hourcount')
                pycom.nvs_set('hourcount',messagesThisHour+1) # increase message counter.
            else:
                result = False
                print("Can't send, no Sigfox Signal")
            return result
        print("Can't send, to many messsages this hour!!")
        return False
    

    Can anyone explain why i am getting stuck or if this is a new issue. I recently updated my firmware and have the latest on both my LoPy4 and Pytrack.


Log in to reply
 

Pycom on Twitter