-
Notifications
You must be signed in to change notification settings - Fork 447
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
[Bug]Can not encode the embedded oneof keyword type in sparkplugb proto schema #1628
Comments
Hi, indeed, the issue you're experiencing is known and has been documented in the protobuf.js GitHub issue tracker: protobufjs/protobuf.js#521 It appears that an official fix still needs to be formally implemented. However, we are considering trying some potential fixes to see if we can temporarily resolve the issue. Thank you for your feedback and patience! Please get in touch with me if you need any more updates or help. |
Your EMQX said it support the Sparkplug, but the MQTTX does not support it. Very stange, are you two different team without any communication? And another problem is the Sparkplug need set the MQTT connetion's Last Will Payload with protobuf as NDEATH payload, and your MQTTX does not support base64 and Hex, so I force transfer the hex to the ugly string. The msg protocol transfer, I let the AI rewrite some simple functions to encode some type of the that my Sparkplug project will used to test. and run it at the MQTTX's Script'Function. function encodeVarint(value) { function encodeUint32(fieldNumber, value) { function encodeUint64(fieldNumber, value) { function encodeStringWithFieldNumber(fieldNumber, value) { function encodeFloat(fieldNumber, value) { function encodeMetric(metric) {
} function encodeMetrics(metrics) { function encodePayload(payload) { const testPayload = { const encodedPayload = encodePayload(testPayload); const nodeDeviceData = [ function randomInt(min = 0, max = 255) { function randomFloat(min = 0, max = 100, isDouble = false) { function randomBoolean() { function randomString(length = 10) { // Function to simulate metric value generation based on datatype function randomFloat(min = 0, max = 100) { // Function to create payload with manually encoded metrics
} let seq = 0; // Global sequence number function getBdSeqNum() { // Example usage: |
|
I copy the schema into the MQTTX Script's Schema input box, and save it.
I input the target json that need to encode.
{ "metrics": [ { "name": "testKey", "alias": 1, "timestamp": 1713020729000, "int_value":100 } ], "extensions": null, "timestamp": 1713020729100, "seq": 36 }
And the output decode json lost the "int_value":100
Payload {
metrics: {
0: {
name: "testKey",
alias: 1,
timestamp: 1713020729000
}
},
timestamp: 1713020729100,
seq: 36
}
Expected
the output should be
Payload {
metrics: [
0: {
name: "testKey",
alias: 1,
timestamp: 1713020729000,
int_value:100
}
],
timestamp: 1713020729100,
seq: 36
}
Environment
More detail
same bug in many protobufjs project or tools
and the online js lib editor and runner https://npm.runkit.com/protobufjs
The text was updated successfully, but these errors were encountered: