Problem with Sigfox Payload


  • Pybytes Beta

    Hi All,
    Using Pytrack with SiPy for sending GPS coordinates to Sigfox backend.
    For example a payload sended by SiPy: b'\xd5\x17M\x00r\xb5\x08\x00' appear in the Sigfox backend as "d5174d0072b50800" !
    When I try to decode this payload by "int1::4 int2::4" in the payload display, I never obtain the Latitude and Longitude expected

    Is someone has the solution ? Thanks for help.
    Jiemde


  • Pybytes Beta

    @livius
    Hi livius, That's work!, now I need to understand how work the "format" of the "pack" function and specialy "little and big-endian.

    Best regards
    Jiemde



  • @Jiemde
    Ahh i see :) I have missed it.

    and i see problem (previously i have thinked in opposite direction)

    try do this (one of this should do the trick)

    datatosend = struct.pack('>II', int(coords[0]*100000),  int(coords[1]*100000))
    

    or not and on sigfox backend (i do not know why little not do the job and suppose that only above line will work for you)

    int1:uint::32:big-endian int2:uint::32:big-endian
    

  • Pybytes Beta

    @livius
    Yes it 's my position !
    The coords are displayed just before the "sigfox send: " on the output in Atom/pymakr picture.

    (50.5236, 5.707314)

    Jiemde



  • @Jiemde

    is this really your position?

    b'\xc8\x17M\x00k\xb5\x08\x00'
    (5052360, 570731)
    

    will be really helpfull to see

    print(coords)
    

    as mentioned below



  • @Jiemde
    can you add before struct.pack

    print(coords)
    or
    print(str(coords)) #if above not work cast first to string
    

  • Pybytes Beta

    @livius
    You will find the output you ask:

    def sendtosigfox():

    datatosend = struct.pack('ii', int(coords[0]*100000),  int(coords[1]*100000))
    print('sigfox send: {}\n'.format(datatosend))
    size1=struct.calcsize('i')
    size2=struct.calcsize('ii')
    print('calcsize: ', size1, size2)
    
    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, False)
    
    s.send(datatosend)
    s.setblocking(False)
    s.close()
    

    while True:
    acc = LIS2HH12(py)
    roll = acc.roll()
    print('X= ', roll)
    pitch = acc.pitch()
    print('Y= ', pitch)
    yaw = acc.yaw()
    print('Z= ', yaw)
    time.sleep(1)
    gps = L76GNSS(py)
    coords = gps.coordinates()
    print(coords)
    sendtosigfox()
    time.sleep(600)

    The output in Atom/Pymakr:
    0_1499096050194_Untitled-3.png

    The output in Sigfox backend
    0_1499096109639_Untitled-2.png

    Regards
    Jiemde


  • Pybytes Beta

    @livius
    No change in the displaying data.
    As I don't have my SiPy/Pytrack with me at my office, I will reply this evening to your other question.

    best regards
    jiemde



  • @Jiemde

    sadly i do not have sipy to test self but
    looking at your values i see that you have variation on most significant bits
    try then this:
    int1:uint::32:little-endian int2:uint::32:little-endian

    if this does not help then post output from corrds recived by pytrack + output packed
    and what you got for this frames on sigfox


  • Pybytes Beta

    @livius
    Here is the printscreen
    0_1499085211840_Capture d'écran 2017-07-03 14.31.56.png



  • @Jiemde
    what are results - maybe this hint something


  • Pybytes Beta

    @livius
    Had already tested this but not the good result.

    jiemde


  • Pybytes Beta

    @livius
    Yes of course! :))



  • @Jiemde
    sorry mistake
    int1:uint::32 int2:uint::32


  • Pybytes Beta

    @bucknall
    The Sigfox backend display "d5174d0072b50800"
    The decoding payload "int1::4 int2::4", display 2 integer but not the good one!

    0_1499083800253_Capture d'écran 2017-07-03 14.06.17.png image url)



  • @Jiemde
    now it is much cliear where you have the problem

    i do not know sigfox much but this format is valid?
    int1::4 int2::4

    i suppose you need
    int1:uint::4 int2:uint::4


  • Pybytes Beta

    @livius
    Yes the coordinates are right !
    When you take the 4 first bytes of the payload seeing in Sigfox for example " d5174d00" and you enter this part of payload in an "Lat=struct.unpack('i', b'\0xd5\0x17\0x4d\0x00') you will retreive the good Latitude.
    I think that teh code is sending the good coordinates, but I don't find how to configure the payload display in "device type" in the Sigfox backend !

    Regards
    jiemde


  • administrators

    @Jiemde

    That looks to be fine - What does the Sigfox Backend give you, instead of the data you're expecting? Also as @livius has suggested, what GPS are you using?

    @livius We'll be adding the CRC check and utilization of other GPS messages shortly. Thanks for your patience!



  • @Jiemde
    First question is - do you have good coordinates retrived by pytrack without sending it to sigfox?
    I ask because if you used official library then current library do not calculate CRC and do not check for fix in messages.
    And it use only GNGLL glonass message ignoring all other messages also GPS messages.


  • Pybytes Beta

    Hi Alex,
    Here is the code:

    def sendtosigfox():

    datatosend = struct.pack('ii', int(coords[0]*100000),  int(coords[1]*100000))
    
    print('sigfox send: {}\n'.format(datatosend))
    
    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, False)
    
    s.send(datatosend)
    s.setblocking(False)
    s.close()
    

    Thanks
    Jiemde


Log in to reply
 

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