Skip to content
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

Rebase v0.60.0 #1095

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions pkg/gateway/lwm2m/client/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func (r *Resource) ReadAsJSON() string {
}

type ObjectData struct {
ParameterName string `json:"n,omitempty"`
FloatValue float64 `json:"v,omitempty"`
StringValue string `json:"sv,omitempty"`
ParameterName *string `json:"n,omitempty"`
FloatValue *float64 `json:"v,omitempty"`
StringValue *string `json:"sv,omitempty"`
// Pointer to avoid marshal false value
BoolValue *bool `json:"bv,omitempty"`
}
Expand Down Expand Up @@ -113,16 +113,19 @@ func (o *Object) readAll(basePath string) ([]ObjectData, error) {

switch newData := data.(type) {
case int, int32, int64, int16, int8:
objectDataList = append(objectDataList, ObjectData{ParameterName: basePath, FloatValue: float64(newData.(int))})
var floatValue = float64(newData.(int))
objectDataList = append(objectDataList, ObjectData{ParameterName: &basePath, FloatValue: &floatValue})
case float32, float64:
objectDataList = append(objectDataList, ObjectData{ParameterName: basePath, FloatValue: newData.(float64)})
var floatValue = newData.(float64)
objectDataList = append(objectDataList, ObjectData{ParameterName: &basePath, FloatValue: &floatValue})
case string:
objectDataList = append(objectDataList, ObjectData{ParameterName: basePath, StringValue: newData})
objectDataList = append(objectDataList, ObjectData{ParameterName: &basePath, StringValue: &newData})
case bool:
objectDataList = append(objectDataList, ObjectData{ParameterName: basePath, BoolValue: &newData})
objectDataList = append(objectDataList, ObjectData{ParameterName: &basePath, BoolValue: &newData})
default:
// default to string
objectDataList = append(objectDataList, ObjectData{ParameterName: basePath, StringValue: fmt.Sprintf("%v", data)})
var stringValue = fmt.Sprintf("%v", data)
objectDataList = append(objectDataList, ObjectData{ParameterName: &basePath, StringValue: &stringValue})
}
}

Expand Down
Loading