espressif / book-esp32c3-iot-projects

《ESP32-C3 物联网工程开发实战》配套代码
97 stars 29 forks source link

Add device error with RainMaker ios app #4

Closed meiliang1123 closed 1 year ago

meiliang1123 commented 1 year ago

flashed example code of 5_rainmaker, and then add device via RainMaker.

app failed with message Device could not be connected please try again

and monitor print this log:

I (1924) app_wifi: If QR code is not visible, copy paste the below URL in a browser.
https://rainmaker.espressif.com/qrcode.html?data={"ver":"v1","name":"PROV_f49b2b","pop":"f2c3b97f","transport":"ble"}
I (1944) app_wifi: Provisioning Started. Name : PROV_f49b2b, POP : f2c3b97f
I (41134) NimBLE: GAP procedure initiated: advertise;
I (41134) NimBLE: disc_mode=2
I (41134) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256
I (41144) NimBLE:

I (41144) NimBLE: rc=0
I (41144) NimBLE: return with rc=0

i add some code in ble_gap.c

    ble_gap_slave[0].op = BLE_GAP_OP_S_ADV;

    rc = ble_gap_adv_enable_tx(1);
    if (rc != 0) {
        ble_gap_slave_reset_state(0);
        goto done;
    }

    if (duration_ms != BLE_HS_FOREVER) {
        ble_gap_slave_set_timer(duration_ticks);
    }

    rc = 0;
    BLE_HS_LOG(INFO, "return with rc=%d", rc);
done:
    ble_hs_unlock();

    if (rc != 0) {
        STATS_INC(ble_gap_stats, adv_start_fail);
    }
    return rc;

there may have some problem with my dev environment, i can't start idf.py gdb

PS E:\esp\book-esp32c3-iot-projects\device_firmware\5_rainmaker> idf.py gdb
Executing action: gdb
C:\Espressif\tools\riscv32-esp-elf\esp-2021r2-patch3-8.4.0\riscv32-esp-elf\bin\riscv32-esp-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (crosstool-NG esp-2021r2-patch3) 9.2.90.20200913-git
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-host_w64-mingw32 --target=riscv32-esp-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
E:/esp/book-esp32c3-iot-projects/device_firmware/5_rainmaker/build\gdbinit:2: Error in sourced command file:
:3333: (undocumented errno 138).
(gdb)

and i run the blufi code in idf examples with espblufi app can connect successfully, what is the different between these.

Questions: do we have any specific document of wifi provisioning? how can i reproduce where is the problem?

shixinke-orion commented 1 year ago

Hello, blufi and wifi_provisioning are two different Bluetooth provisioning application solutions. For example, they use different UUIDs, different communication protocols, and different packet encapsulation formats. You can see some docs for wifi_provisioning here .

From the log of the monitor, there is no obvious error message. I guess it may be related to some settings. Can you try the following operations?

meiliang1123 commented 1 year ago

hi @shixinke-orion, I'm really appreciate for your help. I Fixed this problem by removing the paired device. So I think it is a problem of RainMaker iOS App when the bt device is already paired, you should really report this bug to the developer. Thanks!