mirror of
https://github.com/dpup/meshstream.git
synced 2026-08-06 16:53:09 +02:00
Remove RawEnvelope, RawPacket, and RawData from DecodedPacket struct
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -149,14 +149,8 @@ func TestDecodeMessageWithMapPayload(t *testing.T) {
|
||||
t.Errorf("Expected PortNum to be MAP_REPORT_APP, got %s", decodedPacket.PortNum)
|
||||
}
|
||||
|
||||
// Check that all key fields were populated
|
||||
if decodedPacket.RawEnvelope == nil {
|
||||
t.Error("Expected RawEnvelope to be populated")
|
||||
}
|
||||
|
||||
if decodedPacket.RawPacket == nil {
|
||||
t.Error("Expected RawPacket to be populated")
|
||||
}
|
||||
// These fields are no longer used
|
||||
// Only verify that key metadata was correctly extracted
|
||||
|
||||
// Verify that key metadata was correctly extracted
|
||||
if decodedPacket.From == 0 {
|
||||
|
||||
+3
-11
@@ -40,11 +40,6 @@ type DecodedPacket struct {
|
||||
Source uint32
|
||||
WantResponse bool
|
||||
|
||||
// Raw message objects (for advanced use)
|
||||
RawEnvelope *pb.ServiceEnvelope
|
||||
RawPacket *pb.MeshPacket
|
||||
RawData *pb.Data
|
||||
|
||||
// Error tracking
|
||||
DecodeError error
|
||||
}
|
||||
@@ -135,8 +130,7 @@ func DecodeMessage(payload []byte, topicInfo *TopicInfo) *DecodedPacket {
|
||||
return decoded
|
||||
}
|
||||
|
||||
// Store raw envelope
|
||||
decoded.RawEnvelope = envelope
|
||||
// Extract envelope fields without storing raw envelope
|
||||
|
||||
// Extract envelope fields
|
||||
decoded.ChannelID = envelope.GetChannelId()
|
||||
@@ -149,8 +143,7 @@ func DecodeMessage(payload []byte, topicInfo *TopicInfo) *DecodedPacket {
|
||||
return decoded
|
||||
}
|
||||
|
||||
// Store raw packet
|
||||
decoded.RawPacket = packet
|
||||
// Extract mesh packet fields without storing raw packet
|
||||
|
||||
// Extract mesh packet fields
|
||||
decoded.ID = packet.GetId()
|
||||
@@ -180,8 +173,7 @@ func DecodeMessage(payload []byte, topicInfo *TopicInfo) *DecodedPacket {
|
||||
|
||||
// decodeDataPayload extracts information from a Data message
|
||||
func decodeDataPayload(decoded *DecodedPacket, data *pb.Data) {
|
||||
// Store raw data
|
||||
decoded.RawData = data
|
||||
// Extract data fields without storing raw data
|
||||
|
||||
// Extract data fields
|
||||
decoded.PortNum = data.GetPortnum()
|
||||
|
||||
+1
-38
@@ -745,44 +745,7 @@ func FormatDecodedPacket(packet *DecodedPacket) string {
|
||||
builder.WriteString(fmt.Sprintf("Error decoding packet: %v\n", packet.DecodeError))
|
||||
|
||||
// Show raw data in different formats for debugging
|
||||
if packet.RawData != nil && packet.RawData.GetPayload() != nil {
|
||||
rawData := packet.RawData.GetPayload()
|
||||
builder.WriteString(fmt.Sprintf("Raw data (%d bytes):\n", len(rawData)))
|
||||
builder.WriteString(fmt.Sprintf(" Hex: %x\n", rawData))
|
||||
|
||||
// Show binary representation
|
||||
builder.WriteString(" Binary: ")
|
||||
for i, b := range rawData {
|
||||
if i > 0 && i%8 == 0 {
|
||||
builder.WriteString(" ")
|
||||
}
|
||||
if i > 0 && i%32 == 0 {
|
||||
builder.WriteString("\n ")
|
||||
}
|
||||
builder.WriteString(fmt.Sprintf("%08b ", b))
|
||||
|
||||
// Limit to first 32 bytes for binary representation
|
||||
if i >= 31 {
|
||||
builder.WriteString("...\n")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Show as text if it might be displayable
|
||||
if IsASCII(rawData) {
|
||||
builder.WriteString(fmt.Sprintf(" Text: %s\n", string(rawData)))
|
||||
}
|
||||
} else if packet.RawPacket != nil && packet.RawPacket.GetEncrypted() != nil {
|
||||
// Show raw encrypted data if available
|
||||
encData := packet.RawPacket.GetEncrypted()
|
||||
builder.WriteString(fmt.Sprintf("Raw encrypted data (%d bytes):\n", len(encData)))
|
||||
builder.WriteString(fmt.Sprintf(" Hex: %x\n", encData))
|
||||
|
||||
// Show as text only if it looks like ASCII (rare for encrypted data)
|
||||
if IsASCII(encData) {
|
||||
builder.WriteString(fmt.Sprintf(" Text: %s\n", string(encData)))
|
||||
}
|
||||
} else if packet.Payload != nil {
|
||||
if packet.Payload != nil {
|
||||
// If we have a payload but an error occurred during decoding
|
||||
if data, ok := packet.Payload.([]byte); ok {
|
||||
builder.WriteString(fmt.Sprintf("Raw payload (%d bytes):\n", len(data)))
|
||||
|
||||
Reference in New Issue
Block a user