Skip to content

Commit

Permalink
Merge pull request #30 from truvami/bugfix/tagsl-port-4
Browse files Browse the repository at this point in the history
fix(tagsl): port 4 now accepts optional size fields
  • Loading branch information
michaelbeutler authored Jan 21, 2025
2 parents 6ee46d1 + 7acb0fe commit 218dd71
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions pkg/decoder/tagsl/v1/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ func (t TagSLv1Decoder) getConfig(port int16) (decoder.PayloadConfig, error) {
{Name: "HardwareVersionType", Start: 22, Length: 1},
{Name: "HardwareVersionRevision", Start: 23, Length: 1},
{Name: "BatteryKeepAliveMessageInterval", Start: 24, Length: 4},
{Name: "BatchSize", Start: 28, Length: 2, Optional: true},
{Name: "BufferSize", Start: 30, Length: 2, Optional: true},
},
TargetType: reflect.TypeOf(Port4Payload{}),
}, nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/decoder/tagsl/v1/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestDecode(t *testing.T) {
},
},
{
payload: "0000003c0000012c000151800078012c05dc02020100010200005460deadbeef",
payload: "0000003c0000012c000151800078012c05dc02020100010200005460000a1000",
port: 4,
autoPadding: false,
skipValidation: true,
Expand All @@ -191,6 +191,8 @@ func TestDecode(t *testing.T) {
HardwareVersionType: 1,
HardwareVersionRevision: 2,
BatteryKeepAliveMessageInterval: 21600,
BatchSize: 10,
BufferSize: 4096,
},
},
{
Expand Down
16 changes: 9 additions & 7 deletions pkg/decoder/tagsl/v1/port4.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ package tagsl
// +-------+------+-------------------------------------------+------------+

type Port4Payload struct {
LocalizationIntervalWhileMoving uint32 `json:"localizationIntervalWhileMoving"`
LocalizationIntervalWhileSteady uint32 `json:"localizationIntervalWhileSteady"`
HeartbeatInterval uint32 `json:"heartbeatInterval"`
GPSTimeoutWhileWaitingForFix uint16 `json:"gpsTimeoutWhileWaitingForFix"`
AccelerometerWakeupThreshold uint16 `json:"accelerometerWakeupThreshold"`
AccelerometerDelay uint16 `json:"accelerometerDelay"`
LocalizationIntervalWhileMoving uint32 `json:"localizationIntervalWhileMoving" validate:"gte=60,lte=86400"`
LocalizationIntervalWhileSteady uint32 `json:"localizationIntervalWhileSteady" validate:"gte=120,lte=86400"`
HeartbeatInterval uint32 `json:"heartbeatInterval" validate:"gte=300,lte=604800"`
GPSTimeoutWhileWaitingForFix uint16 `json:"gpsTimeoutWhileWaitingForFix" validate:"gte=60,lte=86400"`
AccelerometerWakeupThreshold uint16 `json:"accelerometerWakeupThreshold" validate:"gte=10,lte=8000"`
AccelerometerDelay uint16 `json:"accelerometerDelay" validate:"gte=1000,lte=10000"`
DeviceState uint8 `json:"deviceState"`
FirmwareVersionMajor uint8 `json:"firmwareVersionMajor"`
FirmwareVersionMinor uint8 `json:"firmwareVersionMinor"`
FirmwareVersionPatch uint8 `json:"firmwareVersionPatch"`
HardwareVersionType uint8 `json:"hardwareVersionType"`
HardwareVersionRevision uint8 `json:"hardwareVersionRevision"`
BatteryKeepAliveMessageInterval uint32 `json:"batteryKeepAliveMessageInterval"`
BatteryKeepAliveMessageInterval uint32 `json:"batteryKeepAliveMessageInterval" validate:"gte=300,lte=604800"`
BatchSize uint16 `json:"batchSize" validate:"lte=50"`
BufferSize uint16 `json:"bufferSize" validate:"gte=128,lte=8128"`
}

0 comments on commit 218dd71

Please sign in to comment.