Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript: sparkplug-payload -> Possible to specify converion options when decoding payload? #384

Open
bj00rn opened this issue May 17, 2024 · 0 comments

Comments

@bj00rn
Copy link

bj00rn commented May 17, 2024

Hi,
Is it possible to specify conversion options for longs etc, when decoding payload?

We coming from using protobufjs with sparkplug protocol and using toObject by specified conversion options:

import * as protobuf from 'protobufjs'
import protocol from './sparkplugb.proto'
const root = protobuf.parse(protocol).root
let SparkplugPayload = root.lookupType('com.cirruslink.sparkplug.protobuf.Payload')
let decodedObj = SparkplugPayload.toObject(SparkplugPayload.decode(new Uint8Array(input)), {longs: Number})

I would like to use sparkplug-payload instead for decoding, but now my long timestamps are no longer converted.

import { get } from 'sparkplug-payload'
let sparkplug = get("spBv1.0")
let decodedObj = sparkplug.decodePayload(new Uint8Array(input)))

image

Cheers!

@bj00rn bj00rn changed the title Javascript: Possible to specify converion options when decoding payload? Javascript: sparkplug-payload -> Possible to specify converion options when decoding payload? May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant