Skip to content
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

Wifi screen not coming up #1

Closed
iotechbugs opened this issue Apr 12, 2020 · 8 comments
Closed

Wifi screen not coming up #1

iotechbugs opened this issue Apr 12, 2020 · 8 comments

Comments

@iotechbugs
Copy link

Hi,

This is a very great library and its very handy too.

I see an issue. I found ESP32 device and discovered, but When i click discovered device following error is thrown. Could you help please?

I/flutter (31505): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (31505): EstablishSession error NoSuchMethodError: The method 'isConnected' was called on null.
I/flutter (31505): Receiver: null
I/flutter (31505): Tried calling: isConnected()
I/flutter (31505): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (31505): │ #0 WifiBloc._mapLoadToState
package:esp_provisioning_example/wifi_screen/wifi_bloc.dart:32
I/flutter (31505): │
I/flutter (31505): │ #1 WifiBloc.mapEventToState
package:esp_provisioning_example/wifi_screen/wifi_bloc.dart:21
I/flutter (31505): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (31505): │ ⛔ Error conencting to device Exception: Error establishSession
I/flutter (31505): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (31505): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (31505): │ #0 WifiBloc._mapLoadToState
package:esp_provisioning_example/wifi_screen/wifi_bloc.dart:42
I/flutter (31505): │
I/flutter (31505): │ #1 WifiBloc.mapEventToState
package:esp_provisioning_example/wifi_screen/wifi_bloc.dart:21
I/flutter (31505): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (31505): │ ⛔ Error scan WiFi network NoSuchMethodError: The method 'startScanWiFi' was called on null.
I/flutter (31505): │ ⛔ Receiver: null
I/flutter (31505): │ ⛔ Tried calling: startScanWiFi()
I/flutter (31505): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

@tuanpmt
Copy link
Contributor

tuanpmt commented Apr 12, 2020

@iotechbugs
Copy link
Author

iotechbugs commented Apr 13, 2020

After selecting the following error is coming. Mobile I use is ONEPLUS 6 PLUS, VS code, OS is MAC

Which version of flutter you are using. I am able to scan BLE devices only once, If I select provisioning second time no device is visible.

Adding logs for your reference.

esp_prov.log

@xandros6
Copy link

xandros6 commented May 16, 2020

The same problem from me. I'm comparing your implementation with ESP-IDF Android one, seem sone problem on encoding securitySession request.

The ESP32 logs this:

LE connection complete. handle=0 role=1 paddrtype=1 addr=77.77.e1.cd.f1.89 local_rpa=0.0.0.0.0.0 peer_rpa=0.0.0.0.0.0 itvl=39 latency=0 spvn_tmo=2000 mca=5
D (207171) protocomm_nimble: Inside BLE connect w/ conn_id - 0
ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0016 len=2
0x16 0x20 0x02 0x00 0x00 
Command Status: status=0 cmd_pkts=5 ocf=0x16 ogf=0x8
LE Remote Used Features. handle=0 feat=0f 00 00 00 00 00 00 00 
ble_hs_hci_evt_acl_process(): conn_handle=0 pb=2 len=27 data=0x17 0x00 0x04 0x00 0x52 0x06 0x00 0x10 0x01 0x5a 0x25 0xa2 0x01 0x22 0x0a 0x20 0x3e 0xbf 0x36 0x7d 0x1e 0x1a 0x84 0xce 0xb7 0x15 0x04 
rxed att command: write cmd; conn=0 handle=0x0006
D (210511) protocomm_nimble: Write attempt for uuid = 021aff51-0382-4aea-bff4-6b3f1c5adfb4, attr_handle = 6, data_len = 20
D (210531) protocomm_nimble: UUID did not match... 51
D (210531) protocomm_nimble: UUID (0x51) matched with proto-name = prov-session
E (210541) security1: Unable to unpack setup_req
D (210541) protocomm: SEC_EP Req handler returned 258

Checking ESP-IDF source code I think this is the point that goes to error:

static esp_err_t sec1_decrypt(uint32_t session_id,
                              const uint8_t *inbuf, ssize_t inlen,
                              uint8_t *outbuf, ssize_t *outlen)
{
    if (*outlen < inlen) {
        return ESP_ERR_INVALID_ARG;
    }

    if (!cur_session || cur_session->id != session_id) {
        return ESP_ERR_INVALID_STATE;
    }
    *outlen = inlen;
    int ret = mbedtls_aes_crypt_ctr(&cur_session->ctx_aes, inlen, &cur_session->nc_off,
                                    cur_session->rand, cur_session->stb, inbuf, outbuf);
    if (ret != 0) {
        ESP_LOGE(TAG, "Failed at mbedtls_aes_crypt_ctr with error code : %d", ret);
        return ESP_FAIL;
    }
    return ESP_OK;
}

ESP_ERR_INVALID_ARG = 0x102 = 258

I try also with the original ESP-IDF Android App and all is ok.

After selecting the following error is coming. Mobile I use is ONEPLUS 6 PLUS, VS code, OS is MAC

Which version of flutter you are using. I am able to scan BLE devices only once, If I select provisioning second time no device is visible.

Adding logs for your reference.

esp_prov.log

@xandros6
Copy link

Finally, I found a problem.
The problem is the MTU that for Android si as default to 23, so the maximum bytes arrived is 20.
This is the problem for the session creation (41 bytes are needed).
My workaround is to request a specific MTU (512), changing line 40 on transport_ble.dart:

await peripheral.connect(requestMtu: 512);

Now all works!

tuanpmt added a commit that referenced this issue Jun 14, 2020
@tuanpmt tuanpmt closed this as completed Jun 14, 2020
@jerry2501
Copy link

Hi,
This is brilliant library to use.

But I am facing same problem which @iotechbugs was facing earlier.

I also tried to run example app and Wifi screen is not appearing and getting same error as @iotechbugs got earlier.

@jerry2501
Copy link

Please help me out with it !!

@sklimovski
Copy link

Same issue @iotechbugs faced. Any update?

@MurtuzaSrashtaSoft
Copy link

same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants