-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Activity can't find WeatherConditions #542
Comments
@180909 Do you mean this? What manufacturer+devices produces fit/profile/filedef/activity.go Lines 25 to 57 in d933f55
Actually, this library is composable, it means you can create your own struct and still be able to use this library. Because if we try to guess which messages should be added to Please see this guide on how to define your own custom file type: https://github.com/muktihari/fit/blob/master/docs/usage.md#using-your-own-custom-file-types Alternatively, you can embed existing // Activity is an user-defined activity file.
type Activity struct {
filedef.Activity // <- Struct-embedding, so we can use its fields as our own.
WeatherConditions []*mesgdef.WeatherConditions
}
func (a *Activity) Add(mesg proto.Message) {
switch mesg.Num {
case mesgnum.WeatherConditions:
a.WeatherConditions = append(a.WeatherConditions, mesgdef.NewWeatherConditions(&mesg))
default:
a.Activity.Add(mesg) // Pass the other messages to filedef.Activity
}
}
func (a *Activity) ToFIT(options *mesgdef.Options) proto.FIT {
for _, v := range a.WeatherConditions {
a.Activity.Add(v.ToMesg(options)) // <- Put messages to (filedef.Activity).UnrelatedMessages
}
return a.Activity.ToFIT(options) // <- Let filedef.Activity to convert all messages into proto.FIT
} I hope it help, thanks. |
Activity can't find WeatherConditions
The text was updated successfully, but these errors were encountered: