-
Notifications
You must be signed in to change notification settings - Fork 41
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
Provide examples of how to restrict pairing as a device (TZ-222) #66
Comments
Hi @nomis ,
The
For this issue, could you please consider referring to the following code for implementation on your end device example?
|
When debugging this it's important to be aware that routers on the network may remain in pairing mode for up to 250 seconds, so it can look like the device is able to rejoin a network on its own (with previous configuration information) but the network is actually still in pairing mode.
Checking
I have not yet been able to test that it will only use the configured network because I'll need to set up a second coordinator.
I can do this by deciding when to call
This happens automatically but I can't do it manually without restarting. I don't know why you're suggesting
I can do this by deciding when to call I'd like to implement a "leave network" button, is there a way to do This would need to work even while attempting to connect to a new/existing network. |
Hi, Some assistance that may be useful for creating the restricted pairing device example as following.
If the device possesses network configurations, the stack will facilitate the device in rejoining the configured network. It will then exclusively issue the
If the end device receive
Instead of calling |
I've now verified that it won't change network (when the configured network is unavailable) even if there's another coordinator accepting new devices.
This works properly if I'm connected but not if I'm in the process of connecting. If I do the following, I get a
|
There are other side effects combining this with It's as if it's still trying to leave the previous network on startup before it'll do anything else. |
@nomis , Regarding the issue, do you have any further topics you'd like to discuss or address? Let me know if there's anything else you need assistance with regarding this matter. |
I've already made comments #66 (comment) and #66 (comment) that haven't been addressed: When leaving there must be no previous state left that will impact the next startup/join. It should be possible to leave at any time, including while joining. That's not possible without side effects. |
I'm sorry this is an old topic and it remains open! @xieqinan can you help me on this? I just wanted to say I would like to implement similar functionality for my device. Here is a link for the project I'm working on Zigbee Gas Meter You can see all source code I wrote. I can recognise a button "long-press" even when the device wakes-up from sleep but it doesn't leave the network when using
Can someone help review what I'm doing wrong there? What I want to achieve can be described as: Long pressing the device button should:
Thanks in advance |
Based on your project, you may refer to the code below to achieve your objective:
|
My comments in #66 (comment) have not yet been addressed. |
In any case, I want to thank you @nomis because your explanations on this topic helped me to move forward. Cheers |
@nomis , Sorry for the delay. Let's revisit and discuss the issue based on the esp-zigbee-sdk v1.6.2.
The device cannot configure all network parameters to rejoin a specific network directly, but it can be restricted to join a specific network by calling
The
If the |
You've replied to my original message instead of this comment: #66 (comment) Specifically: "This works properly if I'm connected but not if I'm in the process of connecting." and "There are other side effects combining this with esp_zb_zdo_device_leave_req()." |
Okay, I’m not sure if the scenario is common, but you can address the concern by calling |
Hi @nomis , To resolve this issue, I still have two questions that I would like to confirm with you.
Regarding this requirement, I understand that "network configuration" can be regarded as the device having previously joined a network, meaning its network settings are already configured, rather than using specific APIs to set up network parameters for a factory-new device. If this is incorrect, please clarify.
I still have a bit confuse for the above calling. Could you please share the reason for the above action? If you intend for the device to steer, it means the device is still not on a network, so why do you want it to leave the network |
I have a "join" and "leave" (not be a part of any network) action, and expect to be able to "leave" at any time without workarounds like "reboot the device". I expect that cancelling steering will work although I can't test it right now. Without documentation explaining how to do these kinds of things there's no way to know what functions are available or when they can be called. |
Understood. We will ensure that |
Hi void zb_leave(uint8_t param)
{
esp_zb_zdo_mgmt_leave_req_param_t cmd_req;
esp_zb_get_long_address(cmd_req.device_address);
cmd_req.dst_nwk_addr = 0xffff;
ESP_LOGI(TAG, "Leave address: 0x%llx, 0x%x", *(uint64_t *)cmd_req.device_address, cmd_req.dst_nwk_addr);
esp_zb_zdo_device_leave_req(&cmd_req, NULL, NULL);
}
void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
{
uint32_t *p_sg_p = signal_struct->p_app_signal;
esp_err_t err_status = signal_struct->esp_err_status;
esp_zb_app_signal_type_t sig_type = *p_sg_p;
switch (sig_type) {
case ESP_ZB_ZDO_SIGNAL_SKIP_STARTUP:
ESP_LOGI(TAG, "Initialize Zigbee stack");
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_INITIALIZATION);
break;
case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START:
case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT:
if (err_status == ESP_OK) {
ESP_LOGI(TAG, "Deferred driver initialization %s", deferred_driver_init() ? "failed" : "successful");
ESP_LOGI(TAG, "Device started up in%s factory-reset mode", esp_zb_bdb_is_factory_new() ? "" : " non");
if (esp_zb_bdb_is_factory_new()) {
ESP_LOGI(TAG, "Start network steering");
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING);
esp_zb_scheduler_alarm((esp_zb_callback_t)zb_leave, 0, 1000);
esp_zb_scheduler_alarm((esp_zb_callback_t)zb_leave, 0, 2000);
esp_zb_scheduler_alarm((esp_zb_callback_t)zb_leave, 0, 3000);
esp_zb_scheduler_alarm((esp_zb_callback_t)zb_leave, 0, 5000);
} else {
ESP_LOGI(TAG, "Device rebooted");
}
} else {
ESP_LOGW(TAG, "%s failed with status: %s, retrying", esp_zb_zdo_signal_to_string(sig_type),
esp_err_to_name(err_status));
esp_zb_scheduler_alarm((esp_zb_callback_t)bdb_start_top_level_commissioning_cb,
ESP_ZB_BDB_MODE_INITIALIZATION, 1000);
}
break;
case ESP_ZB_BDB_SIGNAL_STEERING:
printf("error code: 0x%x\n", err_status);
esp_zb_ieee_addr_t extended_pan_id;
esp_zb_get_extended_pan_id(extended_pan_id);
ESP_LOGI(TAG,
"Joined network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: "
"0x%04hx, Channel:%d, Short Address: 0x%04hx)",
extended_pan_id[7], extended_pan_id[6], extended_pan_id[5], extended_pan_id[4], extended_pan_id[3],
extended_pan_id[2], extended_pan_id[1], extended_pan_id[0], esp_zb_get_pan_id(),
esp_zb_get_current_channel(), esp_zb_get_short_address());
break;
default:
ESP_LOGI(TAG, "ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type,
esp_err_to_name(err_status));
break;
}
} I used the code above to reproduce this issue. Have you verified the status of the When If an error status is received from the |
When I remove the device from the network using the coordinator I get
ESP_ZB_NWK_LEAVE_TYPE_RESET
but then it immediately rejoins the network when I restart the device (and only if I restart the device).This is annoying during development because my coordinator/Home Assistant lets the device automatically reconnect even when not being requested to add new devices and it's hard to get it to clear out the old endpoint information. It's also bad for security because the device should never unexpectedly connect to someone else's network.
Please provide an example of how to make the device:
ESP_ZB_NWK_LEAVE_TYPE_RESET
occurs (without restarting)ESP_ZB_NWK_LEAVE_TYPE_RESET
occurs and the network information has been deleted - i.e. a new "pairing" request (currently I have to restart to do this)The text was updated successfully, but these errors were encountered: