-
Notifications
You must be signed in to change notification settings - Fork 122
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
Add support for Scheduler messages #444
Conversation
Added a slightly more abstract way of reading bits from a packed structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the amazing PR. Great job.
I added 3 minor comments, but I can do this myself, if you prefer, after merging.
public let dayOfWeek: SchedulerDayOfWeek | ||
public let action: SchedulerAction | ||
public let transitionTime: TransitionTime | ||
public let sceneNumber: UInt16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use Scene
type for scene? That's an alias for UInt16
, but can be more readable.
sceneNumber = 0 | ||
} | ||
|
||
public init(year: SchedulerYear, month: SchedulerMonth, day: SchedulerDay, hour: SchedulerHour, minute: SchedulerMinute, second: SchedulerSecond, dayOfWeek: SchedulerDayOfWeek, action: SchedulerAction, transitionTime: TransitionTime, sceneNumber: UInt16) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, split the line.
let transitionTime = TransitionTime(rawValue: parameters[7]) | ||
let sceneNumber: UInt16 = parameters.read(fromOffset: 8) | ||
|
||
return (index, SchedulerRegistryEntry(year: SchedulerYear(value: year), month: SchedulerMonth(value: month), day: SchedulerDay(value: day), hour: SchedulerHour(value: hour), minute: SchedulerMinute(value: minute), second: SchedulerSecond(value: second), dayOfWeek: SchedulerDayOfWeek(value: dayOfWeek), action: SchedulerAction(rawValue: action)!, transitionTime: transitionTime, sceneNumber: sceneNumber)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, split the line.
Great work, thank you! |
As usual, not tested live, but unit tests are written using data extracted from Android SDK which has been tested live.
Have a look at my attempt to make reading and writing the structures that are "packed" from the mesh protocol and see what you think. This could be used on the Time messages as well if it's good enough.