Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Decode Python struct on TTN using Javascript

    Scheduled Pinned Locked Moved MicroPython
    decodepythonlopypacketdata
    2 Posts 1 Posters 1.1k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      kbman99
      last edited by

      Hey everyone,
      I'm having some trouble in my attempt to send multiple pieces of data over LoRa. I'm currently just messing around with the python struct module and sending random float values.

      I'm using the struct.pack('>f', <value>), but since I'm needing to send multiple values I'm unsure if my method of simply adding the byte strings together (using the above function twice and adding the string together) will get me what I need. Anyways my problem mostly comes out on the decoder side. If I send two floats, that comes out to a total of 8 bytes. How exactly can I pull out the individual values on the Javascript end using the TTN decoder. I've looked around for a while and have seen some answers as far as decoding goes. I mostly looked at this thread here for lat and long, but most people encode the data before sending it and modify it back on the other end.

      So my basic question is, if I send data packed using struct.pack() (assume big endian format), how can I pull those values out in Javascript?

      K 1 Reply Last reply Reply Quote 0
      • K Offline
        kbman99 @kbman99
        last edited by

        Found my answer after hours of looking around.

        Found this beautiful post on TTN regarding decoding the values of different types and what have you found here by
        Arjanvanb on TTN

        The main answer was posted on Stackoverflow by Ilya Bursov.

        1 Reply Last reply Reply Quote 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom