Closed tri-bao closed 7 months ago
Facing the same issue. I updated the package to latest build 0.2.13, and using a test string as a proof of possession, and getting "Failed to create session."
Hey! I got the same issue on 0.2.12 when testing yesterday (however my error was onCharacteristicWrite, status : 133
). But it worked after applying #36. Did you rebuild the app after updating the package? Our device uses proof of possession.
Note that it may be related to #46. Before I have time to patch it, you need to make sure the device and the app use the same security setting (secure1 for just POP, secure2 for POP + username). Otherwise you will get "Failed to create session", because the esp-provisioning-android library does not check if the security setting matches until after connection is established and you try scanning for wifi.
@mateogianolio thanks for reaching out, I've given the app following permissions:
`
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission
android:name="android.permission.NEARBY_WIFI_DEVICES"
android:usesPermissionFlags="neverForLocation" />
Plus I'm using the following configuration prior to device connection:
const prefix = 'PROV_';
const transport = ESPTransport.ble;
const security = ESPSecurity.secure;
and while connecting I'm using a simple string as a pop:
device
.connect('pop123456')
`
All the permissions are granted, the device scanning is working, device gets connected but on wifi scan call it fails, I've updated the package to 0.2.13 and still getting this.
any help much appreciated thanks.
And when I try to provision the device by manually passing ssid and password (bypassing the wifi scan function) i get the same error.
Maybe stupid question: Have you configured your proof of possession string pop123456
on your ESP device?
I am not sure if our device has a POP configuration, thats why i tried with no value and unsecure security value as well.
Make sure that you did correct configurations on esp side for security version 1:
Our app follows the example app. searchESPDevices works, we can see list of devices.
On a found device, we call
await espDevice.connect(proofOfPossession);
Then call
await device.scanWifiList();
This always fails with messageFailed to create session
.Logcat show
onCharacteristicWrite, status : 4
And stack traceI found that the android native property
ESPDevice.proofOfPossession
is always an empty string which make it unable to create BLE session with the device, hence the error above.The reason is:
onPeripheralFound
, whenever a device is found (viasearchESPDevices
), it is added to theespDevices
cache. But it that time, there is no PoP, thus no thing is set. Here is the line.createESPDevice
, if the device exist in theespDevices
cache, it returns immediately without filling the Pop. And the result is that PoP is never used.I made a patch and it seems to work for my case. Not know if there is any other cases. I don't check the property
android.bluetooth.BluetoothDevice.uuids
because it always null in my case: the bluetooth device is not null by its uuids is null. fix_proofOfPossession_is_never_set_patch.txt