-
Notifications
You must be signed in to change notification settings - Fork 514
Support robotCleanerOperatingState Routine #2443
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
57a2e4f
Chnage common variable to global variable
HunsupJung 57c5892
Add rvc operational state list handler
HunsupJung 9ce965f
Update supportedCommands attribute
HunsupJung 416eeb2
Update PR
HunsupJung 0ced929
Remove capability folder
HunsupJung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
.../SmartThings/matter-rvc/src/RvcOperationalState/server/attributes/AcceptedCommandList.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| local cluster_base = require "st.matter.cluster_base" | ||
| local data_types = require "st.matter.data_types" | ||
| local TLVParser = require "st.matter.TLV.TLVParser" | ||
|
|
||
| local AcceptedCommandList = { | ||
| ID = 0xFFF9, | ||
| NAME = "AcceptedCommandList", | ||
| base_type = require "st.matter.data_types.Array", | ||
| element_type = require "st.matter.data_types.Uint32", | ||
| } | ||
|
|
||
| function AcceptedCommandList:augment_type(data_type_obj) | ||
| for i, v in ipairs(data_type_obj.elements) do | ||
| data_type_obj.elements[i] = data_types.validate_or_build_type(v, AcceptedCommandList.element_type) | ||
| end | ||
| end | ||
|
|
||
| function AcceptedCommandList:new_value(...) | ||
| local o = self.base_type(table.unpack({...})) | ||
|
|
||
| return o | ||
| end | ||
|
|
||
| function AcceptedCommandList:read(device, endpoint_id) | ||
| return cluster_base.read( | ||
| device, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID, | ||
| nil --event_id | ||
| ) | ||
| end | ||
|
|
||
| function AcceptedCommandList:subscribe(device, endpoint_id) | ||
| return cluster_base.subscribe( | ||
| device, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID, | ||
| nil --event_id | ||
| ) | ||
| end | ||
|
|
||
| function AcceptedCommandList:set_parent_cluster(cluster) | ||
| self._cluster = cluster | ||
| return self | ||
| end | ||
|
|
||
| function AcceptedCommandList:build_test_report_data( | ||
| device, | ||
| endpoint_id, | ||
| value, | ||
| status | ||
| ) | ||
| local data = data_types.validate_or_build_type(value, self.base_type) | ||
|
|
||
| return cluster_base.build_test_report_data( | ||
| device, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID, | ||
| data, | ||
| status | ||
| ) | ||
| end | ||
|
|
||
| function AcceptedCommandList:deserialize(tlv_buf) | ||
| local data = TLVParser.decode_tlv(tlv_buf) | ||
|
|
||
| return data | ||
| end | ||
|
|
||
| setmetatable(AcceptedCommandList, {__call = AcceptedCommandList.new_value, __index = AcceptedCommandList.base_type}) | ||
| return AcceptedCommandList | ||
|
|
79 changes: 79 additions & 0 deletions
79
drivers/SmartThings/matter-rvc/src/RvcOperationalState/server/commands/GoHome.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| local data_types = require "st.matter.data_types" | ||
| local TLVParser = require "st.matter.TLV.TLVParser" | ||
|
|
||
| local GoHome = {} | ||
|
|
||
| GoHome.NAME = "GoHome" | ||
| GoHome.ID = 0x0080 | ||
| GoHome.field_defs = { | ||
| } | ||
|
|
||
| function GoHome:init(device, endpoint_id) | ||
| local out = {} | ||
| local args = {} | ||
| if #args > #self.field_defs then | ||
| error(self.NAME .. " received too many arguments") | ||
| end | ||
| for i,v in ipairs(self.field_defs) do | ||
| if v.is_optional and args[i] == nil then | ||
| out[v.name] = nil | ||
| elseif v.is_nullable and args[i] == nil then | ||
| out[v.name] = data_types.validate_or_build_type(args[i], data_types.Null, v.name) | ||
| out[v.name].field_id = v.field_id | ||
| elseif not v.is_optional and args[i] == nil then | ||
| out[v.name] = data_types.validate_or_build_type(v.default, v.data_type, v.name) | ||
| out[v.name].field_id = v.field_id | ||
| else | ||
| out[v.name] = data_types.validate_or_build_type(args[i], v.data_type, v.name) | ||
| out[v.name].field_id = v.field_id | ||
| end | ||
| end | ||
| setmetatable(out, { | ||
| __index = GoHome, | ||
| __tostring = GoHome.pretty_print | ||
| }) | ||
| return self._cluster:build_cluster_command( | ||
| device, | ||
| out, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID | ||
| ) | ||
| end | ||
|
|
||
| function GoHome:set_parent_cluster(cluster) | ||
| self._cluster = cluster | ||
| return self | ||
| end | ||
|
|
||
| function GoHome:augment_type(base_type_obj) | ||
| local elems = {} | ||
| for _, v in ipairs(base_type_obj.elements) do | ||
| for _, field_def in ipairs(self.field_defs) do | ||
| if field_def.field_id == v.field_id and | ||
| field_def.is_nullable and | ||
| (v.value == nil and v.elements == nil) then | ||
| elems[field_def.name] = data_types.validate_or_build_type(v, data_types.Null, field_def.field_name) | ||
| elseif field_def.field_id == v.field_id and not | ||
| (field_def.is_optional and v.value == nil) then | ||
| elems[field_def.name] = data_types.validate_or_build_type(v, field_def.data_type, field_def.field_name) | ||
| if field_def.element_type ~= nil then | ||
| for i, e in ipairs(elems[field_def.name].elements) do | ||
| elems[field_def.name].elements[i] = data_types.validate_or_build_type(e, field_def.element_type) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| base_type_obj.elements = elems | ||
| end | ||
|
|
||
| function GoHome:deserialize(tlv_buf) | ||
| local data = TLVParser.decode_tlv(tlv_buf) | ||
| self:augment_type(data) | ||
| return data | ||
| end | ||
|
|
||
| setmetatable(GoHome, {__call = GoHome.init}) | ||
|
|
||
| return GoHome |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.