diff --git a/docs/_static/matter_qrcode_20202021_3840.png b/docs/_static/matter_qrcode_20202021_3840.png new file mode 100644 index 000000000..51df5327e Binary files /dev/null and b/docs/_static/matter_qrcode_20202021_3840.png differ diff --git a/docs/en/developing.rst b/docs/en/developing.rst index e2b6f793a..1d058b0fe 100644 --- a/docs/en/developing.rst +++ b/docs/en/developing.rst @@ -193,6 +193,73 @@ In the above commands: - ``20202021`` is the ``setup_passcode`` - ``3840`` is the ``discriminator`` + +Above method commissions the device using setup passcode and discriminator. Device can also be commissioned using manual pairing code or QR code. + +To Commission the device using manual pairing code 34970112332 + +.. only:: esp32 or esp32c3 + + :: + + pairing code-wifi 0x7283 34970112332 + +.. only:: esp32h2 + + :: + pairing code-thread 0x7283 hex: 34970112332 + +Above default manual pairing code contains following values: + +:: + + Version: 0 + Custom flow: 0 (STANDARD) + Discriminator: 3840 + Passcode: 20202021 + +To commission the device using QR code MT:Y.K9042C00KA0648G00 + +.. only:: esp32 or esp32c3 + + :: + + pairing code-wifi 0x7283 MT:Y.K9042C00KA0648G00 + +.. only:: esp32h2 + + :: + + pairing code-thread 0x7283 hex: MT:Y.K9042C00KA0648G00 + +Above QR Code contains the below default values: +:: + + Version: 0 + Vendor ID: 65521 + ProductID: 32768 + Custom flow: 0 (STANDARD) + Discovery Bitmask: 0x02 (BLE) + Long discriminator: 3840 (0xf00) + Passcode: 20202021 + +Alternatively, you can scan the below QR code image using Matter commissioners. + +.. figure:: ../_static/matter_qrcode_20202021_3840.png + :align: center + :alt: Default QR Code + :figclass: align-center + +If QR code is not visible, paste the below link into the browser and scan the QR code. +:: + + https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT:Y.K9042C00KA0648G00 + +If you want to use different values for commissioning the device, please use the +`mfg-tool `__ +to generate the factory partition which has to be flashed on the device. +It also generates the new pairing code and QR code image using which you can commission the device. + 2.2.1.2 Post Commissioning Setup ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/examples/blemesh_bridge/main/CMakeLists.txt b/examples/blemesh_bridge/main/CMakeLists.txt index e99dc3c5c..6697be26c 100644 --- a/examples/blemesh_bridge/main/CMakeLists.txt +++ b/examples/blemesh_bridge/main/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_bridge) +set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_bridge) idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." diff --git a/examples/blemesh_bridge/main/app_main.cpp b/examples/blemesh_bridge/main/app_main.cpp index a562f4b26..29507f9ef 100644 --- a/examples/blemesh_bridge/main/app_main.cpp +++ b/examples/blemesh_bridge/main/app_main.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include "blemesh_bridge.h" @@ -103,8 +102,6 @@ extern "C" void app_main() ESP_LOGE(TAG, "Matter start failed: %d", err); } - app_qrcode_print(); - #if CONFIG_ENABLE_CHIP_SHELL esp_matter_console_diagnostics_register_commands(); esp_matter_console_init(); diff --git a/examples/common/app_qrcode/CMakeLists.txt b/examples/common/app_qrcode/CMakeLists.txt deleted file mode 100644 index 0421569f4..000000000 --- a/examples/common/app_qrcode/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(priv_requires_list chip bt esp32_mbedtls qrcode) - -if ("${IDF_TARGET}" STREQUAL "esp32h2") - list(APPEND priv_requires_list openthread) -endif() -idf_component_register(SRCS app_qrcode.cpp - INCLUDE_DIRS . - PRIV_REQUIRES ${priv_requires_list}) diff --git a/examples/common/app_qrcode/app_qrcode.cpp b/examples/common/app_qrcode/app_qrcode.cpp deleted file mode 100644 index 58d3d144f..000000000 --- a/examples/common/app_qrcode/app_qrcode.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace ::chip; -using namespace ::chip::DeviceLayer; - -#define QRCODE_BASE_URL "https://dhrishi.github.io/connectedhomeip/qrcode.html" -static const char *TAG = "app_qrcode"; - -esp_err_t app_qrcode_get_payload(char **qrcode_text, char **short_manual_code_text, char **long_manual_code_text) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - esp_err_t ret = ESP_OK; - uint16_t discriminator; - uint32_t setup_pin_code; - uint16_t vendor_id; - uint16_t product_id; - SetupPayload payload; - std::string qrcode_payload; - std::string short_manual_code_payload; - std::string long_manual_code_payload; - - /* Get details */ - err = GetCommissionableDataProvider()->GetSetupDiscriminator(discriminator); - if (err != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "Couldn't get discriminator: %s", ErrorStr(err)); - return ESP_FAIL; - } - - err = GetCommissionableDataProvider()->GetSetupPasscode(setup_pin_code); - if (err != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "Couldn't get setup_pin_code: %s", ErrorStr(err)); - return ESP_FAIL; - } - - err = GetDeviceInstanceInfoProvider()->GetVendorId(vendor_id); - if (err != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "Couldn't get vendor_id: %s", ErrorStr(err)); - return ESP_FAIL; - } - - err = GetDeviceInstanceInfoProvider()->GetProductId(product_id); - if (err != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "Couldn't get product_id: %s", ErrorStr(err)); - return ESP_FAIL; - } - - ESP_LOGI(TAG, "Setup discriminator: %u (0x%x)", discriminator, discriminator); - ESP_LOGI(TAG, "Setup PIN code: %u (0x%x)", setup_pin_code, setup_pin_code); - ESP_LOGI(TAG, "Vendor ID: %u (0x%x)", vendor_id, vendor_id); - ESP_LOGI(TAG, "Product ID: %u (0x%x)", product_id, product_id); - - /* Set details */ - payload.version = 0; - payload.discriminator.SetLongValue(discriminator); - payload.setUpPINCode = setup_pin_code; - payload.rendezvousInformation.SetValue(RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); - payload.vendorID = vendor_id; - payload.productID = product_id; - - /* Change format and alloc for qrcode */ - QRCodeSetupPayloadGenerator qrcode_generator(payload); - err = qrcode_generator.payloadBase38Representation(qrcode_payload); - if (err == CHIP_NO_ERROR) { - *qrcode_text = (char *)calloc(1, qrcode_payload.length() + 1); - if (*qrcode_text) { - strcpy(*qrcode_text, qrcode_payload.c_str()); - } - } else { - ESP_LOGE(TAG, "Couldn't get qrcode payload string %s", ErrorStr(err)); - ret = ESP_FAIL; - } - - /* Change format and alloc for short manual code. This can be used for 'non qrcode' devices. */ - ManualSetupPayloadGenerator short_manual_code_generator(payload); - err = short_manual_code_generator.payloadDecimalStringRepresentation(short_manual_code_payload); - if (err == CHIP_NO_ERROR) { - *short_manual_code_text = (char *)calloc(1, short_manual_code_payload.length() + 1); - if (*short_manual_code_text) { - strcpy(*short_manual_code_text, short_manual_code_payload.c_str()); - } - } else { - ESP_LOGE(TAG, "Couldn't get short manual code payload string %s", ErrorStr(err)); - ret = ESP_FAIL; - } - - /* Change format and alloc for long manual code. This can be used for 'non qrcode' devices. */ - /* Just adding this extra commissioning flow to the payload. */ - payload.commissioningFlow = CommissioningFlow::kCustom; - ManualSetupPayloadGenerator long_manual_code_generator(payload); - err = long_manual_code_generator.payloadDecimalStringRepresentation(long_manual_code_payload); - if (err == CHIP_NO_ERROR) { - *long_manual_code_text = (char *)calloc(1, long_manual_code_payload.length() + 1); - if (*long_manual_code_text) { - strcpy(*long_manual_code_text, long_manual_code_payload.c_str()); - } - } else { - ESP_LOGE(TAG, "Couldn't get long manual code payload string %s", ErrorStr(err)); - ret = ESP_FAIL; - } - - return ret; -} - -esp_err_t app_qrcode_print() -{ - /* Get */ - char *qrcode_text = NULL; - char *short_manual_code_text = NULL; - char *long_manual_code_text = NULL; - bool manual_code_exists = false; - esp_err_t err = app_qrcode_get_payload(&qrcode_text, &short_manual_code_text, &long_manual_code_text); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Error getting payload %d", err); - } - - /* Manual code */ - if (short_manual_code_text || long_manual_code_text) { - /* This flag is just used for the print at the end */ - manual_code_exists = true; - } - - /* Short manual code */ - if (short_manual_code_text) { - /* Print */ - ESP_LOGI(TAG, "Short manual code: %s", short_manual_code_text); - - /* Free */ - free(short_manual_code_text); - } else { - ESP_LOGE(TAG, "Error getting short manual code text"); - err = ESP_FAIL; - } - - /* Long manual code */ - if (long_manual_code_text) { - /* Print */ - ESP_LOGI(TAG, "Long manual code: %s", long_manual_code_text); - - /* Free */ - free(long_manual_code_text); - } else { - ESP_LOGE(TAG, "Error getting long manual code text"); - err = ESP_FAIL; - } - - /* QR code */ - if (qrcode_text) { - /* Print */ - ESP_LOGI(TAG, "Scan this QR code from the Matter phone app for Commissioning."); - esp_qrcode_config_t cfg = ESP_QRCODE_CONFIG_DEFAULT(); - /* Changing the error tolerance to MED. This increases the size of the qr code and makes it more detailed. The - * default is set to LOW and sometimes the qr code scanner is not able to recognize that. */ - cfg.qrcode_ecc_level = ESP_QRCODE_ECC_MED; - esp_qrcode_generate(&cfg, qrcode_text); - ESP_LOGI(TAG, "If QR code is not visible, copy paste the URL in a browser: %s?data=%s", QRCODE_BASE_URL, - qrcode_text); - - /* Free */ - free(qrcode_text); - } else { - ESP_LOGE(TAG, "Error getting qrcode text"); - err = ESP_FAIL; - } - - if (manual_code_exists) { - ESP_LOGI(TAG, - "In case QR code is not supported, manual code mentioned above can be entered in the Matter phone app " - "for Commissioning"); - } - - return err; -} diff --git a/examples/common/app_qrcode/app_qrcode.h b/examples/common/app_qrcode/app_qrcode.h deleted file mode 100644 index 5f7d84f39..000000000 --- a/examples/common/app_qrcode/app_qrcode.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ - -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Print the QR code for commissioning - * - * Fetch the QR code details for commissioning from Matter and print it on the console. - * Also print the manual code if QR code is not supported. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t app_qrcode_print(); - -#ifdef __cplusplus -} -#endif diff --git a/examples/common/app_qrcode/idf_component.yml b/examples/common/app_qrcode/idf_component.yml deleted file mode 100644 index ed852323c..000000000 --- a/examples/common/app_qrcode/idf_component.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - qrcode: "^0.1.0" diff --git a/examples/light/main/CMakeLists.txt b/examples/light/main/CMakeLists.txt index 8903feced..4945f7377 100644 --- a/examples/light/main/CMakeLists.txt +++ b/examples/light/main/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_reset) +set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_reset) idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index 94fd5b01c..24f646861 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -15,7 +15,6 @@ #include #include -#include #include static const char *TAG = "app_main"; @@ -127,7 +126,6 @@ extern "C" void app_main() if (err != ESP_OK) { ESP_LOGE(TAG, "Matter start failed: %d", err); } - app_qrcode_print(); /* Starting driver with default values */ app_driver_light_set_defaults(light_endpoint_id); diff --git a/examples/light_switch/main/CMakeLists.txt b/examples/light_switch/main/CMakeLists.txt index 8903feced..4945f7377 100644 --- a/examples/light_switch/main/CMakeLists.txt +++ b/examples/light_switch/main/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_reset) +set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_reset) idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." diff --git a/examples/light_switch/main/app_main.cpp b/examples/light_switch/main/app_main.cpp index 700366720..11f92eed6 100644 --- a/examples/light_switch/main/app_main.cpp +++ b/examples/light_switch/main/app_main.cpp @@ -15,7 +15,6 @@ #include #include -#include #include static const char *TAG = "app_main"; @@ -113,7 +112,6 @@ extern "C" void app_main() if (err != ESP_OK) { ESP_LOGE(TAG, "Matter start failed: %d", err); } - app_qrcode_print(); #if CONFIG_ENABLE_CHIP_SHELL esp_matter_console_diagnostics_register_commands(); diff --git a/examples/zap_light/main/CMakeLists.txt b/examples/zap_light/main/CMakeLists.txt index 8903feced..4945f7377 100644 --- a/examples/zap_light/main/CMakeLists.txt +++ b/examples/zap_light/main/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_reset) +set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_reset) idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." diff --git a/examples/zap_light/main/app_main.cpp b/examples/zap_light/main/app_main.cpp index 29072cbbb..6bc8dd8c9 100644 --- a/examples/zap_light/main/app_main.cpp +++ b/examples/zap_light/main/app_main.cpp @@ -14,7 +14,6 @@ #include #include -#include #include using namespace esp_matter; @@ -95,7 +94,6 @@ extern "C" void app_main() if (err != ESP_OK) { ESP_LOGE(TAG, "Matter start failed: %d", err); } - app_qrcode_print(); /* Starting driver with default values */ app_driver_light_set_defaults(light_endpoint_id); diff --git a/examples/zigbee_bridge/main/CMakeLists.txt b/examples/zigbee_bridge/main/CMakeLists.txt index e99c48f4a..81937c003 100644 --- a/examples/zigbee_bridge/main/CMakeLists.txt +++ b/examples/zigbee_bridge/main/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_bridge +set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_bridge esp-zboss-lib) idf_component_register(SRC_DIRS "." diff --git a/examples/zigbee_bridge/main/app_main.cpp b/examples/zigbee_bridge/main/app_main.cpp index 59e23e2cf..ebdf22e7d 100644 --- a/examples/zigbee_bridge/main/app_main.cpp +++ b/examples/zigbee_bridge/main/app_main.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -102,8 +101,6 @@ extern "C" void app_main() ESP_LOGE(TAG, "Matter start failed: %d", err); } - app_qrcode_print(); - #if CONFIG_ENABLE_CHIP_SHELL esp_matter_console_diagnostics_register_commands(); esp_matter_console_init(); diff --git a/examples/zigbee_bridge/main/idf_component.yml b/examples/zigbee_bridge/main/idf_component.yml index 4aa45948f..da2f5d001 100644 --- a/examples/zigbee_bridge/main/idf_component.yml +++ b/examples/zigbee_bridge/main/idf_component.yml @@ -2,7 +2,6 @@ dependencies: espressif/esp-zboss-lib: "~0.1.0" espressif/esp-zigbee-lib: "~0.1.1" - qrcode: "^0.1.0" espressif/mdns: "^1.0.3" ## Required IDF version idf: