Skip to content

Commit

Permalink
ns: Convert LastBatteryPercentage value to [0, 100] interval
Browse files Browse the repository at this point in the history
  • Loading branch information
halimi committed Jan 22, 2025
1 parent ad82414 commit d63d032
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/ttn/lorawan/v3/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8954,7 +8954,7 @@ ncrc: [scheduled.advanced]

| Field | Validations |
| ----- | ----------- |
| `value` | <p>`float.lte`: `1`</p><p>`float.gte`: `0`</p> |
| `value` | <p>`float.lte`: `100`</p><p>`float.gte`: `0`</p> |

### <a name="ttn.lorawan.v3.MessagePayloadFormatters">Message `MessagePayloadFormatters`</a>

Expand Down
2 changes: 1 addition & 1 deletion api/ttn/lorawan/v3/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ message LastBatteryPercentage {
// The value is defined in the [0, 100] interval.
google.protobuf.FloatValue value = 2 [(validate.rules).float = {
gte: 0,
lte: 1
lte: 100
}];
// Time when last DevStatus MAC command was received.
google.protobuf.Timestamp received_at = 3;
Expand Down
3 changes: 2 additions & 1 deletion pkg/networkserver/grpc_gsns.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)

const (
Expand Down Expand Up @@ -911,7 +912,7 @@ func lastBatteryPercentage(dev *ttnpb.EndDevice) *ttnpb.LastBatteryPercentage {

return &ttnpb.LastBatteryPercentage{
FCnt: dev.MacState.LastDevStatusFCntUp,
Value: dev.BatteryPercentage,
Value: wrapperspb.Float(dev.BatteryPercentage.Value * 100),
ReceivedAt: dev.LastDevStatusReceivedAt,
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ttnpb/messages.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/ttnpb/messages.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/js/generated/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -40305,7 +40305,7 @@
"validate.rules": [
{
"name": "float.lte",
"value": 1
"value": 100
},
{
"name": "float.gte",
Expand Down

0 comments on commit d63d032

Please sign in to comment.