-
Notifications
You must be signed in to change notification settings - Fork 314
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
fix(modify): Repair the issue of channel updating #1280
base: master
Are you sure you want to change the base?
fix(modify): Repair the issue of channel updating #1280
Conversation
… fail to be controlled.
src/controller/controller.ts
Outdated
let nwkUpdateId: number = 0x00; | ||
const isSupportsBackup = await this.adapter.supportsBackup(); | ||
if (isSupportsBackup) { | ||
const backup = await this.adapter.backup(this.getDeviceIeeeAddresses()); |
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.
I don't think making a new backup is necessary here? Can't we get the value from the existing backup?
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.
Agreed.
Probably the property should be added to the adapter type NetworkParameters, since it's part of that, and then can be used throughout controller without issue (cached on start).
Remains to see if all adapters provide it though.
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.
Okay, I will try to change it to the implementation method you suggested.
Was this tested against the described problem? From what I can tell, that quoted paragraph of the spec is for In the paragraph about the reception of nwk update req by a device, that value doesn't seem to matter.
As far as I can tell, the case where the nwkUpdateId would be used would be if a router decides to rejoin (for some reason), and it finds the same network on at least two different nodes, then it should pick the node with the higher nwkUpdateId (if any). But that scenario should not matter for a channel change, since routers receive the broadcast, and switch immediately. Leaving any offline router eventually powered back on, with only the new network available to rejoin. The spec is a bit lacking on that nwkUpdateId, which I noted in the implementation a while back: zigbee-herdsman/src/zspec/zdo/buffaloZdo.ts Lines 1199 to 1204 in 1c8d886
Short version: I don't expect it would solve the problem at hand? |
test/controller.test.ts
Outdated
@@ -56,6 +94,7 @@ const mocksendZclFrameToGroup = vi.fn(); | |||
const mocksendZclFrameToAll = vi.fn(); | |||
const mockAddInstallCode = vi.fn(); | |||
const mocksendZclFrameToEndpoint = vi.fn(); | |||
const mockApaterBackup = vi.fn().mockReturnValue(mockDummyBackup); |
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.
const mockAdapterBackup = vi.fn(() => Promise.resolve(mockDummyBackup));
should provide more accurate typing/testing (and fix typo).
(A lot of others also need refactoring, but might as well add new ones properly.)
…ue of nwkUpdateID, and implement the ember and ezsp adapters.
I added the same device to Home Assistant, then changed the channel. I found that it can be controlled normally in Home Assistant, and I also discovered that Home Assistant will increase the value of nwkUpdateID. |
When I update channels in zigbee2mqtt and restart, I find that some devices fail to be controlled. I discovered that when changing channels, the value of the nwkUpdateId field remains at 0.
I referred to the ZigBee specification and found the instructions regarding the modification of the nwkUpdateId field when changing channels:
"The network manager should broadcast a Mgmt_NWK_Update_req notifying devices of the new channel. The broadcast shall be to all devices with RxOnWhenIdle equal to TRUE. The network manager is responsible for incrementing the nwkUpdateId parameter from the NIB and including it in the Mgmt_NWK_Update_req. The network manager shall set a timer based on the value of apsChannelTimer upon issue of a Mgmt_NWK_Update_req that changes channels and shall not issue another such command until this timer expires. However, during this period, the network manager can complete the above analysis. However, instead of changing channels, the network manager would report to the local application using Mgmt_NWK_Update_notify and the application can force a channel change using the Mgmt_NWK_Update_req."