simple_ble_start failed w/ error code 0xf

maldus
Posts: 83
Joined: Wed Jun 06, 2018 1:41 pm

simple_ble_start failed w/ error code 0xf

Postby maldus » Fri Nov 26, 2021 8:29 am

Hello everyone,
I'm working on an application that relies on the default BLE provisioning system to get access to a WiFi network (ESP-IDF version 4.0.4).
At first the procedure worked (got the credentials through the official Espressif BLE provisioning Android application), but after working on the firmware for a while I realized that the provisioning service now fails to start with an error that I cannot further evaluate. Here are the boot logs:

Code: Select all

I (464) cpu_start: Pro cpu up.
I (464) cpu_start: Application information:
I (464) cpu_start: Project name:     Airduino-Esp
I (467) cpu_start: App version:      0.12.4-dirty
I (472) cpu_start: Compile time:     Nov 26 2021 09:15:04
I (478) cpu_start: ELF file SHA256:  617bc05b338fcb62...
I (484) cpu_start: ESP-IDF:          v4.0-beta2-2056-gbe7df8bce-dirt
I (491) cpu_start: Starting app cpu, entry point is 0x40081468
I (0) cpu_start: App cpu up.
I (502) heap_init: Initializing. RAM available for dynamic allocation:
I (509) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (515) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (521) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (527) heap_init: At 3FFBDB5C len 00000004 (0 KiB): DRAM
I (533) heap_init: At 3FFCFEB0 len 00010150 (64 KiB): DRAM
I (539) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (546) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (552) heap_init: At 4009F6F8 len 00000908 (2 KiB): IRAM
I (558) cpu_start: Pro cpu start user code
I (576) spi_flash: detected chip: gd
I (577) spi_flash: flash io: dio
W (577) spi_flash: Detected size(16384k) larger than the size in the binary image header(8192k). Using the size in the binary image header.
I (587) esp_core_dump_flash: Init core dump to flash
I (593) esp_core_dump_flash: Found partition 'coredump' @ 610000 65536 bytes
I (602) cpu_start: Found core dump 10260 bytes in flash @ 0x610000
I (607) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (1626) Main: Peripherals initialized
I (1627) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1631) Can Utils: Driver installed
I (1634) CN_Hal: CAN driver started
I (1639) Main: Running on factory partition!
I (1668) Storage: Storage initialized!
I (1673) wifi:wifi driver task: 3ffd6a0c, prio:23, stack:6656, core=0
I (1673) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1679) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1703) wifi:wifi firmware version: e58bf82
I (1703) wifi:config NVS flash: enabled
I (1703) wifi:config nano formating: disabled
I (1704) wifi:Init data frame dynamic rx buffer num: 32
I (1708) wifi:Init management frame dynamic rx buffer num: 32
I (1714) wifi:Init management short buffer num: 32
I (1718) wifi:Init dynamic tx buffer num: 32
I (1722) wifi:Init static rx buffer size: 1600
I (1726) wifi:Init static rx buffer num: 10
I (1730) wifi:Init dynamic rx buffer num: 32
I (1735) wifi_init: rx ba win: 6
I (1738) wifi_init: tcpip mbox: 32
I (1742) wifi_init: udp mbox: 6
I (1746) wifi_init: tcp mbox: 6
I (1750) wifi_init: tcp tx win: 5744
I (1754) wifi_init: tcp rx win: 5744
I (1758) wifi_init: tcp mss: 1440
I (1762) wifi_init: WiFi IRAM OP enabled
I (1767) wifi_init: WiFi RX IRAM OP enabled
I (1772) Network: Starting BLE provisioning
I (1778) BTDM_INIT: BT controller compile version [14ea243]
I (1784) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1795) phy_init: phy_version 4660,0162888,Dec 23 2020
Coex register schm btdm cb faild
E (2040) protocomm_nimble: Error initializing GATT server
E (2041) protocomm_nimble: simple_ble_start failed w/ error code 0xf
E (2043) app_prov: Failed to start BLE provisioning (0xF)
E (2049) app_prov: Provisioning failed to start
E (2054) Network: Failed to start provisioning service!
Where the focus is on those lines:

Code: Select all

E (2040) protocomm_nimble: Error initializing GATT server
E (2041) protocomm_nimble: simple_ble_start failed w/ error code 0xf
E (2043) app_prov: Failed to start BLE provisioning (0xF)
E (2049) app_prov: Provisioning failed to start
I'm not sure I understand what the error code 0xf entails. This is the actual code I'm using to start the provisioning service:

Code: Select all

static esp_err_t app_prov_start_service(void) {
    /* Create new protocomm instance */
    g_prov->pc = protocomm_new();
    if (g_prov->pc == NULL) {
        ESP_LOGE(TAG, "Failed to create new protocomm instance");
        return ESP_FAIL;
    }

    /* Endpoint UUIDs */
    protocomm_ble_name_uuid_t nu_lookup_table[] = {
        {"prov-session", 0x0001},
        {"prov-config", 0x0002},
        {"proto-ver", 0x0003},
    };

    /* Config for protocomm_ble_start() */
    protocomm_ble_config_t config = {
        .service_uuid =
            {/* LSB <---------------------------------------
              * ---------------------------------------> MSB */
             0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02},
        .nu_lookup_count = sizeof(nu_lookup_table) / sizeof(nu_lookup_table[0]),
        .nu_lookup       = nu_lookup_table};

    /* With the above selection of 128bit primary service UUID and
     * 16bit endpoint UUIDs, the 128bit characteristic UUIDs will be
     * formed by replacing the 12th and 13th bytes of the service UUID
     * with the 16bit endpoint UUID, i.e. :
     *    service UUID : 021a9004-0382-4aea-bff4-6b3f1c5adfb4
     *     masked base : 021a____-0382-4aea-bff4-6b3f1c5adfb4
     * ------------------------------------------------------
     * resulting characteristic UUIDs :
     * 1) prov-session : 021a0001-0382-4aea-bff4-6b3f1c5adfb4
     * 2)  prov-config : 021a0002-0382-4aea-bff4-6b3f1c5adfb4
     * 3)    proto-ver : 021a0003-0382-4aea-bff4-6b3f1c5adfb4
     *
     * Also, note that each endpoint (characteristic) will have
     * an associated "Characteristic User Description" descriptor
     * with 16bit UUID 0x2901, each containing the corresponding
     * endpoint name. These descriptors can be used by a client
     * side application to figure out which characteristic is
     * mapped to which endpoint, without having to hardcode the
     * UUIDs */

    uint8_t eth_mac[6];
    esp_wifi_get_mac(WIFI_IF_STA, eth_mac);
    snprintf(config.device_name, sizeof(config.device_name), "%s%02X%02X%02X", ssid_prefix, eth_mac[3], eth_mac[4],
             eth_mac[5]);

    /* Release BT memory, as we need only BLE */
    esp_err_t err = esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);
    if (err) {
        ESP_LOGE(TAG, "bt_controller_mem_release failed %d", err);
        if (err != ESP_ERR_INVALID_STATE) {
            return err;
        }
    }

    /* Start protocomm layer on top of BLE */
    if ((err = protocomm_ble_start(g_prov->pc, &config)) != ESP_OK) {
        ESP_LOGE(TAG, "Failed to start BLE provisioning (0x%X)", err);
        return ESP_FAIL;
    }

    /* Set protocomm version verification endpoint for protocol */
    protocomm_set_version(g_prov->pc, "proto-ver", "V0.1");

    /* Set protocomm security type for endpoint */
    if (g_prov->security == 0) {
        protocomm_set_security(g_prov->pc, "prov-session", &protocomm_security0, NULL);
    } else if (g_prov->security == 1) {
        protocomm_set_security(g_prov->pc, "prov-session", &protocomm_security1, g_prov->pop);
    }

    /* Add endpoint for provisioning to set wifi station config */
    if (protocomm_add_endpoint(g_prov->pc, "prov-config", wifi_prov_config_data_handler, (void *)&wifi_prov_handlers) !=
        ESP_OK) {
        ESP_LOGE(TAG, "Failed to set provisioning endpoint");
        protocomm_ble_stop(g_prov->pc);
        return ESP_FAIL;
    }

    ESP_LOGI(TAG, "Provisioning started with BLE devname : '%s'", config.device_name);
    return ESP_OK;
}
What could be the cause of this issue?

Who is online

Users browsing this forum: Majestic-12 [Bot] and 110 guests