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

Add support for Scheduler messages #444

Merged
merged 3 commits into from
Sep 15, 2022

Conversation

daretobeorjan
Copy link
Contributor

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.

Added a slightly more abstract way of reading bits from a packed structure.
Copy link
Member

@philips77 philips77 left a 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
Copy link
Member

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) {
Copy link
Member

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, split the line.

@philips77
Copy link
Member

Great work, thank you!

@philips77 philips77 merged commit 66e9efd into NordicSemiconductor:main Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants