-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
decode data in frontend #795
Conversation
- Select data type (string, json, hex, uint, int, float) for each topic individually - Default data type is 'string' - Show milliseconds in message received timestamp
- possible data types are: 'json', 'string', 'hex', 'uint8', 'uint16', 'uint32', 'uint64', 'int8', 'int16', 'int32', 'int64', 'float', 'double' - default is 'json'
…tahu-for-sparkplug-decoding
adda7a7
to
c88978f
Compare
backend/src/DataSource/MqttSource.ts
Outdated
@@ -98,7 +98,7 @@ export class MqttSource implements DataSource<MqttOptions> { | |||
|
|||
public publish(msg: MqttMessage) { | |||
if (this.client) { | |||
this.client.publish(msg.topic, msg.payload ? Base64Message.toUnicodeString(msg.payload) : '', { | |||
this.client.publish(msg.topic, msg.payload?.toBuffer() ?? '', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't call method on serialized object. make Base64Message.toBuffer
static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, this is a bit messy.
I'll add a DTO (Data Transfer Object) type to differentiate between these two types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, this is a bit messy. I'll add a DTO (Data Transfer Object) type to differentiate between these two types.
Good, publish is broken at the moment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch btw., Maybe I'll add a few automated test scenarios later on.
This should work now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch btw., Maybe I'll add a few automated test scenarios later on.
This should work now.
Speaking of automated tests, I did a dirty hack when moving to Playwright, the expandTopic logic is broken. It does not work when topics have the same name in path since multiple nodes will be matched.
i.e
/livingtroom/lamp
/bedroom/upstairs/lamp
/lamp/device1
I opened an issue on this #796
@@ -17,6 +19,7 @@ export class TreeNode<ViewModel extends Destroyable> { | |||
public onMessage = new EventDispatcher<Message>() | |||
public onDestroy = new EventDispatcher<TreeNode<ViewModel>>() | |||
public isTree = false | |||
public type: TopicDataType = 'json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thomasnordquist i'm a bit confused about node.type here? Should't type
be derived from the selected Decoder
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understandable, I think you are right.
{options.map(([decoder, format], index) => ( | ||
<MenuItem | ||
key={format} | ||
selected={node && format === node.type} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thomasnordquist i'm a bit confused about node.type here? Should't type
be derived from the selected Decoder
?
What needs to improve: