Skip to content

Commit 07e3459

Browse files
authored
Rename Version to BaseVersion (#12)
* rename Version to BaseVersion to be in sync with RFC * updated README for 1.0.0
1 parent 7fc6a98 commit 07e3459

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
`go get github.com/objenious/senml`
88

9-
## Status: beta (no breaking changes expected)
9+
## Status: stable
1010

11-
This package implements the SenML format (Sensor Measurement Lists, formerly known as Sensor Markup Language), as defined in [RFC8428](https://tools.ietf.org/html/rfc8428)
11+
This package implements the SenML format (Sensor Measurement Lists, formerly known as Sensor Markup Language), as defined in [RFC8428](https://tools.ietf.org/html/rfc8428).
1212

1313
This package is used in production on the Objenious LoRaWAN platform, and is maintained.
1414

15+
> Warning: a breaking change was introduced in version 1.0.0, with the Record.Version being renamed to Record.BaseVersion.
16+
1517
## Encoding/decoding
1618

1719
Encoding to/from JSON and XML is managed by the standard library.

record.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Record struct {
1010
BaseValue *float64 `json:"bv,omitempty" xml:"bv,attr,omitempty"`
1111
BaseSum *float64 `json:"bs,omitempty" xml:"bs,attr,omitempty"`
1212

13-
Version int `json:"bver,omitempty" xml:"bver,attr,omitempty"`
13+
BaseVersion int `json:"bver,omitempty" xml:"bver,attr,omitempty"`
1414

1515
Name string `json:"n,omitempty" xml:"n,attr,omitempty"`
1616
Unit Unit `json:"u,omitempty" xml:"u,attr,omitempty"`
@@ -39,7 +39,7 @@ func (r *Record) Equals(r2 *Record) bool {
3939
if r.BaseUnit != r2.BaseUnit {
4040
return false
4141
}
42-
if r.Version != r2.Version {
42+
if r.BaseVersion != r2.BaseVersion {
4343
return false
4444
}
4545
if r.Name != r2.Name {

senml.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ func (p Pack) Normalize() Pack {
3838
if p[i].BaseTime != 0 {
3939
btime = p[i].BaseTime
4040
}
41-
if p[i].Version != 0 {
42-
bver = p[i].Version
41+
if p[i].BaseVersion != 0 {
42+
bver = p[i].BaseVersion
4343
}
4444
if p[i].BaseUnit != "" {
4545
bunit = p[i].BaseUnit
@@ -54,10 +54,10 @@ func (p Pack) Normalize() Pack {
5454
bsum = *p[i].BaseSum
5555
}
5656
r := Record{
57-
Name: bname + p[i].Name,
58-
Time: btime + p[i].Time,
59-
Unit: bunit,
60-
Version: bver,
57+
Name: bname + p[i].Name,
58+
Time: btime + p[i].Time,
59+
Unit: bunit,
60+
BaseVersion: bver,
6161
}
6262
if p[i].Unit != "" {
6363
r.Unit = p[i].Unit

senml_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ func TestXML(t *testing.T) {
444444
},
445445
{
446446
src: Pack{
447-
{BaseName: "urn:dev:ow:10e2073a01080063", BaseTime: 1.276020076001e+09, BaseUnit: Ampere, Version: 5, Name: "voltage", Unit: Volt, Value: Float(120.1)},
447+
{BaseName: "urn:dev:ow:10e2073a01080063", BaseTime: 1.276020076001e+09, BaseUnit: Ampere, BaseVersion: 5, Name: "voltage", Unit: Volt, Value: Float(120.1)},
448448
{Name: "current", Time: -5, Value: Float(1.2)},
449449
{Name: "current", Time: -4, Value: Float(1.3)},
450450
{Name: "current", Time: -3, Value: Float(1.4)},

0 commit comments

Comments
 (0)